Skip to content

Uncaught Error: [] operator not supported for strings #53

Description

@tmo26

I'm writing this down just in case someone is still using the pagequery plugin in combination with php 7.1+ and stumbles over the same issue.

The following issue is found in in the nginx error log, after accessing a page that has a pagequery in it with sorting by date (other pagequeries are not affected):

2021/10/27 14:42:12 [error] 806#806: *1158977 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: [] operator not supported for strings in /var/www/dokuwiki/lib/plugins/pagequery/inc/pagequery.php:787
Stack trace:
#0 /var/www/dokuwiki/lib/plugins/pagequery/inc/pagequery.php(609): PageQuery->_date_format()
#1 /var/www/dokuwiki/lib/plugins/pagequery/syntax.php(288): PageQuery->build_sorting_array()
#2 /var/www/dokuwiki/inc/parser/renderer.php(117): syntax_plugin_pagequery->render()
#3 /var/www/dokuwiki/inc/parserutils.php(673): Doku_Renderer->plugin()
#4 /var/www/dokuwiki/inc/parserutils.php(142): p_render()
#5 /var/www/dokuwiki/inc/parserutils.php(89): p_cached_output()
#6 /var/www/dokuwiki/inc/html.php(305): p_wiki_xhtml()
#7 /var/www/dokuwiki/inc/Action/Show.php(33): html_show()
#8 /var/www/dokuwiki/inc/template.php(99): dokuwiki\Action\Show->tplContent()
#9 [internal function]: tpl_content_core()
#10 /var/www/dokuwiki/inc/Extension/Event.php(129): call_user_func_array()
#11 /var/www/dokuwiki/inc/Extension/Event.php(195): dokuwiki\Extension\Event" while reading upstream, client: 66.249.76.229, server: openwrt.org, request: "GET /wiki/stats/created_pages HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.4-fpm.sock:", host: "openwrt.org"

Root cause: PHP syntax has changed from 7.1+ onwards and now complains about declarations like $dkey = '';

Solution: change $dkey = ''; to $dkey = array(); -> error is gone

For more information on the background, just search the net for Uncaught Error: [] operator not supported for strings, and youo will get plenty results.

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