DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:releases:refactor2022

developer changelog

Refactoring 2022

This page lists changes from August 2022 to April 2023 as included in the “Jack Jackrum” release. For older changes see refactor2021 and refactor2020, for newer refactor2023.

Welcome to add more notes/examples/etc on this page, to make updating of plugins and templates easy! Please share all remarks and possible improvements. See forum topic. Thank you very much! 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:

Since the Igor 2022 release:

  • logging of deprecated messages is default enabled, otherwise you need to uncheck deprecated in the dontlog configuration setting
  • use the plugin
  • check LogViewer (or data/log/deprecated/<date>.log).

Up to the Hogfather 2020 release:

  • enable the allowdebug setting in the Configuration Manager
  • use the plugin
  • Check logs for any information about deprecated calls caused by the plugin in data/cache/debug.log .

sexplode() instead of explode() to list

3754 introduces a PHP8 safe way to do an explode to an list/array.

- list($foo, $bar) = explode(',', $input, 2);
+ [$foo, $bar] = sexplode(',', $input, 2);
this is a convenient alternative for
+ [$foo, $bar] = array_pad(explode(',', $input, 2), 2, null);

Since PHP 7.1 [.., ..] = .. is supported instead of list(.., ..) = ..

Remove .gif icons

DokuWiki upgrades, using the data/deleted.files file, removes the .gif icons.

The .gif icons need to be replaced by the .svg icons in lib/images/smileys. See also from gif to svg smileys.

Replace phpquery by php-dom-wrapper in tests

3814 replaced phpquery by php-dom-wrapper. Usage is similar but not a 1:1 replacement. In plugin tests small changes will be needed.

- $doc = phpQuery::newDocumentXHTML($html);
+ use DOMWrap\Document
+ $doc = (new Document())->html($html);

Some examples (see further also the docs referred above for the new syntax)

//probably the biggest change
- $paragraphs = pq("p", $doc);
- $divs = pq("div");
+ $paragraphs = $doc->find('p')
+ $divs = $doc->find('div')
 
 
$input = $doc->find('button[name=foo]');
- $this->assertTrue($input->length == 1);
+ $this->assertTrue($input->count() == 1);
 
- $this->assertEquals('bam', $input->val());
+ $this->assertEquals('bam', $input->attr('value'));
 
$inputs = $doc->find('input[name=foo]');
- $this->assertEquals('first', pq($inputs->elements[0])->val());
+ $this->assertEquals('first', $inputs->get(0)->attr('value'));
 
//more?? other examples welcome.

Embedded HTML and PHP removed

The option to embed html or php, and settings to enable them are removed in 3798.

The settings htmlok and phpok are removed.

Removed
dokuwiki\Parsing\ParserMode\Html
dokuwiki\Parsing\ParserMode\Php
from Doku_Handler: php() phpblock() html() htmlblock()
from Doku_Renderer and extended: php() phpblock() html() htmlblock()

Plugins replacing this need to implement other renderers them self.

Input class

Reminder. Note that the Input class can be helpful with retrieving better defined data from request variables $_POST, $_GET, $_REQUEST and $_SERVER.

Example:

- _SERVER['HTTP_HOST']
+ $INPUT->server->str('HTTP_HOST')

EventHandler

Added getEventHandlers() for listing the handlers.

Dependencies

Via composer several dependencies updated:

  • 2afbbba 9aee973 SimplePie is significant refactored and uses now namespaces. Example:
    - class FeedParser extends SimplePie {
    + class FeedParser extends \SimplePie\SimplePie {
  • 3917 Javascript compressor moved to splitbrain/php-jsstrip:
    +$js = (new JSStrip())->compress($js);

3721 Support the multiple attribute in Form selects

dokuwiki\Form\DropdownElement supports now optgroups.

No example available FIXME

Info class

class dokuwiki\Info added, now first with method parseVersionString().

Autoloading

Autoloading of namespaces

  • dokuwiki\test\mock refers classes in _test/mock/
  • dokuwiki\test refers classes in _test/tests/

$footnote in Doku_Handler

Added protected footnote (instead of dynamic declared $_footnote) Not used anymore _footnote

tpl_img_close()

Added tpl_img_close() for helping the garbage collector. To be used when done with tpl_img_getTag().

Example: lib/exe/detail.php

devel/releases/refactor2022.txt · Last modified: 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