dokufreaks/plugin-blog

sortkey configuration doesn't work; entries are always sorted by creation date

Opened this issue · 2 comments

sortkey configuration doesn't work; entries are always sorted by creation date.

sortkey available options:

  • creation date
  • modification date
  • page name
  • page ID
  • page tiltle

versions

Blog Plugin 2023-01-12
dokuwiki 2023-04-04 "Jack Jackrum"
PHP 8.1.2-1ubuntu2.11

I checked blog plugin's helper.php and noticed helper_plugin_blog class's constructor is not called, so $this->sort valiable is empty.

helper.cpp

class helper_plugin_blog extends DokuWiki_Plugin {
    var $sort       = '';      // sort key
    function helper_plugin_blog() {
        // load sort key from settings
        $this->sort = $this->getConf('sortkey');
    }

By chagning the constructor as follows, sort valiable is set and entries are sorted expectedly with sortkey configuration.

class helper_plugin_blog extends DokuWiki_Plugin {
    var $sort       = '';      // sort key
    function __construct() {
        // load sort key from settings
        $this->sort = $this->getConf('sortkey');
    }
fiwswe commented

This is caused by a change in PHP 8.0.0. See: Other incompatible Changes

But to stay backward compatible for users still running PHP <8.0.0 and to avoid code duplication maybe just implement __construct like this:

function __construct() {
        $this->helper_plugin_blog();
    }
    …