com php-src: Fixed bug #74340: NEWS Zend/tests/bug74340.phpt Zend/zend_object_handlers.c

[email protected] (Nikita Popov)
Newsgroups php.cvs
Message-ID <[email protected]>
Commit:    fe46a7da78f037fe032f27c9b65667c675a6dd8d
Author:    Nikita Popov <[email protected]>         Sun, 2 Apr 2017 13:30:35 +0200
Parents:   c8034514edadbafc4376f107e2a4ba52b7b17ff4
Branches:  PHP-7.1 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=fe46a7da78f037fe032f27c9b65667c675a6dd8d

Log:
Fixed bug #74340

Bugs:
https://bugs.php.net/74340

Changed paths:
  M  NEWS
  A  Zend/tests/bug74340.phpt
  M  Zend/zend_object_handlers.c


Diff:
diff --git a/NEWS b/NEWS
index 635a51b..f92417a 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2017, PHP 7.1.5
 
+- Core:
+  . Fixed bug #74340 (Magic function __get has different behavior in php 7.1.x).
+    (Nikita)
+
 - GD:
   . Fixed bug #74343 (compile fails on solaris 11 with system gd2 library).
     (krakjoe)
diff --git a/Zend/tests/bug74340.phpt b/Zend/tests/bug74340.phpt
new file mode 100644
index 0000000..f266dcc
--- /dev/null
+++ b/Zend/tests/bug74340.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Bug #74340: Magic function __get has different behavior in php 7.1.x
+--FILE--
+<?php
+class Test
+{
+    public function __get($var)
+    {
+        static $first = true;
+        echo '__get '.$var.PHP_EOL;
+        if ($first) {
+            $first = false;
+            $this->$var;
+            $this->{$var.'2'};
+            $this->$var;
+        }
+    }
+}
+
+$test = new Test;
+$test->test;
+
+?>
+--EXPECTF--
+__get test
+
+Notice: Undefined property: Test::$test in %s on line %d
+__get test2
+
+Notice: Undefined property: Test::$test in %s on line %d
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 9a01bcf..c75a59e 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -545,7 +545,7 @@ ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *membe
 			ALLOC_HASHTABLE(guards);
 			zend_hash_init(guards, 8, NULL, zend_property_guard_dtor, 0);
 			/* mark pointer as "special" using low bit */
-			zend_hash_add_new_ptr(guards, member,
+			zend_hash_add_new_ptr(guards, str,
 				(void*)(((zend_uintptr_t)&zv->u2.property_guard) | 1));
 			zend_string_release(Z_STR_P(zv));
 			ZVAL_ARR(zv, guards);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.