]> granicus.if.org Git - php/commitdiff
Fixed bug #70873 (Regression on private static properties access)
authorXinchen Hui <laruence@gmail.com>
Sat, 7 Nov 2015 14:50:24 +0000 (06:50 -0800)
committerXinchen Hui <laruence@gmail.com>
Sat, 7 Nov 2015 14:50:36 +0000 (06:50 -0800)
NEWS
Zend/tests/bug70873.phpt [new file with mode: 0644]
Zend/zend_object_handlers.c

diff --git a/NEWS b/NEWS
index e68dc23819ed74f41df6d8bbede3b772878ab5d4..95aab2c0c193ff00122cd754265a5d0c9cf3bce7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? ??? 2015, PHP 7.0.1
 
 - Core:
+  . Fixed bug #70873 (Regression on private static properties access).
+    (Laruence)
   . Fixed bug #70805 (Segmentation faults whilst running Drupal 8 test suite).
     (Dmitry, Laruence)
   . Fixed bug #70862 (Several functions do not check return code of
diff --git a/Zend/tests/bug70873.phpt b/Zend/tests/bug70873.phpt
new file mode 100644 (file)
index 0000000..3edb7ea
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+Bug #70873 (Regression on private static properties access)
+--FILE--
+<?php
+
+class A {
+       private static $x = 1;
+}
+
+class B extends A {
+       function bar() {
+               var_dump(self::$x);
+       }
+};
+
+class C extends A {
+       function bar() {
+               var_dump(A::$x);
+       }
+};
+
+
+$a = new B;
+$a->bar();
+
+$b = new C;
+$b->bar();
+?>
+--EXPECTF--
+Fatal error: Uncaught Error: Cannot access  property B::$x in %sbug70873.php:%d
+Stack trace:
+#0 %sbug70873.php(%d): B->bar()
+#1 {main}
+  thrown in %sbug70873.php on line %d
index 7c4b6a679a694b8dda28b285abb68981cfd95be8..4cd8a4e7c2aaa24d8585e76c3b269bf1d7a6706c 100644 (file)
@@ -275,10 +275,10 @@ static zend_always_inline int zend_verify_property_access(zend_property_info *pr
                return 1;
        } else if (property_info->flags & ZEND_ACC_PRIVATE) {
                return (ce == EG(scope) || property_info->ce == EG(scope));
-       } else {
-               ZEND_ASSERT(property_info->flags & ZEND_ACC_PROTECTED);
+       } else if (property_info->flags & ZEND_ACC_PROTECTED) {
                return zend_check_protected(property_info->ce, EG(scope));
        }
+       return 0;
 }
 /* }}} */