]> granicus.if.org Git - php/commitdiff
Fixed bug #74340
authorNikita Popov <nikita.ppv@gmail.com>
Sun, 2 Apr 2017 11:30:35 +0000 (13:30 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sun, 2 Apr 2017 11:30:35 +0000 (13:30 +0200)
NEWS
Zend/tests/bug74340.phpt [new file with mode: 0644]
Zend/zend_object_handlers.c

diff --git a/NEWS b/NEWS
index 635a51b835e64881aeb1975cadab2c7f4c252a20..f92417a2a90f25b5bcfc53375a2ceb21c43c0a21 100644 (file)
--- 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 (file)
index 0000000..f266dcc
--- /dev/null
@@ -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
index 9a01bcf89ded910be4304a2721b888f4c182ad93..c75a59e036632c73a1269989ef528ac37be975fd 100644 (file)
@@ -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);