Bug #70790 [NEW]: Nested __get calls in some cases.

From: Date: Mon, 26 Oct 2015 13:10:12 +0000
Subject: Bug #70790 [NEW]: Nested __get calls in some cases.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196813@lists.php.net to get a copy of this message
From:             phplists at stanvassilev dot com
Operating system: OSX
PHP version:      7.0.0RC5
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Nested __get calls in some cases.

Description:
------------
A "magic property" call into __get shouldn't trigger nested __get, but
in some cases it does - namely, when you do isset on an array key of a
non-existing property.

This is not a new behavior for PHP 7, PHP 5.6 also does this. But it's
undesirable in general.



Test script:
---------------
class Abc {
	function __get($name) {
		echo $name . ", ";
		if (isset($this->shallow)); // Doesn't trigger __get.
		if (isset($this->deep['foo'])); // Triggers __get with name "deep".
		return 'value';
	}
}

$abc = new Abc();
echo $abc->trigger; // Produces output: trigger, deep, value.

Expected result:
----------------
It's expected isset() checks in __get won't produce nested __get calls
in the same object (the "deep" part of the output shouldn't exist).

Actual result:
--------------
Nested calls of __get occur.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=70790&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70790&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70790&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70790&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70790&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70790&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70790&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70790&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70790&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70790&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70790&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70790&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70790&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70790&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70790&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70790&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70790&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70790&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70790&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70790&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70790&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#196813) next »