cosmocode / simplenavi

Create a simple navigation tree based on DokuWiki namespaces
http://www.dokuwiki.org/plugin:simplenavi
GNU General Public License v2.0
14 stars 11 forks source link

TypeError: array_key_last(): Argument #1 ($array) must be of type array, null given #37

Open RobinR1 opened 1 year ago

RobinR1 commented 1 year ago

Since recent update of simplenavi, I get this error whenever I try to click on the first entry of the simplenavi menu:

2023-08-30 10:44:28TypeError: array_key_last(): Argument #1 ($array) must be of type array, null given/srv/www/vhosts/dokuwiki/lib/plugins/simplenavi/syntax.php(121)
    #0 /srv/www/vhosts/dokuwiki/lib/plugins/simplenavi/syntax.php(121): array_key_last(NULL)
    #1 /srv/www/vhosts/dokuwiki/lib/plugins/simplenavi/syntax.php(70): syntax_plugin_simplenavi->getSortedItems('systemen', 1, 0, 1, 1)
    #2 /srv/www/vhosts/dokuwiki/inc/parser/renderer.php(119): syntax_plugin_simplenavi->render('xhtml', Object(Doku_Renderer_xhtml), Array)
    #3 /srv/www/vhosts/dokuwiki/inc/parserutils.php(700): Doku_Renderer->plugin('simplenavi', Array, 5, '{{simplenavi>sy...')
    #4 /srv/www/vhosts/dokuwiki/inc/parserutils.php(158): p_render('xhtml', Array, NULL)
    #5 /srv/www/vhosts/dokuwiki/inc/parserutils.php(96): p_cached_output('/srv/www/vhosts...', 'xhtml', 'systemen:sideba...')
    #6 /srv/www/vhosts/dokuwiki/inc/template.php(1592): p_wiki_xhtml('systemen:sideba...', '', false)
    #7 /srv/www/vhosts/dokuwiki/lib/tpl/bootstrap3/tpl/sidebar.php(33): tpl_include_page('systemen:sideba...', 0, 1, 0)
    #8 /srv/www/vhosts/dokuwiki/lib/tpl/bootstrap3/Template.php(1383): require('/srv/www/vhosts...')
    #9 /srv/www/vhosts/dokuwiki/lib/tpl/bootstrap3/Template.php(1346): dokuwiki\template\bootstrap3\Template->sidebarWrapper('sidebar', 'dokuwiki__aside', 'col-sm-3 col-md...', 'sidebarheader', 'sidebarfooter')
    #10 /srv/www/vhosts/dokuwiki/lib/tpl/bootstrap3/main.php(93): dokuwiki\template\bootstrap3\Template->includeSidebar('left')
    #11 /srv/www/vhosts/dokuwiki/inc/actions.php(27): include('/srv/www/vhosts...')
    #12 /srv/www/vhosts/dokuwiki/doku.php(126): act_dispatch()
    #13 {main}
annda commented 1 year ago

Duplicate of #35 and #36

RobinR1 commented 1 year ago

@annda How is this a duplicate of #35 ? This server is running PHP 8 and the function array_key_last exists but somehow it is passed 'null' as parameter instead of the required array ?

RobinR1 commented 12 months ago

This seems to be caused by the fact that the namespace which triggers this bug contains both a start.txt and a start directory with content and is the very first namespace in the simplenavi list.

I'm not sure how that happened in the past; probably a user error, but it worked in previous simplenavi versions: the content under the start directory was shown as children of the parent namespace.

As a workaround I have moved the content of the start directory to the root of the parent namespace, removing the start directory, only leaving a start.txt and the content of the now removed start directory.

When another namespace, other than the first listed, contains a start.txt and a start directory with content, then we won't get the above mentioned error but that namespace then suddenly visually becomes a child of a different, unrelated namespace when it is clicked on and expanded in the tree. Visually: parent namespace testspace image When clicked on: it opens, but jumps under the unrelated namespace exchange_online and has extra folder icons shown: image

So on the alphabetically first namespace it seems to be trying to sort it under another namespace upon clicking on it, but it fails to find a previous namespace to sort it under as it itself is the first namespace. Hence the error I reported in this bug.