Bug #78779 [Com]: Null Coalescing Operator: Trying to access array offset on value of type null

From: Date: Sat, 07 Dec 2019 19:01:14 +0000
Subject: Bug #78779 [Com]: Null Coalescing Operator: Trying to access array offset on value of type null
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224115@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78779&edit=1 ID: 78779 Comment by: contact at kevin-anidjar dot com Reported by: bugreport2 at gmail dot com Summary: Null Coalescing Operator: Trying to access array offset on value of type null Status: Feedback Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 7.4Git-2019-11-04 (Git) Block user comment: N Private report: N New Comment: Hi, here is a way to reproduce the issue: https://3v4l.org/mX3Pf Previous Comments: ------------------------------------------------------------------------ [2019-12-04 09:31:44] nikic@php.net Unless there's some working reproduction code for this, I don't think we can do anything here. ------------------------------------------------------------------------ [2019-11-17 11:41:35] cmb@php.net Opening, since feedback had been provided. ------------------------------------------------------------------------ [2019-11-17 04:22:05] php-bugs at lists dot php dot net No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. ------------------------------------------------------------------------ [2019-11-05 11:39:36] bugreport2 at gmail dot com it was triggered by a fuzzy-testsuite on two out of millions of calls :-( i replaced the offending code path with a construct used all over the codebase which should silence it as intended i find it interesting that it's even possible that this warning triggers at all when "Null Coalescing Operator" is used because there is no point to look at the array offset when the whole $arr is NULL - $arr = mysqli_fetch_row($db->query($sql)); - $oldcontent = $arr[0] ?? ''; + $oldcontent = (string)(mysqli_fetch_row($db->query($sql))[0] ?? ''); ------------------------------------------------------------------------ [2019-11-05 11:20:40] nikic@php.net I can't reproduce this: https://3v4l.org/9NvcY ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=78779 -- Edit this bug report at https://bugs.php.net/bug.php?id=78779&edit=1

« previous php.bugs (#224115) next »