dokuwiki icon indicating copy to clipboard operation
dokuwiki copied to clipboard

Search is not completing with an 'AND' operation (Invalid argument supplied for foreach(): fulltext.php:577)

Open gerardnico opened this issue 3 years ago • 4 comments

Hallo,

On Igor, I got the following problem

Invalid argument supplied for foreach()
 D:\dokuwiki\inc\fulltext.php:577

The problem comes from the AND operation specifically on this line fulltext.php#L127.

list($pages1, $pages2) = array_splice($stack, -2);

because the stack is empty, the variables are null and the code try to loop over pages1 (ie null).

I have no experience on the fulltext code, I don't see an easy fix.

The test code is the following:

$andQuery = "and query for sure";

$request = new TestRequest();
$response = $request->get(array(
    "do" => "search",
    "q" => $andQuery
));

Stack Trace:

Invalid argument supplied for foreach()
 D:\dokuwiki\inc\fulltext.php:577
 D:\dokuwiki\inc\fulltext.php:128
 D:\dokuwiki\inc\Extension\Event.php:133
 D:\dokuwiki\inc\Extension\Event.php:199
 D:\dokuwiki\inc\fulltext.php:45
 D:\dokuwiki\inc\Action\Search.php:70
 D:\dokuwiki\inc\Action\Search.php:54
 D:\dokuwiki\inc\template.php:100
 D:\dokuwiki\inc\Extension\Event.php:133
 D:\dokuwiki\inc\Extension\Event.php:199
 D:\dokuwiki\inc\template.php:85
 D:\dokuwiki\lib\tpl\dokuwiki\main.php:59
 D:\dokuwiki\inc\actions.php:27
 D:\dokuwiki\doku.php:126
 D:\dokuwiki\_test\core\TestRequest.php:159
 D:\dokuwiki\_test\core\TestRequest.php:242
action_plugin_combo_routermessageTest.php:87

gerardnico avatar Aug 27 '22 08:08 gerardnico

does the problem only occur when your query starts with AND or is it a more general problem?

splitbrain avatar Aug 27 '22 16:08 splitbrain

I have the same problem. I followed the instructions here to rebuild the search index, but it didn't help me with this problem 😞.

rrakso avatar Mar 21 '23 16:03 rrakso

I seem not to be able to reproduce this in current master. @gerardnico can you still reproduce the problem or has it been fixed?

splitbrain avatar Mar 21 '23 18:03 splitbrain

Sorry for the late answer, I'm not acquainted with the mailbox of Github.

I can still reproduce it with the test given.

The data in the variable args found at inc\fulltext.php:588 are:

$args = [0 =>null, 1 => null ];

I run it may be with another configuration.

My local.php is

$conf['title'] = 'Title';
$conf['license'] = 'cc-by-sa';
$conf['useheading'] = '1';
$conf['useacl'] = 1;
$conf['superuser'] = '@admin';
$conf['disableactions'] = 'register';

My git summary:

git show --summary
commit fbc36acd79849164c22f5d6ef7872318cfb6907e (HEAD -> stable, tag: release-2023-04-04, origin/stable)
Merge: 1e4e47625 ebc5ef05f
Author: Andreas Gohr <[email protected]>
Date:   Tue Apr 4 18:20:30 2023 +0200

    Merge pull request #3939 from dokuwiki/auto-2023-04-04

    Release Preparations for 2023-04-04 "Jack Jackrum"

The new stack trace is:

 Caused by
 PHPUnit\Framework\Error\Warning: Invalid argument supplied for foreach()
 
 D:\dokuwiki\inc\fulltext.php:588
 D:\dokuwiki\inc\fulltext.php:130
 D:\dokuwiki\inc\Extension\Event.php:133
 D:\dokuwiki\inc\Extension\Event.php:199
 D:\dokuwiki\inc\fulltext.php:47
 D:\dokuwiki\inc\Action\Search.php:70
 D:\dokuwiki\inc\Action\Search.php:54
 D:\dokuwiki\lib\plugins\combo\ComboStrap\FetcherAppPages.php:165
 D:\dokuwiki\inc\Extension\Event.php:133
 D:\dokuwiki\inc\Extension\Event.php:199
 D:\dokuwiki\lib\plugins\combo\ComboStrap\FetcherAppPages.php:101
 D:\dokuwiki\lib\plugins\combo\action\docustom.php:152
 D:\dokuwiki\inc\Extension\EventHandler.php:80
 D:\dokuwiki\inc\Extension\Event.php:74
 D:\dokuwiki\inc\ActionRouter.php:80
 D:\dokuwiki\inc\ActionRouter.php:48
 D:\dokuwiki\inc\ActionRouter.php:60
 D:\dokuwiki\inc\actions.php:16
 D:\dokuwiki\doku.php:126
 D:\dokuwiki\_test\core\TestRequest.php:159
 D:\dokuwiki\_test\core\TestRequest.php:242
 D:\dokuwiki\lib\plugins\combo\_test\AndTest.php:5

gerardnico avatar Apr 14 '23 21:04 gerardnico