From: [email protected]
Operating system:
PHP version: 5.4Git-2013-01-13 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:isset() inconsistently produces a fatal error on protected
property
Description:
------------
<?php
class Test {
protected $protectedProperty;
}
$test = new Test();
var_dump(isset($test->protectedProperty->foo));
This produces fatal error. However this:
var_dump(isset($test->protectedProperty));
produces bool(false) - even though the very same protected property is
accessed.
This is obviously inconsistent. It looks like this is caused by this code
in
zend_std_read_property:
property_info = zend_get_property_info_quick(zobj->ce, member, (zobj-
>ce->__get != NULL), key TSRMLS_CC);
This sets property getter to "silent" for "get" requests, but not for
"isset"
requests, even though code immediately above is:
silent = (type == BP_VAR_IS);
But 'silent' value is ignored for zend_get_property_info_quick and it is
allowed
to produce the fatal error, even though has_property() handler in this
situation
does not.
Test script:
---------------
<?php
class Test {
protected $protectedProperty;
}
$test = new Test();
var_dump(isset($test->protectedProperty->foo));
Expected result:
----------------
bool(false)
Actual result:
--------------
Fatal error: Cannot access protected property Test::$protectedProperty
--
Edit bug report at https://bugs.php.net/bug.php?id=63982&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=63982&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=63982&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=63982&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63982&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63982&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63982&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63982&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63982&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63982&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63982&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63982&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63982&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63982&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63982&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63982&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63982&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63982&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63982&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63982&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63982&r=mysqlcfg