DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:releases:refactor2023

developer changelog

Refactoring 2023

develonly

Update of this page is in Progress

This page lists changes since April 2023. For older changes see refactor2022, refactor2021 and refactor2020.

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).

Since [upcoming] release:

  • Setup GitHub Action (or setup Rector locally), to get code improvement suggestions. Plugin authors who want to use the new workflow can easily add it using the dev plugin: Remove old workflow and add the new one

ptln()

ptln() is deprecated in 4045.

- ptln('your message', 4);
+ echo 'your message';

str_start_with/str_ends_with/str_contains()

Polyfills are added in 4045, so these PHP8 functions can already be used.

- if (substr($url, 0, 3) == 'ftp');
+ if (str_starts_with($url, 'ftp'));
 
- if (substr($target, -1, 1) === ':') {
+ if (str_ends_with($target, ':')) {
 
- ...;
+ str_contains();

Refactor fulltext search functions and class Doku_Indexer

General improvement suggestions

Check for plugin interface/class instead of not null

- if ($auth) {
-     $info = $auth->getUserData($username);
- }
+ if ($auth instanceof AuthPlugin) {
+     $info = $auth->getUserData($username);
+ }
 
- if (!$auth) return false;
+ if (!$auth instanceof AuthPlugin) return false;
- $plugin = plugin_load('remote', 'example');
- if (!$plugin) {
-     return;
- }
+ $plugin = plugin_load('remote', 'example');
+ if (!$plugin instanceof PluginInterface) {
+     return;
+ }
 
- if (!$plugin = plugin_load('syntax', 'example)) return false;
+ if (!($plugin = plugin_load('syntax', 'example)) instanceof PluginInterface) return false;

As you use typically specific functionality, you can also update PluginInterface to the specific class of the component.

devel/releases/refactor2023.txt · Last modified: 2023-10-25 21:39 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