Menu

#605 php8 null access prohibited

open
None
5
2022-10-14
2022-10-14
No

Hi,
I've found error in modules/googlemap/placecheck.php. If there are places in gedcom absent in the places db table, errors occur about line 288 and later in the mentioned file. $row is null but the code is trying to index it. I'm surprised that it ever worked (but worked, I did used it in the past). Indexing null was illegal before php8, maybe from php7? Summing up, I propose to use "safe objedct" pattern adding the following lines (shown with one line context) after 281 line of the placecheck.php file (with correct indent of course, I can't paste it properly here):
->fetchOneRow(PDO::FETCH_ASSOC);
if(is_null($row)) {
$row = array('pl_id'=>'', 'pl_place'=>'', 'pl_long'=>0, 'pl_lati'=>'', 'pl_placerequested'=>$levels[$z]);
}
if (!empty($row['pl_id'])) {

T.B.

1 Attachments

Discussion

  • Gerry Kroll

    Gerry Kroll - 2022-10-14
    • assigned_to: Gerry Kroll
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -0,0 +1 @@
    +placecheck.zip (4.7 kB; application/x-zip-compressed)
    
     
  • Gerry Kroll

    Gerry Kroll - 2022-10-14

    Thank you.

    Very few people (myself included) use the googlemap module, so it's no surprise that there are errors in it.

    The attached placecheck.zip is placecheck.php with your correction applied.

    It will be in the next SVN update.

     
  • Tomasz Babczyński

    Gerry, it is a surprise to me, because I'm sure it worked some time ago. I don't remember which version of php I had back then. It is possible that 6.x or even 5.x.

    T.B.

     

Log in to post a comment.