Bug #72132 [Opn->Nab]: isset() sometimes returns FALSE when TRUE is expected
| From: | nikic@php.net | Date: | Sat, 30 Apr 2016 10:38:30 +0000 |
| Subject: | Bug #72132 [Opn->Nab]: isset() sometimes returns FALSE when TRUE is expected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200845@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72132&edit=1
ID: 72132
Updated by: nikic@php.net
Reported by: holger dot schletz at web dot de
Summary: isset() sometimes returns FALSE when TRUE is
expected
-Status: Open
+Status: Not a bug
Type: Bug
Package: Arrays related
Operating System: Arch Linux, Kernel 4.5.1-1-ARCH
PHP Version: 7.0.6
Block user comment: N
Private report: N
New Comment:
The issue you are (very likely) hitting, is that starting with PHP 7.0.6 __isset() and
offsetExists() will be called for each access level in the expression. So in
isset($var['a']['b']), if $var is an ArrayAccess object, you will now see a call
to offsetExists($var, 'a'), where none occurred previously. If you don't have a
correct offsetExists() implementation, this may lead to the described result.
Previous Comments:
------------------------------------------------------------------------
[2016-04-30 10:25:05] holger dot schletz at web dot de
Description:
------------
This seems to be a regression with PHP 7.0.6. The problem does not occur when I downgrade to 7.0.5.
The problem is difficult to reproduce. The test script below will most likely behave correctly, but
in some very specific context, a similar case will fail, and the failure is reproducible then.
Test script:
---------------
$var['a']['b'] = 'c';
var_dump($var['a']['b']);
var_dump(isset($var['a']['b']));
Expected result:
----------------
string(1) "c"
bool(true)
Actual result:
--------------
string(1) "c"
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72132&edit=1