It's better when it's simple

User Tools

Site Tools


developer changelog

Refactoring 2022

Update of this page is in Progress

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);
+ $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.
devel/releases/refactor2022.txt · Last modified: 2023-10-22 00:10 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