Skip to content

TypeError thrown by sidebar TOC when accessing deleted page #14

@pyuxiang

Description

@pyuxiang

When accessing a deleted page, i.e. by removing page contents, the following error message is thrown by PHP:

TypeError: Cannot access offset of type string on string

An unforeseen error has occured. This is most likely a bug somewhere. It might be a problem in the toctweak plugin.

More info has been written to the DokuWiki error log.
Dump of Dokuwiki error log
2022-12-26 11:51:31     /var/www/dokuwiki/lib/plugins/toctweak/helper.php(96)   TypeError: Cannot access offset of type string on string
  #0 /var/www/dokuwiki/lib/plugins/toctweak/syntax/sidetoc.php(73): helper_plugin_toctweak->get_metatoc()
  #1 /var/www/dokuwiki/inc/parser/renderer.php(117): syntax_plugin_toctweak_sidetoc->render()
  #2 /var/www/dokuwiki/inc/parserutils.php(682): Doku_Renderer->plugin()
  #3 /var/www/dokuwiki/inc/parserutils.php(149): p_render()
  #4 /var/www/dokuwiki/inc/parserutils.php(89): p_cached_output()
  #5 /var/www/dokuwiki/inc/template.php(1585): p_wiki_xhtml()
  #6 /var/www/dokuwiki/lib/tpl/dokuwiki/main.php(43): tpl_include_page()
  #7 /var/www/dokuwiki/inc/actions.php(27): include('...')
  #8 /var/www/dokuwiki/doku.php(126): act_dispatch()
  #9 {main}

Cause seems to be due to $INFO['meta'] array being unpopulated for such deleted pages,

array(9) { ["date"]=> string(0) "" ["creator"]=> string(0) "" ["user"]=> string(0) "" ["last_change"]=> string(0) "" ["contributor"]=> string(0) "" ["title"]=> string(0) "" ["description"]=> string(0) "" ["relation"]=> string(0) "" ["internal"]=> string(0) "" }


This issue does not manifest when the page itself has not been previously created, nor did it appear in Dokuwiki Hogfather running PHP 7.4 (Ubuntu 20.04).

Environment:

  • Plugin version 2.0.2 (2018-01-08)
  • Dokuwiki version 2022-07-31 "Igor"
  • PHP 8.1 (Ubuntu 22.04)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions