Place Entry - causes non-fatal crash in the edit box
Brought to you by:
canajun2eh,
yalnifj
While entering a birthplace, I started typing a name that was not in the location db, and the autocomplete_PLAC returned an error and stack dump - as shown in the attached picture and as listed here:
<br />ERROR 2: Trying to access array offset on null<br />
0 Error occurred on line <b>543</b> of file <b>autocomplete.php</b> in function <b>autocomplete_PLAC</b><br />
1 called from line <b>92</b> of file <b>autocomplete.php</b><br />
Warning: Trying to access array offset on null in /volume1/web/gen/autocomplete.php on line 543
Call Stack:
0.0000 368592 1. {main}() /volume1/web/gen/autocomplete.php:0
0.0093 774784 2. autocomplete_PLAC($FILTER = 'ZQ', $OPTION = NULL) /volume1/web/gen/autocomplete.php:92
I reproduced it by just typing a few letters that don't match anything and pulled the text from the browser debug | network panel.
case 'PLAC':
92 $data=autocomplete_PLAC($FILTER, $OPTION);
break;
and
$places = json_decode($json, true);
543 if ($places["geonames"]) {
foreach ($places["geonames"] as $k => $place) {
I'm on Revision 7382, which appears to be the latest.
I should have mentioned, typing on thru the error works, and then it will accept what you put in there. So, it seems be just the autocomplete when it doesn't match any existing pattern.
Try replacing line 542 of autocomplete.php with this:
Let me know by e-mail to gkroll (at) keldine (dot) ca whether this works. PHP 8 definitely does NOT like NULL!!!
The description in the PHP8 manual of the json_decode function says that NULL is returned when the function fails or when the input string is not valid JSON.
So, the absolutely correct code at line 542 should be