php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63982 isset() inconsistently produces a fatal error on protected property
Submitted: 2013-01-14 00:21 UTC Modified: -
From: stas@php.net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5.4Git-2013-01-13 (Git) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stas@php.net
New email:
PHP Version: OS:

 

 [2013-01-14 00:21 UTC] stas@php.net
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 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-14 01:28 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1a96fe0b3260b4b63627cf69d71a5b350ad3163f
Log: fix bug #63982: isset() inconsistently produces a fatal error on protected property
 [2013-01-14 01:28 UTC] stas@php.net
-Status: Open +Status: Closed
 [2013-01-14 01:29 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1a96fe0b3260b4b63627cf69d71a5b350ad3163f
Log: fix bug #63982: isset() inconsistently produces a fatal error on protected property
 [2014-10-07 23:20 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=1a96fe0b3260b4b63627cf69d71a5b350ad3163f
Log: fix bug #63982: isset() inconsistently produces a fatal error on protected property
 [2014-10-07 23:31 UTC] stas@php.net
Automatic comment on behalf of stas
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=1a96fe0b3260b4b63627cf69d71a5b350ad3163f
Log: fix bug #63982: isset() inconsistently produces a fatal error on protected property
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC