1<?php
2// phpcs:ignoreFile -- this file violates PSR2 by definition
3/**
4 * These classes and functions are deprecated and will be removed in future releases
5 *
6 * Note: when adding to this file, please also add appropriate actions to _test/rector.php
7 */
8
9use dokuwiki\Debug\DebugHelper;
10use dokuwiki\Subscriptions\BulkSubscriptionSender;
11use dokuwiki\Subscriptions\MediaSubscriptionSender;
12use dokuwiki\Subscriptions\PageSubscriptionSender;
13use dokuwiki\Subscriptions\RegistrationSubscriptionSender;
14use dokuwiki\Subscriptions\SubscriberManager;
15
16/**
17 * @inheritdoc
18 * @deprecated 2018-05-07
19 */
20class RemoteAccessDeniedException extends \dokuwiki\Remote\AccessDeniedException
21{
22    /** @inheritdoc */
23    public function __construct($message = "", $code = 0, Throwable $previous = null)
24    {
25        dbg_deprecated(\dokuwiki\Remote\AccessDeniedException::class);
26        parent::__construct($message, $code, $previous);
27    }
28
29}
30
31/**
32 * @inheritdoc
33 * @deprecated 2018-05-07
34 */
35class RemoteException extends \dokuwiki\Remote\RemoteException
36{
37    /** @inheritdoc */
38    public function __construct($message = "", $code = 0, Throwable $previous = null)
39    {
40        dbg_deprecated(\dokuwiki\Remote\RemoteException::class);
41        parent::__construct($message, $code, $previous);
42    }
43
44}
45
46/**
47 * Escapes regex characters other than (, ) and /
48 *
49 * @param string $str
50 * @return string
51 * @deprecated 2018-05-04
52 */
53function Doku_Lexer_Escape($str)
54{
55    dbg_deprecated('\\dokuwiki\\Parsing\\Lexer\\Lexer::escape()');
56    return \dokuwiki\Parsing\Lexer\Lexer::escape($str);
57}
58
59/**
60 * @inheritdoc
61 * @deprecated 2018-06-01
62 */
63class setting extends \dokuwiki\plugin\config\core\Setting\Setting
64{
65    /** @inheritdoc */
66    public function __construct($key, array $params = null)
67    {
68        dbg_deprecated(\dokuwiki\plugin\config\core\Setting\Setting::class);
69        parent::__construct($key, $params);
70    }
71}
72
73/**
74 * @inheritdoc
75 * @deprecated 2018-06-01
76 */
77class setting_authtype extends \dokuwiki\plugin\config\core\Setting\SettingAuthtype
78{
79    /** @inheritdoc */
80    public function __construct($key, array $params = null)
81    {
82        dbg_deprecated(\dokuwiki\plugin\config\core\Setting\SettingAuthtype::class);
83        parent::__construct($key, $params);
84    }
85}
86
87/**
88 * @inheritdoc
89 * @deprecated 2018-06-01
90 */
91class setting_string extends \dokuwiki\plugin\config\core\Setting\SettingString
92{
93    /** @inheritdoc */
94    public function __construct($key, array $params = null)
95    {
96        dbg_deprecated(\dokuwiki\plugin\config\core\Setting\SettingString::class);
97        parent::__construct($key, $params);
98    }
99}
100
101/**
102 * @inheritdoc
103 * @deprecated 2018-06-15
104 */
105class PageChangelog extends \dokuwiki\ChangeLog\PageChangeLog
106{
107    /** @inheritdoc */
108    public function __construct($id, $chunk_size = 8192)
109    {
110        dbg_deprecated(\dokuwiki\ChangeLog\PageChangeLog::class);
111        parent::__construct($id, $chunk_size);
112    }
113}
114
115/**
116 * @inheritdoc
117 * @deprecated 2018-06-15
118 */
119class MediaChangelog extends \dokuwiki\ChangeLog\MediaChangeLog
120{
121    /** @inheritdoc */
122    public function __construct($id, $chunk_size = 8192)
123    {
124        dbg_deprecated(\dokuwiki\ChangeLog\MediaChangeLog::class);
125        parent::__construct($id, $chunk_size);
126    }
127}
128
129/** Behavior switch for JSON::decode() */
130define('JSON_LOOSE_TYPE', 16);
131
132/** Behavior switch for JSON::decode() */
133define('JSON_STRICT_TYPE', 0);
134
135/**
136 * Encode/Decode JSON
137 * @deprecated 2018-07-27
138 */
139class JSON
140{
141    protected $use = 0;
142
143    /**
144     * @param int $use JSON_*_TYPE flag
145     * @deprecated  2018-07-27
146     */
147    public function __construct($use = JSON_STRICT_TYPE)
148    {
149        $this->use = $use;
150    }
151
152    /**
153     * Encode given structure to JSON
154     *
155     * @param mixed $var
156     * @return string
157     * @deprecated  2018-07-27
158     */
159    public function encode($var)
160    {
161        dbg_deprecated('json_encode');
162        return json_encode($var);
163    }
164
165    /**
166     * Alias for encode()
167     * @param $var
168     * @return string
169     * @deprecated  2018-07-27
170     */
171    public function enc($var) {
172        return $this->encode($var);
173    }
174
175    /**
176     * Decode given string from JSON
177     *
178     * @param string $str
179     * @return mixed
180     * @deprecated  2018-07-27
181     */
182    public function decode($str)
183    {
184        dbg_deprecated('json_encode');
185        return json_decode($str, ($this->use == JSON_LOOSE_TYPE));
186    }
187
188    /**
189     * Alias for decode
190     *
191     * @param $str
192     * @return mixed
193     * @deprecated  2018-07-27
194     */
195    public function dec($str) {
196        return $this->decode($str);
197    }
198}
199
200/**
201 * @inheritdoc
202 * @deprecated 2019-02-19
203 */
204class Input extends \dokuwiki\Input\Input {
205    /**
206     * @inheritdoc
207     * @deprecated 2019-02-19
208     */
209    public function __construct()
210    {
211        dbg_deprecated(\dokuwiki\Input\Input::class);
212        parent::__construct();
213    }
214}
215
216/**
217 * @inheritdoc
218 * @deprecated 2019-02-19
219 */
220class PostInput extends \dokuwiki\Input\Post {
221    /**
222     * @inheritdoc
223     * @deprecated 2019-02-19
224     */
225    public function __construct()
226    {
227        dbg_deprecated(\dokuwiki\Input\Post::class);
228        parent::__construct();
229    }
230}
231
232/**
233 * @inheritdoc
234 * @deprecated 2019-02-19
235 */
236class GetInput extends \dokuwiki\Input\Get {
237    /**
238     * @inheritdoc
239     * @deprecated 2019-02-19
240     */
241    public function __construct()
242    {
243        dbg_deprecated(\dokuwiki\Input\Get::class);
244        parent::__construct();
245    }
246}
247
248/**
249 * @inheritdoc
250 * @deprecated 2019-02-19
251 */
252class ServerInput extends \dokuwiki\Input\Server {
253    /**
254     * @inheritdoc
255     * @deprecated 2019-02-19
256     */
257    public function __construct()
258    {
259        dbg_deprecated(\dokuwiki\Input\Server::class);
260        parent::__construct();
261    }
262}
263
264/**
265 * @inheritdoc
266 * @deprecated 2019-03-06
267 */
268class PassHash extends \dokuwiki\PassHash {
269    /**
270     * @inheritdoc
271     * @deprecated 2019-03-06
272     */
273    public function __construct()
274    {
275        dbg_deprecated(\dokuwiki\PassHash::class);
276    }
277}
278
279/**
280 * @deprecated since 2019-03-17 use \dokuwiki\HTTP\HTTPClientException instead!
281 */
282class HTTPClientException extends \dokuwiki\HTTP\HTTPClientException {
283
284    /**
285     * @inheritdoc
286     * @deprecated 2019-03-17
287     */
288    public function __construct($message = '', $code = 0, $previous = null)
289    {
290        DebugHelper::dbgDeprecatedFunction(dokuwiki\HTTP\HTTPClientException::class);
291        parent::__construct($message, $code, $previous);
292    }
293}
294
295/**
296 * @deprecated since 2019-03-17 use \dokuwiki\HTTP\HTTPClient instead!
297 */
298class HTTPClient extends \dokuwiki\HTTP\HTTPClient {
299
300    /**
301     * @inheritdoc
302     * @deprecated 2019-03-17
303     */
304    public function __construct()
305    {
306        DebugHelper::dbgDeprecatedFunction(dokuwiki\HTTP\HTTPClient::class);
307        parent::__construct();
308    }
309}
310
311/**
312 * @deprecated since 2019-03-17 use \dokuwiki\HTTP\DokuHTTPClient instead!
313 */
314class DokuHTTPClient extends \dokuwiki\HTTP\DokuHTTPClient
315{
316
317    /**
318     * @inheritdoc
319     * @deprecated 2019-03-17
320     */
321    public function __construct()
322    {
323        DebugHelper::dbgDeprecatedFunction(dokuwiki\HTTP\DokuHTTPClient::class);
324        parent::__construct();
325    }
326}
327
328/**
329 * function wrapper to process (create, trigger and destroy) an event
330 *
331 * @param  string   $name               name for the event
332 * @param  mixed    $data               event data
333 * @param  callback $action             (optional, default=NULL) default action, a php callback function
334 * @param  bool     $canPreventDefault  (optional, default=true) can hooks prevent the default action
335 *
336 * @return mixed                        the event results value after all event processing is complete
337 *                                      by default this is the return value of the default action however
338 *                                      it can be set or modified by event handler hooks
339 * @deprecated 2018-06-15
340 */
341function trigger_event($name, &$data, $action=null, $canPreventDefault=true) {
342    dbg_deprecated('\dokuwiki\Extension\Event::createAndTrigger');
343    return \dokuwiki\Extension\Event::createAndTrigger($name, $data, $action, $canPreventDefault);
344}
345
346/**
347 * @inheritdoc
348 * @deprecated 2018-06-15
349 */
350class Doku_Plugin_Controller extends \dokuwiki\Extension\PluginController {
351    /** @inheritdoc */
352    public function __construct()
353    {
354        dbg_deprecated(\dokuwiki\Extension\PluginController::class);
355        parent::__construct();
356    }
357}
358
359
360/**
361 * Class for handling (email) subscriptions
362 *
363 * @author  Adrian Lang <lang@cosmocode.de>
364 * @author  Andreas Gohr <andi@splitbrain.org>
365 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
366 *
367 * @deprecated 2019-04-22 Use the classes in the \dokuwiki\Subscriptions namespace instead!
368 */
369class Subscription {
370
371    /**
372     * Check if subscription system is enabled
373     *
374     * @return bool
375     *
376     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::isenabled
377     */
378    public function isenabled() {
379        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::isenabled');
380        $subscriberManager = new SubscriberManager();
381        return $subscriberManager->isenabled();
382    }
383
384    /**
385     * Recursively search for matching subscriptions
386     *
387     * This function searches all relevant subscription files for a page or
388     * namespace.
389     *
390     * @author Adrian Lang <lang@cosmocode.de>
391     *
392     * @param string         $page The target object’s (namespace or page) id
393     * @param string|array   $user
394     * @param string|array   $style
395     * @param string|array   $data
396     * @return array
397     *
398     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::subscribers
399     */
400    public function subscribers($page, $user = null, $style = null, $data = null) {
401        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::subscribers');
402        $manager = new SubscriberManager();
403        return $manager->subscribers($page, $user, $style, $data);
404    }
405
406    /**
407     * Adds a new subscription for the given page or namespace
408     *
409     * This will automatically overwrite any existent subscription for the given user on this
410     * *exact* page or namespace. It will *not* modify any subscription that may exist in higher namespaces.
411     *
412     * @param string $id The target page or namespace, specified by id; Namespaces
413     *                   are identified by appending a colon.
414     * @param string $user
415     * @param string $style
416     * @param string $data
417     * @throws Exception when user or style is empty
418     * @return bool
419     *
420     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::add
421     */
422    public function add($id, $user, $style, $data = '') {
423        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::add');
424        $manager = new SubscriberManager();
425        return $manager->add($id, $user, $style, $data);
426    }
427
428    /**
429     * Removes a subscription for the given page or namespace
430     *
431     * This removes all subscriptions matching the given criteria on the given page or
432     * namespace. It will *not* modify any subscriptions that may exist in higher
433     * namespaces.
434     *
435     * @param string         $id   The target object’s (namespace or page) id
436     * @param string|array   $user
437     * @param string|array   $style
438     * @param string|array   $data
439     * @return bool
440     *
441     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::remove
442     */
443    public function remove($id, $user = null, $style = null, $data = null) {
444        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::remove');
445        $manager = new SubscriberManager();
446        return $manager->remove($id, $user, $style, $data);
447    }
448
449    /**
450     * Get data for $INFO['subscribed']
451     *
452     * $INFO['subscribed'] is either false if no subscription for the current page
453     * and user is in effect. Else it contains an array of arrays with the fields
454     * “target”, “style”, and optionally “data”.
455     *
456     * @param string $id  Page ID, defaults to global $ID
457     * @param string $user User, defaults to $_SERVER['REMOTE_USER']
458     * @return array|false
459     * @author Adrian Lang <lang@cosmocode.de>
460     *
461     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::userSubscription
462     */
463    public function user_subscription($id = '', $user = '') {
464        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::userSubscription');
465        $manager = new SubscriberManager();
466        return $manager->userSubscription($id, $user);
467    }
468
469    /**
470     * Send digest and list subscriptions
471     *
472     * This sends mails to all subscribers that have a subscription for namespaces above
473     * the given page if the needed $conf['subscribe_time'] has passed already.
474     *
475     * This function is called form lib/exe/indexer.php
476     *
477     * @param string $page
478     * @return int number of sent mails
479     *
480     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\BulkSubscriptionSender::sendBulk
481     */
482    public function send_bulk($page) {
483        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\BulkSubscriptionSender::sendBulk');
484        $subscriptionSender = new BulkSubscriptionSender();
485        return $subscriptionSender->sendBulk($page);
486    }
487
488    /**
489     * Send the diff for some page change
490     *
491     * @param string   $subscriber_mail The target mail address
492     * @param string   $template        Mail template ('subscr_digest', 'subscr_single', 'mailtext', ...)
493     * @param string   $id              Page for which the notification is
494     * @param int|null $rev             Old revision if any
495     * @param string   $summary         Change summary if any
496     * @return bool                     true if successfully sent
497     *
498     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\PageSubscriptionSender::sendPageDiff
499     */
500    public function send_diff($subscriber_mail, $template, $id, $rev = null, $summary = '') {
501        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\PageSubscriptionSender::sendPageDiff');
502        $subscriptionSender = new PageSubscriptionSender();
503        return $subscriptionSender->sendPageDiff($subscriber_mail, $template, $id, $rev, $summary);
504    }
505
506    /**
507     * Send the diff for some media change
508     *
509     * @fixme this should embed thumbnails of images in HTML version
510     *
511     * @param string   $subscriber_mail The target mail address
512     * @param string   $template        Mail template ('uploadmail', ...)
513     * @param string   $id              Media file for which the notification is
514     * @param int|bool $rev             Old revision if any
515     *
516     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\MediaSubscriptionSender::sendMediaDiff
517     */
518    public function send_media_diff($subscriber_mail, $template, $id, $rev = false) {
519        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\MediaSubscriptionSender::sendMediaDiff');
520        $subscriptionSender = new MediaSubscriptionSender();
521        return $subscriptionSender->sendMediaDiff($subscriber_mail, $template, $id, $rev);
522    }
523
524    /**
525     * Send a notify mail on new registration
526     *
527     * @author Andreas Gohr <andi@splitbrain.org>
528     *
529     * @param string $login    login name of the new user
530     * @param string $fullname full name of the new user
531     * @param string $email    email address of the new user
532     * @return bool true if a mail was sent
533     *
534     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\RegistrationSubscriptionSender::sendRegister
535     */
536    public function send_register($login, $fullname, $email) {
537        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\RegistrationSubscriptionSender::sendRegister');
538        $subscriptionSender = new RegistrationSubscriptionSender();
539        return $subscriptionSender->sendRegister($login, $fullname, $email);
540    }
541
542
543    /**
544     * Default callback for COMMON_NOTIFY_ADDRESSLIST
545     *
546     * Aggregates all email addresses of user who have subscribed the given page with 'every' style
547     *
548     * @author Steven Danz <steven-danz@kc.rr.com>
549     * @author Adrian Lang <lang@cosmocode.de>
550     *
551     * @todo move the whole functionality into this class, trigger SUBSCRIPTION_NOTIFY_ADDRESSLIST instead,
552     *       use an array for the addresses within it
553     *
554     * @param array &$data Containing the entries:
555     *    - $id (the page id),
556     *    - $self (whether the author should be notified,
557     *    - $addresslist (current email address list)
558     *    - $replacements (array of additional string substitutions, @KEY@ to be replaced by value)
559     *
560     * @deprecated 2019-04-20 \dokuwiki\Subscriptions\SubscriberManager::notifyAddresses
561     */
562    public function notifyaddresses(&$data) {
563        DebugHelper::dbgDeprecatedFunction('\dokuwiki\Subscriptions\SubscriberManager::notifyAddresses');
564        $manager = new SubscriberManager();
565        $manager->notifyAddresses($data);
566    }
567}
568
569/**
570 * @deprecated 2019-12-29 use \dokuwiki\Search\Indexer
571 */
572class Doku_Indexer extends \dokuwiki\Search\Indexer {};
573
574/**
575 * @deprecated since 2021-11-11 use \dokuwiki\Remote\IXR\Client instead!
576 */
577class IXR_Client extends \dokuwiki\Remote\IXR\Client
578{
579    /**
580     * @inheritdoc
581     * @deprecated 2021-11-11
582     */
583    public function __construct($server, $path = false, $port = 80, $timeout = 15, $timeout_io = null)
584    {
585        DebugHelper::dbgDeprecatedFunction(dokuwiki\Remote\IXR\Client::class);
586        parent::__construct($server, $path, $port, $timeout, $timeout_io);
587    }
588}
589/**
590 * @deprecated since 2021-11-11 use \IXR\Client\ClientMulticall instead!
591 */
592class IXR_ClientMulticall extends \IXR\Client\ClientMulticall
593{
594    /**
595     * @inheritdoc
596     * @deprecated 2021-11-11
597     */
598    public function __construct($server, $path = false, $port = 80)
599    {
600        DebugHelper::dbgDeprecatedFunction(IXR\Client\ClientMulticall::class);
601        parent::__construct($server, $path, $port);
602    }
603}
604/**
605 * @deprecated since 2021-11-11 use \IXR\Server\Server instead!
606 */
607class IXR_Server extends \IXR\Server\Server
608{
609    /**
610     * @inheritdoc
611     * @deprecated 2021-11-11
612     */
613    public function __construct($callbacks = false, $data = false, $wait = false)
614    {
615        DebugHelper::dbgDeprecatedFunction(IXR\Server\Server::class);
616        parent::__construct($callbacks, $data, $wait);
617    }
618}
619/**
620 * @deprecated since 2021-11-11 use \IXR\Server\IntrospectionServer instead!
621 */
622class IXR_IntrospectionServer extends \IXR\Server\IntrospectionServer
623{
624    /**
625     * @inheritdoc
626     * @deprecated 2021-11-11
627     */
628    public function __construct()
629    {
630        DebugHelper::dbgDeprecatedFunction(IXR\Server\IntrospectionServer::class);
631        parent::__construct();
632    }
633}
634/**
635 * @deprecated since 2021-11-11 use \IXR\Request\Request instead!
636 */
637class IXR_Request extends \IXR\Request\Request
638{
639    /**
640     * @inheritdoc
641     * @deprecated 2021-11-11
642     */
643    public function __construct($method, $args)
644    {
645        DebugHelper::dbgDeprecatedFunction(IXR\Request\Request::class);
646        parent::__construct($method, $args);
647    }
648}
649/**
650 * @deprecated since 2021-11-11 use \IXR\Message\Message instead!
651 */
652class IXR_Message extends IXR\Message\Message
653{
654    /**
655     * @inheritdoc
656     * @deprecated 2021-11-11
657     */
658    public function __construct($message)
659    {
660        DebugHelper::dbgDeprecatedFunction(IXR\Message\Message::class);
661        parent::__construct($message);
662    }
663}
664/**
665 * @deprecated since 2021-11-11 use \IXR\Message\Error instead!
666 */
667class IXR_Error extends \IXR\Message\Error
668{
669    /**
670     * @inheritdoc
671     * @deprecated 2021-11-11
672     */
673    public function __construct($code, $message)
674    {
675        DebugHelper::dbgDeprecatedFunction(IXR\Message\Error::class);
676        parent::__construct($code, $message);
677    }
678}
679/**
680 * @deprecated since 2021-11-11 use \IXR\DataType\Date instead!
681 */
682class IXR_Date extends \IXR\DataType\Date
683{
684    /**
685     * @inheritdoc
686     * @deprecated 2021-11-11
687     */
688    public function __construct($time)
689    {
690        DebugHelper::dbgDeprecatedFunction(IXR\DataType\Date::class);
691        parent::__construct($time);
692    }
693}
694/**
695 * @deprecated since 2021-11-11 use \IXR\DataType\Base64 instead!
696 */
697class IXR_Base64 extends \IXR\DataType\Base64
698{
699    /**
700     * @inheritdoc
701     * @deprecated 2021-11-11
702     */
703    public function __construct($data)
704    {
705        DebugHelper::dbgDeprecatedFunction(IXR\DataType\Base64::class);
706        parent::__construct($data);
707    }
708}
709/**
710 * @deprecated since 2021-11-11 use \IXR\DataType\Value instead!
711 */
712class IXR_Value extends \IXR\DataType\Value
713{
714    /**
715     * @inheritdoc
716     * @deprecated 2021-11-11
717     */
718    public function __construct($data, $type = null)
719    {
720        DebugHelper::dbgDeprecatedFunction(IXR\DataType\Value::class);
721        parent::__construct($data, $type);
722    }
723}
724
725/**
726 * print a newline terminated string
727 *
728 * You can give an indention as optional parameter
729 *
730 * @author Andreas Gohr <andi@splitbrain.org>
731 *
732 * @param string $string  line of text
733 * @param int    $indent  number of spaces indention
734 * @deprecated 2023-08-31 use echo instead
735 */
736function ptln($string, $indent = 0)
737{
738    DebugHelper::dbgDeprecatedFunction('echo');
739    echo str_repeat(' ', $indent) . "$string\n";
740}
741