leibler / dokuwiki-plugin-todo

DokuWiki ToDo Plugin
39 stars 30 forks source link

strpos() ValueError when listing todos in current namespace #178

Open rgh256 opened 3 days ago

rgh256 commented 3 days ago

I am trying to list all todos in the current namespace (and its children) by using ~~TODOLIST ns:.: ~~.

It has worked well until today when I updated both PHP (7.4->8.3) and the todo plugin. Now I get the following error in logs:

ValueError: strpos(): Argument #3 (offset) must be contained in argument #1 (haystack)/doku_www/XXXX/lib/plugins/todo/syntax/list.php(282)

#0 /doku_www/XXXX/lib/plugins/todo/syntax/list.php(282): strpos()
#1 /doku_www/XXXX/lib/plugins/todo/syntax/list.php(239): syntax_plugin_todo_list->filter_ns()
#2 /doku_www/XXXX/inc/search.php(67): syntax_plugin_todo_list->search_todos()
#3 /doku_www/XXXX/inc/search.php(62): search()
#4 /doku_www/XXXX/inc/search.php(62): search()
#5 /doku_www/XXXX/lib/plugins/todo/syntax/list.php(179): search()
#6 /doku_www/XXXX/inc/parser/renderer.php(119): syntax_plugin_todo_list->render()
#7 /doku_www/XXXX/inc/parserutils.php(700): Doku_Renderer->plugin()
#8 /doku_www/XXXX/inc/parserutils.php(158): p_render()
#9 /doku_www/XXXX/inc/parserutils.php(96): p_cached_output()
#10 /doku_www/XXXX/inc/Ui/PageView.php(68): p_wiki_xhtml()
#11 /doku_www/XXXX/inc/Action/Show.php(37): dokuwiki\Ui\PageView->show()
#12 /doku_www/XXXX/inc/template.php(100): dokuwiki\Action\Show->tplContent()
#13 [internal function]: tpl_content_core()
#14 /doku_www/XXXX/inc/Extension/Event.php(133): call_user_func_array()
#15 /doku_www/XXXX/inc/Extension/Event.php(199): dokuwiki\Extension\Event->trigger()
#16 /doku_www/XXXX/inc/template.php(85): dokuwiki\Extension\Event::createAndTrigger()
#17 /doku_www/XXXX/lib/tpl/sprintdoc/main.php(358): tpl_content()
#18 /doku_www/XXXX/inc/actions.php(27): include('...')
#19 /doku_www/XXXX/doku.php(126): act_dispatch()
#20 {main}
runout-at commented 3 days ago

I'm not sure why we have the offset there at all. I would need some debug output from that function.

$p = strpos($item.':', ':', $len+1);

rgh256 commented 3 days ago

Forgot to mention that nginx is also throwing some errors of its own:

2024/11/15 17:03:45 [error] 170443#170443: *1 FastCGI sent in stderr: " message: PHP Warning:  Undefined variable $condition2 in /doku_www/XXXX/lib/plugins/todo/syntax/list.php on line 419; PHP message: PHP Warning:  Undefined variable $condition2 in /doku_www/XXXX/lib/plugins/todo/syntax/list.php on line 419; PHP message: PHP Warning:  Undefined array key "due" in /doku_www/XXXX/lib/plugins/todo/syntax/list.php on line 449;
[....repeated many times...]

As far as line list.php(282) I added a debug print of $item (sorry, never used php before, so don't know how to debug it):

error_log("****** list.php debug:item = {$item}; len = {$len} ******");
$p = strpos($item.':', ':', $len+1);

In nginx error log (just one example): PHP message: ****** list.php debug:item = business:cdei:cdei_accounting:cdei_banks:XXXXXXX:YYYYYYYY; len = 33 ******;

Important: len is always 33 regardless of the item (namespace). In the example listed above len(item) is 69.

The Dokuwiki error log is shown in the previous message.

Removing third parameter in line 282 (change to $p = strpos($item.':', ':'); solves the strpos error.

The FastCGI errors/warning listed above are not solved (obviously...).

rgh256 commented 3 days ago

Since I mentioned the FastCGI errors/warnings in my previous comment I am adding a nicer version from the dokuwiki logs (for completeness, despite likely being unrelated to the original issue):

2024-11-15 23:39:39 /gdrive/doku_www/remy_business/lib/plugins/todo/syntax/list.php(419)    E_WARNING: Undefined variable $condition2
  #0 /doku_www/XXXX/lib/plugins/todo/syntax/list.php(421): dokuwiki\ErrorHandler::errorHandler()
  #1 /doku_www/XXXX/lib/plugins/todo/syntax/list.php(344): syntax_plugin_todo_list->isRequestedTodo()
  #2 /doku_www/XXXX/lib/plugins/todo/syntax/list.php(181): syntax_plugin_todo_list->filterpages()
  #3 /doku_www/XXXX/inc/parser/renderer.php(126): syntax_plugin_todo_list->render()
  #4 /doku_www/XXXX/inc/parserutils.php(691): Doku_Renderer->plugin()
  #5 /doku_www/XXXX/inc/parserutils.php(158): p_render()
  #6 /doku_www/XXXX/inc/parserutils.php(97): p_cached_output()
  #7 /doku_www/XXXX/inc/Ui/PageView.php(67): p_wiki_xhtml()
  #8 /doku_www/XXXX/inc/Action/Show.php(40): dokuwiki\Ui\PageView->show()
  #9 /doku_www/XXXX/inc/template.php(120): dokuwiki\Action\Show->tplContent()
  #10 [internal function]: tpl_content_core()
  #11 /doku_www/XXXX/inc/Extension/Event.php(134): call_user_func_array()
  #12 /doku_www/XXXX/inc/Extension/Event.php(200): dokuwiki\Extension\Event->trigger()
  #13 /doku_www/XXXX/inc/template.php(102): dokuwiki\Extension\Event::createAndTrigger()
  #14 /doku_www/XXXX/lib/tpl/sprintdoc/main.php(358): tpl_content()
  #15 /doku_www/XXXX/inc/actions.php(30): include('...')
  #16 /doku_www/XXXX/doku.php(131): act_dispatch()
  #17 {main}
runout-at commented 1 day ago

thx.

maybe it would be good to open open a new issue for the other bug. and please quote the lines as you might have inserted lines for debugging and now it's not clear where the error is thrown.