DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:releases:refactor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devel:releases:refactor [2020-09-13 17:03] – [Changelog] Klap-indevel:releases:refactor [2020-09-14 21:51] (current) – pointer to refactor2020 Klap-in
Line 1: Line 1:
-====== Refactoring 2020====== +Please see [[refactor2020]]
- +
-For the release of 2020 big parts of DokuWiki are refactored. +
-^WORK IN PROGRESS PLEASE SHARE ALL REMARKS AND QUESTIONS.\\ Thank you very much! [[user>klap-in]]^ +
- +
-===== How to find deprecated code ===== +
-A lot of code has been marked as deprecated. Which means it will be removed in future releases of DokuWiki. While this does (normally) not cause plugins to malfunction now, it may lead to nasty surprises after future updates. +
- +
-Plugin/template authors can easily check if they use any deprecated functions, classes or methods: +
- +
-  * enable the [[config:allowdebug]] setting in the Configuration Manager +
-  * use the plugin +
-  * check ''data/cache/debug.log'' for any information about deprecated calls caused by the plugin. +
- +
-===== Deprecated and changed code ===== +
-Below, you find lists with renamed, changed and moved parts of DokuWiki. Some examples are provided for easier update of plugins and templates. References to codesearch.dokuwiki.org can help locate it usage. +
- +
-==== JSON class is deprecated ==== +
- +
-Code changes: [[github>d443762bafe99b9292cee141f99fbe818e8d2f16|d443762baf]] and [[pr>2686]] +
- +
-Search usage: [[codesearch>"inc\/JSON.php"]], [[codesearch>"json->encode"]] and [[codesearch>"json->decode"]] +
- +
-<code diff> +
-// Remove always the require, since years already autoloaded  +
-// and file is now removed as well +
-- require_once DOKU_INC . 'inc/JSON.php'; +
- +
-- $json = new JSON; +
-- $str = $json->encode($data); +
-- $data = $json->decode($str); +
-+ $str = json_encode($data); +
-+ $data = json_decode($str); +
-     +
- +
-- $json = new JSON(JSON_LOOSE_TYPE); +
-- $str = $json->encode($data); +
-- $data = $json->decode($str); +
-+ $str = json_encode($data, true); +
-+ $data = json_decode($str, true); +
-</code> +
- +
-==== Handlers callwriters, modes and lexer are renamed ==== +
-e.g. ''Doku_Handler_List'' is replaced by ''dokuwiki\Parsing\Handler\Lists''. Needed code update: +
-<code diff> +
-//import at begin of the file: +
-+ use dokuwiki\Parsing\Handler\Lists; +
- +
-//at place of usage: +
-- class Doku_Handler_Creole_List extends Doku_Handler_List { +
-+ class Doku_Handler_Creole_List extends Lists { +
-</code> +
- +
-**Tip**: when using a IDE, like [[deveL:Intellij idea]], it will suggest a lot of the imports if you use the class names. +
- +
- +
- +
-The following classes are renamed: +
-^Old ^New ^ +
-| [[codesearch>Doku_Handler_CallWriter_Interface]] [[codesearch>Doku_Handler_CallWriter]] | dokuwiki\Parsing\Handler\CallWriterInterface dokuwiki\Parsing\Handler\CallWriter| +
-|new \\ new \\ [[codesearch>Doku_Handler_Block]]\\ [[codesearch>Doku_Handler_List]]\\ [[codesearch>Doku_Handler_Nest]] [[codesearch>Doku_Handler_Preformatted]] [[codesearch>Doku_Handler_Quote]] [[codesearch>Doku_Handler_Table]]|dokuwiki\Parsing\Handler\ReWriterInterface dokuwiki\Parsing\Handler\AbstractRewriter dokuwiki\Parsing\Handler\Block dokuwiki\Parsing\Handler\Lists dokuwiki\Parsing\Handler\Nest dokuwiki\Parsing\Handler\Preformatted dokuwiki\Parsing\Handler\Quote dokuwiki\Parsing\Handler\Table| +
-|[[codesearch>Doku_Parser]]|dokuwiki\Parsing\Parser| +
-|[[codesearch>Doku_Lexer]]\\ [[codesearch>Doku_LexerParallelRegex]] [[codesearch>Doku_LexerStateStack]]|dokuwiki\Parsing\Lexer\Lexer dokuwiki\Parsing\Lexer\ParallelRegex dokuwiki\Parsing\Lexer\StateStack| +
-|[[codesearch>Doku_Parser_Mode_Interface]] [[codesearch>Doku_Parser_Mode]] [[codesearch>Doku_Parser_Mode_acronym]] [[codesearch>Doku_Parser_Mode_base]] [[codesearch>Doku_Parser_Mode_camelcaselink]] [[codesearch>Doku_Parser_Mode_code]] [[codesearch>Doku_Parser_Mode_emaillink]] [[codesearch>Doku_Parser_Mode_entity]] [[codesearch>Doku_Parser_Mode_eol]] [[codesearch>Doku_Parser_Mode_externallink]] [[codesearch>Doku_Parser_Mode_file]] [[codesearch>Doku_Parser_Mode_filelink]] [[codesearch>Doku_Parser_Mode_footnote]] [[codesearch>Doku_Parser_Mode_formatting]] [[codesearch>Doku_Parser_Mode_header]] [[codesearch>Doku_Parser_Mode_hr]] [[codesearch>Doku_Parser_Mode_html]] [[codesearch>Doku_Parser_Mode_internallink]] [[codesearch>Doku_Parser_Mode_linebreak]] [[codesearch>Doku_Parser_Mode_listblock]] [[codesearch>Doku_Parser_Mode_media]] [[codesearch>Doku_Parser_Mode_multiplyentity]] [[codesearch>Doku_Parser_Mode_nocache]] [[codesearch>Doku_Parser_Mode_notoc]] [[codesearch>Doku_Parser_Mode_php]] [[codesearch>Doku_Parser_Mode_Plugin]] [[codesearch>Doku_Parser_Mode_preformatted]] [[codesearch>Doku_Parser_Mode_quote]] [[codesearch>Doku_Parser_Mode_quotes]] [[codesearch>Doku_Parser_Mode_rss]] [[codesearch>Doku_Parser_Mode_smiley]] [[codesearch>Doku_Parser_Mode_table]] [[codesearch>Doku_Parser_Mode_unformatted]] [[codesearch>Doku_Parser_Mode_windowssharelink]] [[codesearch>Doku_Parser_Mode_wordblock]]|dokuwiki\Parsing\ParserMode\ModeInterface dokuwiki\Parsing\ParserMode\AbstractMode dokuwiki\Parsing\ParserMode\Acronym dokuwiki\Parsing\ParserMode\Base dokuwiki\Parsing\ParserMode\Camelcaselink dokuwiki\Parsing\ParserMode\Code dokuwiki\Parsing\ParserMode\Emaillink dokuwiki\Parsing\ParserMode\Entity dokuwiki\Parsing\ParserMode\Eol dokuwiki\Parsing\ParserMode\Externallink dokuwiki\Parsing\ParserMode\File dokuwiki\Parsing\ParserMode\Filelink dokuwiki\Parsing\ParserMode\Footnote dokuwiki\Parsing\ParserMode\Formatting dokuwiki\Parsing\ParserMode\Header dokuwiki\Parsing\ParserMode\Hr dokuwiki\Parsing\ParserMode\Html dokuwiki\Parsing\ParserMode\Internallink dokuwiki\Parsing\ParserMode\Linebreak dokuwiki\Parsing\ParserMode\Listblock dokuwiki\Parsing\ParserMode\Media dokuwiki\Parsing\ParserMode\Multiplyentity dokuwiki\Parsing\ParserMode\Nocache dokuwiki\Parsing\ParserMode\Notoc dokuwiki\Parsing\ParserMode\Php dokuwiki\Parsing\ParserMode\Plugin dokuwiki\Parsing\ParserMode\Preformatted dokuwiki\Parsing\ParserMode\Quote dokuwiki\Parsing\ParserMode\Quotes dokuwiki\Parsing\ParserMode\Rss dokuwiki\Parsing\ParserMode\Smiley dokuwiki\Parsing\ParserMode\Table dokuwiki\Parsing\ParserMode\Unformatted dokuwiki\Parsing\ParserMode\Windowssharelink dokuwiki\Parsing\ParserMode\Wordblock| +
- +
-==== Changes of the internals of the handler ==== +
-Variables are not available anymore: +
-  * ''%%$handler->status[]%%'' +
-  * ''%%$handler->CallWriter%%'' +
-Functions renamed: +
-  * ''%%$handler->_addCall()%%'' +
-  * ''%%$handler->_finalize()%%'' +
- +
-Search usage: [[codesearch>status]], [[codesearch>CallWriter]] and [[codesearch>_addCall]], [[codesearch>_finalize]] +
- +
-Replacements: +
-<code diff> +
-- $status = $handler->status['section'+
-+ $status = $handler->getStatus('section'+
- +
-- $handler->status['section'] = true +
-+ $handler->setStatus('section', true) +
-</code> +
- +
-<code diff> +
-case DOKU_LEXER_ENTER: +
--   $ReWriter = new Doku_Handler_Creole_List($handler->CallWriter); +
--   $handler->CallWriter = & $ReWriter; +
-+   $ReWriter = new Doku_Handler_Creole_List($handler->getCallWriter()); +
-+   $handler->setCallWriter($ReWriter); +
- +
-case DOKU_LEXER_EXIT: +
--   $handler->CallWriter->process(); +
--   $ReWriter = & $handler->CallWriter; +
--   $handler->CallWriter = & $ReWriter->CallWriter; +
-+   $ReWriter = $handler->getCallWriter(); +
-+   $handler->setCallWriter($ReWriter->process()); +
-</code> +
- +
-<code diff> +
-- $handler->_addCall('list_close', array(), $pos); +
-+ $handler->addCall('list_close', array(), $pos); +
-</code> +
- +
-Note: some general ''addCall()'' can be replaced by the specific functions like ''header()'', ''eof()'', ''hr()'', ''strong()'', ''emphasis()'', ''underline()'', etc etc. Could be worth a check, however there should be typical a reason that these specific functions were not used. +
- +
-==== Changes of the internals of the parser ==== +
-Renamed variables: ''Handler'' and ''Lexer'' to ''handler'' and ''lexer''. (maybe no difference in practice due to case-insensitivity) +
- +
-Changed visibility, these variables are now protected: ''handler'', ''lexer'', ''modes'', ''connected''. The ''handler'' can be set via the constructor. There are no setters or getters for the others. +
- +
-<code diff> +
-- $parser = new Doku_Parser(); +
-- $parser->Handler = $handler; +
-+ $parser = new Parser($handler); +
-</code> +
- +
- +
-==== Changes of the internals of the Lexer ==== +
-Variables and functions are not available anymore: +
-  * ''%%$lexer->_mode%%'' +
-  * function ''%%Doku_Lexer_Escape($str)%%'' +
- +
-Search usage: [[codesearch>_mode]], [[codesearch>Doku_Lexer_Escape]] and [[codesearch>_dispatchTokens]] +
- +
-<code diff> +
-- $lexer->_mode->getCurrent(); +
-+ $lexer->getModeStack()->getCurrent(); +
-</code> +
- +
-<code diff> +
-- $str = Doku_Lexer_Escape($str); +
-+ $str = \dokuwiki\Parsing\Lexer\Lexer::escape($str); +
-</code> +
- +
-Other renamed protected functions of Lexer: ''_dispatchTokens()'', ''_isModeEnd()'', ''_isSpecialMode()'', ''_decodeSpecial()'', ''_invokeParser()'' and ''_reduce()''+
- +
- +
- +
-Renamed protected functions of ParallelRegex: ''_getCompoundedRegex()'', ''_getPerlMatchingFlags()''+
- +
- +
-==== UTF-8 functions ==== +
-All UTF-8 functions are moved and renamed. Refactored mostly in [[pr>2780]]. +
- +
-^Old ^New ^ +
-|inline code|\dokuwiki\Utf8\Asian::isAsianWords()\\ \dokuwiki\Utf8\Asian::separateAsianWords()\\ \dokuwiki\Utf8\Asian::splitAsianWords()| +
-|[[codesearch>IDX_ASIAN]]|\dokuwiki\Utf8\Asian::REGEXP| +
-|[[codesearch>utf8_isASCII]]\\ [[codesearch>utf8_check]]\\ [[codesearch>utf8_strip]]\\ [[codesearch>utf8_stripspecials]]\\ [[codesearch>utf8_bad_replace]]\\ [[codesearch>utf8_deaccent]]\\ [[codesearch>utf8_romanize]]\\ [[codesearch>utf8_correctIdx]]|\dokuwiki\Utf8\Clean::isASCII()\\ \dokuwiki\Utf8\Clean::isUtf8()\\ \dokuwiki\Utf8\Clean::strip()\\ \dokuwiki\Utf8\Clean::stripspecials()\\ \dokuwiki\Utf8\Clean::replaceBadBytes()\\ \dokuwiki\Utf8\Clean::deaccent()\\ \dokuwiki\Utf8\Clean::romanize()\\ \dokuwiki\Utf8\Clean::correctIdx()| +
-|[[codesearch>utf8_tohtml]]\\ [[codesearch>utf8_unhtml]]\\ [[codesearch>utf8_to_utf16be]]\\ [[codesearch>utf16be_to_utf8]]|\dokuwiki\Utf8\Conversion::toHtml()\\ \dokuwiki\Utf8\Conversion::fromHtml()\\ \dokuwiki\Utf8\Conversion::toUtf16be()\\ \dokuwiki\Utf8\Conversion::fromUtf16be()| +
-|[[codesearch>utf8_basename]]\\ [[codesearch>utf8_strlen]]\\ [[codesearch>utf8_substr]]\\ [[codesearch>utf8_substr_replace]]\\ [[codesearch>utf8_ltrim]]\\ [[codesearch>utf8_rtrim]]\\ [[codesearch>utf8_trim]]\\ [[codesearch>utf8_strtolower]]\\ [[codesearch>utf8_strtoupper]]\\ [[codesearch>utf8_ucfirst]]\\ [[codesearch>utf8_ucwords]]\\ [[codesearch>utf8_strpos]]|\dokuwiki\Utf8\PhpString::basename()\\ \dokuwiki\Utf8\PhpString::strlen()\\ \dokuwiki\Utf8\PhpString::substr()\\ \dokuwiki\Utf8\PhpString::substr_replace()\\ \dokuwiki\Utf8\PhpString::ltrim()\\ \dokuwiki\Utf8\PhpString::rtrim()\\ \dokuwiki\Utf8\PhpString::trim()\\ \dokuwiki\Utf8\PhpString::strtolower()\\ \dokuwiki\Utf8\PhpString::strtoupper()\\ \dokuwiki\Utf8\PhpString::ucfirst()\\ \dokuwiki\Utf8\PhpString::ucwords()\\ \dokuwiki\Utf8\PhpString::strpos()| +
-|[[codesearch>utf8_to_unicode]]\\ [[codesearch>unicode_to_utf8]]|\dokuwiki\Utf8\Unicode::fromUtf8()\\ \dokuwiki\Utf8\Unicode::toUtf8()| +
-|globals\\ [[codesearch>UTF8_UPPER_TO_LOWER]]\\ [[codesearch>UTF8_LOWER_TO_UPPER]]\\ [[codesearch>UTF8_LOWER_ACCENTS]]\\ [[codesearch>UTF8_UPPER_ACCENTS]]\\ [[codesearch>UTF8_ROMANIZATION]]\\ [[codesearch>UTF8_SPECIAL_CHARS]]\\ [[codesearch>UTF8_SPECIAL_CHARS2]] |\\ \dokuwiki\Utf8\Table::upperCaseToLowerCase()\\ \dokuwiki\Utf8\Table::lowerCaseToUpperCase()\\ \dokuwiki\Utf8\Table::lowerAccents()\\ \dokuwiki\Utf8\Table::upperAccents()\\ \dokuwiki\Utf8\Table::romanization()\\ \dokuwiki\Utf8\Table::specialChars()\\ **TO CHECK**: combined? or deprecated/removed??+
- +
-Class for handling UTF-8 in filenames. Renamed functions: +
-|SafeFN::[[codesearch>validate_printable_utf8]]\\ SafeFN::[[codesearch>validate_safe]]| SafeFN::validatePrintableUtf8()\\ SafeFN::validateSafe()|| +
- +
- +
-==== Cache ==== +
-|[[codesearch>cache]]\\ [[codesearch>cache_parser]]\\ [[codesearch>cache_renderer]]\\ [[codesearch> cache_instructions]]|dokuwiki\Cache\Cache\\ dokuwiki\Cache\CacheParser\\ dokuwiki\Cache\CacheRenderer\\ dokuwiki\Cache\CacheInstructions| +
- +
-Changed visibility, these variables are now protected and have new setters/getters: +
-|[[codesearch>_event]]| setEvent($event)\\ getEvent() | +
-|[[codesearch>_time]]|getTime()| +
-|[[codesearch>_nocache]]|isNoCache()| +
- +
-FIXME? CHECK: NO SETTER FOR nocache, while used in plugins +
- +
-<code diff> +
-- $time = $cache->_time  +
-+ $time = $cache->getTime()) +
- +
-- $cache = new cache_renderer($ID, $file, 'xhtml'); +
-- $useCache = $cache->_nocache +
-+ $cache = new CacheRenderer($ID, $file, 'xhtml'); +
-+ $useCache = $cache->isNoCache() +
- +
-- $cache->_event = $event +
-+ $cache->setEvent($event) +
-- $event = $cache->_event  +
-+ $event = $cache->getEvent() +
-</code> +
-==== Changelog ==== +
-Renamed and moved classes: +
-| [[codesearch>Changelog]]\\ [[codesearch>MediaChangelog]]\\ [[codesearch>PageChangelog]]|dokuwiki\ChangeLog\Changelog\\ dokuwiki\ChangeLog\MediaChangeLog\\ dokuwiki\ChangeLog\PageChangeLog| +
-==== Sitemap ==== +
- +
-==== Subscription ==== +
- +
-==== Remote API ==== +
- +
-==== HTTP Client ==== +
- +
-==== Input ==== +
- +
-==== Other ==== +
- +
-==== Settings ==== +
- +
-===== Deprecated 2016 ===== +
- +
-signatures in action.php  +
- +
-- function alwaysHide(Doku_Event &$event, $params) { +
-+ function alwaysHide(Doku_Event $event, $params) { +
- +
- +
-and syntax.php +
- +
-===== General cleanup suggestions ===== +
- +
-Lot of plugins uses the following older code. Today these are already included via the core or not needed anymore. +
- +
-The following code is only needed if a file has main code that is executed. Otherwise it can be left out. +
-<code diff> +
-- if(!defined('DOKU_INC')) die('meh.'); +
-</code> +
- +
-Code beautification. The defines are already in core, so can be deleted. Further these code beautifications are not needed anymore with current tools. +
-<code diff> +
-- // Some whitespace to help View > Source +
-- if(!defined('DOKU_LF')) define ('DOKU_LF', "\n"); +
- +
-- // Some whitespace to help View > Source +
-- if(!defined('DOKU_TAB')) define ('DOKU_TAB', "\t"); +
- +
-- if(!defined('NL')) define('NL',"\n"); +
-</code> +
- +
-This directory is set in the core, not needed per plugin. +
-<code diff> +
-- if(!defined('DOKU_PLUGIN')) { +
--     define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); +
-- } +
-</code> +
- +
-Scripts includes such as ''require'' and ''require_one'' are not needed for all the DokuWiki files or the typical plugin files. DokuWiki has an autoloader. More and more parts of the core use namespaces. Please use them, see [[devel:autoloader]] how these are related to your files. +
- +
-<code diff> +
-- require_once(DOKU_PLUGIN.'syntax.php'); +
-- require_once(DOKU_PLUGIN.'action.php'); +
-- require_once(DOKU_PLUGIN.'admin.php'); +
-- etc +
- +
-- require_once DOKU_INC . 'inc/parser/lexer.php'; +
-- require_once DOKU_INC . 'inc/parser/handler.php'; +
-</code>+
devel/releases/refactor.1600009388.txt.gz · Last modified: 2020-09-13 17:03 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki