Search.inc Error - Can you help at all? (General)

by Bobby, Thursday, June 02, 2022, 19:34 (118 days ago)

I'm on a couple of releases back, using the standard theme and get a search error.

By putting the cursor in the search box (top right) but leaving the search box blank and pressing enter.

Warning: implode(): Invalid arguments passed in

public_html/includes/search.inc.php on line 124


I have in the past been able to do this and didn't get this error and I have not changed any files so not sure why this error all of a sudden now shows.

Thanks

Avatar

Search.inc Error - Can you help at all?

by Micha ⌂, Thursday, June 02, 2022, 19:56 (118 days ago) @ Bobby

Hello,

I can reproduce the error - but not in line 124. The problem is the $search_string_array, which exists iff the search box is not blank. To fix this bug, just initializes the variable by an empty array at line 52

$search_string_array = array(); // new line of code
foreach ($search_array as $item) {
 if (my_strpos($item, ' ', 0, CHARSET)) {
  $item = '"' . $item . '"';
 }
 $search_string_array[] = $item;
}
$search = implode(' ', $search_string_array);

I add this change to github, too.

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Search.inc Error - Can you help at all?

by Bobby, Thursday, June 02, 2022, 20:48 (118 days ago) @ Micha

Just looked I'm on 2.4.19

I'm a complete noob at this but if I understand it right I just add

$search_string_array = array();

to line 118? and move the rest of the code down

I don't understand your mention of line 52. The code in that area doesn't look like what you posted.

Avatar

Search.inc Error - Can you help at all?

by Micha ⌂, Thursday, June 02, 2022, 21:13 (118 days ago) @ Bobby

Hello,

I don't understand your mention of line 52. The code in that area doesn't look like what you posted.

My change relates to the latest version, cf. search.inc.php#L52.

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

RSS Feed of thread