Bug #70321 [Opn->Csd]: Magic getter breaks reference to array property
| From: | bwoebi@php.net | Date: | Sat, 22 Aug 2015 22:55:11 +0000 |
| Subject: | Bug #70321 [Opn->Csd]: Magic getter breaks reference to array property | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195430@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70321&edit=1
ID: 70321
Updated by: bwoebi@php.net
Reported by: hrach dot cz at gmail dot com
Summary: Magic getter breaks reference to array property
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: win10
PHP Version: 7.0.0RC1
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of bobwei9@hotmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=66754585f889e56ddaf3442fd4ac7b9adf93417b
Log: Fixed bug #70321 (Magic getter breaks reference to array property) Note that the UNEXPECTED(zv)
was turned into EXPECTED(zv), as zv is mostly set in the context where it is used and usually anyway
is checked first with OP*_TYPE == IS_VAR; or maybe just completely remove that (UN)EXPECTED at this
place...
Previous Comments:
------------------------------------------------------------------------
[2015-08-21 19:06:27] nikic@php.net
> I do not meant that proposed change. Since I'm returning object by magic getter, it's
> has no meaning to put the reference there. The reference would be important for that magic property,
> not the holding object itself, wouldn't be?
You're right, I misread the example.
------------------------------------------------------------------------
[2015-08-21 19:00:08] j dot tvr at centrum dot cz
It turns out what matter is NTS vs. TS build. If we modify the testcase to print more info
echo "PHP_VERSION: " . PHP_VERSION . "\n";
echo "PHP_ZTS: " . PHP_ZTS . "\n";
echo "\n";
we get the following results:
$ php test.php
PHP_VERSION: 7.0.0RC1
PHP_ZTS: 0
array(0) {
}
$ php test.php
PHP_VERSION: 7.0.0RC1
PHP_ZTS: 1
array(0) {
}
$ php test.php
PHP_VERSION: 7.0.0beta3
PHP_ZTS: 0
array(0) {
}
$ php test.php
PHP_VERSION: 7.0.0beta3
PHP_ZTS: 1
array(1) {
[0]=>
object(Closure)#3 (0) {
}
}
------------------------------------------------------------------------
[2015-08-21 18:42:05] bugs dot php dot net at majkl578 dot cz
I did some git-bisecting (because we originally thought it was caused by a fix for #70262) and it
lead me to 38151a38ec31af33e10513cc39e7cac8f819f120, a commit from 4 Mar 2014. Anything newer
appears to return an empty array...
Tried with ./configure --disable-all --enable-cli on Debian x86_64.
------------------------------------------------------------------------
[2015-08-21 18:24:25] hrach dot cz at gmail dot com
No, on Windows the bahavior has changed:
/d/storage $ php --version
PHP 7.0.0beta3 (cli) (built: Aug 5 2015 12:17:06)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
/d/storage $ php test.php
array(1) {
[0]=>
object(Closure)#3 (0) {
}
}
/d/storage $ php --version
PHP 7.0.0RC1 (cli) (built: Aug 20 2015 12:42:50)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
/d/storage $ php test.php
array(0) {
}
On Linux probably too, since travis was ok!
- ok: https://travis-ci.org/nextras/orm/jobs/72314843
- broken: https://travis-ci.org/nextras/orm/jobs/76666269
I do not meant that proposed change. Since I'm returning object by magic getter, it's has
no meaning to put the reference there. The reference would be important for that magic property, not
the holding object itself, wouldn't be?
------------------------------------------------------------------------
[2015-08-21 17:53:21] nikic@php.net
The behavior is the same for all PHP 7 versions: https://3v4l.org/GBpN8
Did you mean to write $bar =& $this->bar? If you don't use a by-reference assignment,
you won't be able to indirectly modify the property.
------------------------------------------------------------------------
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=70321
--
Edit this bug report at https://bugs.php.net/bug.php?id=70321&edit=1