xref: /dokuwiki/inc/deprecated.php (revision 75aef198cdc7307a75ab63c9403e704e2194959a)
1<?php
2// phpcs:ignoreFile -- this file violates PSR-12 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\MailUtils;
11
12/**
13 * @deprecated since 2021-11-11 use \dokuwiki\Remote\IXR\Client instead!
14 */
15class IXR_Client extends \dokuwiki\Remote\IXR\Client
16{
17    /**
18     * @inheritdoc
19     * @deprecated 2021-11-11
20     */
21    public function __construct($server, $path = false, $port = 80, $timeout = 15, $timeout_io = null)
22    {
23        DebugHelper::dbgDeprecatedFunction(dokuwiki\Remote\IXR\Client::class);
24        parent::__construct($server, $path, $port, $timeout, $timeout_io);
25    }
26}
27/**
28 * @deprecated since 2021-11-11 use \IXR\Client\ClientMulticall instead!
29 */
30class IXR_ClientMulticall extends \IXR\Client\ClientMulticall
31{
32    /**
33     * @inheritdoc
34     * @deprecated 2021-11-11
35     */
36    public function __construct($server, $path = false, $port = 80)
37    {
38        DebugHelper::dbgDeprecatedFunction(IXR\Client\ClientMulticall::class);
39        parent::__construct($server, $path, $port);
40    }
41}
42/**
43 * @deprecated since 2021-11-11 use \IXR\Server\Server instead!
44 */
45class IXR_Server extends \IXR\Server\Server
46{
47    /**
48     * @inheritdoc
49     * @deprecated 2021-11-11
50     */
51    public function __construct($callbacks = false, $data = false, $wait = false)
52    {
53        DebugHelper::dbgDeprecatedFunction(IXR\Server\Server::class);
54        parent::__construct($callbacks, $data, $wait);
55    }
56}
57/**
58 * @deprecated since 2021-11-11 use \IXR\Server\IntrospectionServer instead!
59 */
60class IXR_IntrospectionServer extends \IXR\Server\IntrospectionServer
61{
62    /**
63     * @inheritdoc
64     * @deprecated 2021-11-11
65     */
66    public function __construct()
67    {
68        DebugHelper::dbgDeprecatedFunction(IXR\Server\IntrospectionServer::class);
69        parent::__construct();
70    }
71}
72/**
73 * @deprecated since 2021-11-11 use \IXR\Request\Request instead!
74 */
75class IXR_Request extends \IXR\Request\Request
76{
77    /**
78     * @inheritdoc
79     * @deprecated 2021-11-11
80     */
81    public function __construct($method, $args)
82    {
83        DebugHelper::dbgDeprecatedFunction(IXR\Request\Request::class);
84        parent::__construct($method, $args);
85    }
86}
87/**
88 * @deprecated since 2021-11-11 use \IXR\Message\Message instead!
89 */
90class IXR_Message extends IXR\Message\Message
91{
92    /**
93     * @inheritdoc
94     * @deprecated 2021-11-11
95     */
96    public function __construct($message)
97    {
98        DebugHelper::dbgDeprecatedFunction(IXR\Message\Message::class);
99        parent::__construct($message);
100    }
101}
102/**
103 * @deprecated since 2021-11-11 use \IXR\Message\Error instead!
104 */
105class IXR_Error extends \IXR\Message\Error
106{
107    /**
108     * @inheritdoc
109     * @deprecated 2021-11-11
110     */
111    public function __construct($code, $message)
112    {
113        DebugHelper::dbgDeprecatedFunction(IXR\Message\Error::class);
114        parent::__construct($code, $message);
115    }
116}
117/**
118 * @deprecated since 2021-11-11 use \IXR\DataType\Date instead!
119 */
120class IXR_Date extends \IXR\DataType\Date
121{
122    /**
123     * @inheritdoc
124     * @deprecated 2021-11-11
125     */
126    public function __construct($time)
127    {
128        DebugHelper::dbgDeprecatedFunction(IXR\DataType\Date::class);
129        parent::__construct($time);
130    }
131}
132/**
133 * @deprecated since 2021-11-11 use \IXR\DataType\Base64 instead!
134 */
135class IXR_Base64 extends \IXR\DataType\Base64
136{
137    /**
138     * @inheritdoc
139     * @deprecated 2021-11-11
140     */
141    public function __construct($data)
142    {
143        DebugHelper::dbgDeprecatedFunction(IXR\DataType\Base64::class);
144        parent::__construct($data);
145    }
146}
147/**
148 * @deprecated since 2021-11-11 use \IXR\DataType\Value instead!
149 */
150class IXR_Value extends \IXR\DataType\Value
151{
152    /**
153     * @inheritdoc
154     * @deprecated 2021-11-11
155     */
156    public function __construct($data, $type = null)
157    {
158        DebugHelper::dbgDeprecatedFunction(IXR\DataType\Value::class);
159        parent::__construct($data, $type);
160    }
161}
162
163/**
164 * returns all available parser syntax modes in correct order
165 *
166 * @return array[] with for each plugin the array('sort' => sortnumber, 'mode' => mode string, 'obj'  => plugin object)
167 * @author Andreas Gohr <andi@splitbrain.org>
168 * @deprecated 2026-04-16 use \dokuwiki\Parsing\ModeRegistry::getModes() instead
169 */
170function p_get_parsermodes()
171{
172    DebugHelper::dbgDeprecatedFunction(\dokuwiki\Parsing\ModeRegistry::class . '::getModes()');
173    return \dokuwiki\Parsing\ModeRegistry::getInstance()->getModes();
174}
175
176/**
177 * Callback function for usort
178 *
179 * @param array $a
180 * @param array $b
181 * @return int $a is lower/equal/higher than $b
182 * @author Andreas Gohr <andi@splitbrain.org>
183 * @deprecated 2026-04-16 use \dokuwiki\Parsing\ModeRegistry::sortModes() instead
184 */
185function p_sort_modes($a, $b)
186{
187    DebugHelper::dbgDeprecatedFunction(\dokuwiki\Parsing\ModeRegistry::class . '::sortModes()');
188    return \dokuwiki\Parsing\ModeRegistry::sortModes($a, $b);
189}
190
191/**
192 * print a newline terminated string
193 *
194 * You can give an indention as optional parameter
195 *
196 * @author Andreas Gohr <andi@splitbrain.org>
197 *
198 * @param string $string  line of text
199 * @param int    $indent  number of spaces indention
200 * @deprecated 2023-08-31 use echo instead
201 */
202function ptln($string, $indent = 0)
203{
204    DebugHelper::dbgDeprecatedFunction('echo');
205    echo str_repeat(' ', $indent) . "$string\n";
206}
207
208/**
209 * Adds/updates the search index for the given page
210 *
211 * Locking is handled internally.
212 *
213 * @param string        $page   name of the page to index
214 * @param boolean       $verbose    print status messages
215 * @param boolean       $force  force reindexing even when the index is up to date
216 * @return string|boolean  the function completed successfully
217 *
218 * @deprecated 2026-04-07 use Indexer class instead
219 */
220function idx_addPage($page, $verbose = false, $force = false)
221{
222    DebugHelper::dbgDeprecatedFunction('dokuwiki\Search\Indexer::addPage()');
223    try {
224        (new dokuwiki\Search\Indexer())->addPage($page, $force);
225        return true;
226    } catch (\dokuwiki\Search\Exception\SearchException $e) {
227        return false;
228    }
229}
230
231/**
232 * Create an instance of the indexer.
233 *
234 * Returns a {@see dokuwiki\Search\LegacyIndexer} that preserves the legacy
235 * Doku_Indexer return contract (true|string on success/failure for the four
236 * mutating methods) so existing plugins keep working without try/catch.
237 *
238 * @return dokuwiki\Search\LegacyIndexer
239 *
240 * @deprecated 2026-04-07 use dokuwiki\Search\Indexer directly
241 */
242function idx_get_indexer()
243{
244    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Indexer::class);
245    return new dokuwiki\Search\LegacyIndexer();
246}
247
248/**
249 * Read the list of words in an index (if it exists).
250 *
251 * @param string $idx
252 * @param string $suffix
253 * @return array
254 *
255 * @deprecated 2026-04-07 use Index classes directly
256 */
257function idx_getIndex($idx, $suffix)
258{
259    DebugHelper::dbgDeprecatedFunction('Index classes');
260    global $conf;
261    $fn = $conf['indexdir'] . '/' . $idx . $suffix . '.idx';
262    if (!file_exists($fn)) return [];
263    return file($fn);
264}
265
266/**
267 * Find tokens in the fulltext index
268 *
269 * @param array $words list of words to search for
270 * @return array list of pages found
271 *
272 * @deprecated 2026-04-07 use CollectionSearch on PageFulltextCollection instead
273 */
274function idx_lookup(&$words)
275{
276    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Collection\CollectionSearch::class);
277    return (new dokuwiki\Search\LegacyIndexer())->lookup($words);
278}
279
280/**
281 * Get the list of lengths indexed in the wiki.
282 *
283 * @return array
284 *
285 * @deprecated 2026-04-07 use PageFulltextCollection::getTokenIndexMaximum() instead
286 */
287function idx_listIndexLengths()
288{
289    DebugHelper::dbgDeprecatedFunction('PageFulltextCollection::getTokenIndexMaximum()');
290    global $conf;
291    $idx = [];
292    $files = glob($conf['indexdir'] . '/i*.idx');
293    if ($files) {
294        foreach ($files as $file) {
295            if (preg_match('/i(\d+)\.idx$/', $file, $match)) {
296                $idx[] = (int)$match[1];
297            }
298        }
299        sort($idx);
300    }
301    return $idx;
302}
303
304/**
305 * Get the word lengths that have been indexed.
306 *
307 * @param array|int $filter
308 * @return array
309 *
310 * @deprecated 2026-04-07 use PageFulltextCollection::getTokenIndexMaximum() instead
311 */
312function idx_indexLengths($filter)
313{
314    DebugHelper::dbgDeprecatedFunction('PageFulltextCollection::getTokenIndexMaximum()');
315    global $conf;
316    $idx = [];
317    if (is_array($filter)) {
318        $path = $conf['indexdir'] . "/i";
319        foreach (array_keys($filter) as $key) {
320            if (file_exists($path . $key . '.idx'))
321                $idx[] = $key;
322        }
323    } else {
324        $lengths = idx_listIndexLengths();
325        foreach ($lengths as $length) {
326            if ((int)$length >= (int)$filter)
327                $idx[] = $length;
328        }
329    }
330    return $idx;
331}
332
333/**
334 * Execute a fulltext search
335 *
336 * @param string $query search query
337 * @param array $highlight words to highlight
338 * @param string|null $sort sorting order
339 * @param int|string|null $after only show results after this date
340 * @param int|string|null $before only show results before this date
341 * @return array
342 *
343 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::pageSearch() instead
344 */
345function ft_pageSearch($query, &$highlight, $sort = null, $after = null, $before = null)
346{
347    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::pageSearch()');
348    if (!is_array($highlight)) $highlight = [];
349    return (new dokuwiki\Search\FulltextSearch())->pageSearch($query, $highlight, $sort, $after, $before);
350}
351
352/**
353 * Returns the backlinks for a given page
354 *
355 * @param string $id page id
356 * @param bool $ignore_perms
357 * @return string[]
358 *
359 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::backlinks() instead
360 */
361function ft_backlinks($id, $ignore_perms = false)
362{
363    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::backlinks()');
364    return (new dokuwiki\Search\MetadataSearch())->backlinks($id, $ignore_perms);
365}
366
367/**
368 * Returns the pages that use a given media file
369 *
370 * @param string $id media id
371 * @param bool $ignore_perms
372 * @return string[]
373 *
374 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::mediause() instead
375 */
376function ft_mediause($id, $ignore_perms = false)
377{
378    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::mediause()');
379    return (new dokuwiki\Search\MetadataSearch())->mediause($id, $ignore_perms);
380}
381
382/**
383 * Quicksearch for pagenames
384 *
385 * @param string $id page id
386 * @param bool $in_ns match namespace
387 * @param bool $in_title search in title
388 * @param int|string|null $after
389 * @param int|string|null $before
390 * @return string[]
391 *
392 * @deprecated 2026-04-07 use dokuwiki\Search\MetadataSearch::pageLookup() instead
393 */
394function ft_pageLookup($id, $in_ns = false, $in_title = false, $after = null, $before = null)
395{
396    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\MetadataSearch::class . '::pageLookup()');
397    return (new dokuwiki\Search\MetadataSearch())->pageLookup($id, $in_ns, $in_title, $after, $before);
398}
399
400/**
401 * Creates a snippet extract
402 *
403 * @param string $id page id
404 * @param array $highlight words to highlight
405 * @return string
406 *
407 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::snippet() instead
408 */
409function ft_snippet($id, $highlight)
410{
411    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::snippet()');
412    return (new dokuwiki\Search\FulltextSearch())->snippet($id, $highlight);
413}
414
415/**
416 * Sort pages based on their namespace level first, then alphabetically
417 *
418 * @param string $a
419 * @param string $b
420 * @return int
421 *
422 * @deprecated 2026-04-07 use Utf8\Sort functions directly
423 */
424function ft_pagesorter($a, $b)
425{
426    DebugHelper::dbgDeprecatedFunction('Utf8\\Sort');
427    $diff = substr_count($a, ':') - substr_count($b, ':');
428    return $diff ?: dokuwiki\Utf8\Sort::strcmp($a, $b);
429}
430
431/**
432 * Wrap a search term in regex boundary checks
433 *
434 * @param string $term
435 * @return string
436 *
437 * @deprecated 2026-04-07 use dokuwiki\Search\FulltextSearch::snippetRePreprocess() instead
438 */
439function ft_snippet_re_preprocess($term)
440{
441    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\FulltextSearch::class . '::snippetRePreprocess()');
442    return (new dokuwiki\Search\FulltextSearch())->snippetRePreprocess($term);
443}
444
445/**
446 * Parse a search query into its components
447 *
448 * @param mixed $Indexer ignored (legacy parameter)
449 * @param string $query search query
450 * @return array parsed query structure
451 *
452 * @deprecated 2026-04-07 use dokuwiki\Search\Query\QueryParser::convert() instead
453 */
454function ft_queryParser($Indexer, $query)
455{
456    DebugHelper::dbgDeprecatedFunction(dokuwiki\Search\Query\QueryParser::class . '::convert()');
457    return (new dokuwiki\Search\Query\QueryParser())->convert($query);
458}
459
460/**
461 * @deprecated 2026-04-16 use \dokuwiki\Parsing\ParserMode\Media::parseMedia() instead
462 */
463function Doku_Handler_Parse_Media($match)
464{
465    DebugHelper::dbgDeprecatedFunction(\dokuwiki\Parsing\ParserMode\Media::class . '::parseMedia()');
466    return \dokuwiki\Parsing\ParserMode\Media::parseMedia($match);
467}
468
469/**
470 * @deprecated 2026-05-06 use \dokuwiki\MailUtils::PREG_PATTERN_VALID_EMAIL instead!
471 */
472if (!defined('PREG_PATTERN_VALID_EMAIL')) define('PREG_PATTERN_VALID_EMAIL', MailUtils::PREG_PATTERN_VALID_EMAIL);
473
474/**
475 * @deprecated 2026-05-06 use \dokuwiki\MailUtils::obfuscate() instead!
476 */
477function obfuscate($email)
478{
479    DebugHelper::dbgDeprecatedFunction(MailUtils::class . '::obfuscate');
480    return MailUtils::obfuscate($email);
481}
482
483/**
484 * @deprecated 2026-05-06 use \dokuwiki\MailUtils::isValid() instead!
485 */
486function mail_isvalid($email)
487{
488    DebugHelper::dbgDeprecatedFunction(MailUtils::class . '::isValid');
489    return MailUtils::isValid($email);
490}
491
492/**
493 * @deprecated 2026-05-06 use \dokuwiki\MailUtils::quotedPrintableEncode() instead!
494 */
495function mail_quotedprintable_encode($sText, $maxlen = 74, $bEmulate_imap_8bit = true)
496{
497    DebugHelper::dbgDeprecatedFunction(MailUtils::class . '::quotedPrintableEncode');
498    return MailUtils::quotedPrintableEncode($sText, $maxlen, $bEmulate_imap_8bit);
499}
500