From 06f056a760bd6db35cfddb41f98ed9ed9482cfd1 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 11 Sep 2018 18:29:27 +0300 Subject: [PATCH] Additional fix for bug #76860. --- Zend/tests/bug76860_2.phpt | 34 ++++++++++++++++++++++++++++++++++ Zend/zend_object_handlers.c | 9 ++++----- 2 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 Zend/tests/bug76860_2.phpt diff --git a/Zend/tests/bug76860_2.phpt b/Zend/tests/bug76860_2.phpt new file mode 100644 index 0000000000..bc92702fc1 --- /dev/null +++ b/Zend/tests/bug76860_2.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #76860 (Missed "Accessing static property as non static" warning) +--FILE-- +a, $this->b, $this->c); + } +} +class B extends A { + private static $a = "a1"; + protected static $b = "b1"; + public static $c = "c1"; +} +new B; +?> +--EXPECTF-- +Notice: Accessing static property B::$a as non static in %sbug76860_2.php on line 7 + +Notice: Undefined property: B::$a in %sbug76860_2.php on line 7 + +Notice: Accessing static property B::$b as non static in %sbug76860_2.php on line 7 + +Notice: Undefined property: B::$b in %sbug76860_2.php on line 7 + +Notice: Accessing static property B::$c as non static in %sbug76860_2.php on line 7 + +Notice: Undefined property: B::$c in %sbug76860_2.php on line 7 +NULL +NULL +NULL diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 3ab2a0e4be..4e982baac1 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -378,7 +378,7 @@ static zend_always_inline uintptr_t zend_get_property_offset(zend_class_entry *c if (flags & ZEND_ACC_PUBLIC) { if (!(flags & ZEND_ACC_CHANGED)) { no_changed: - if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0)) { + if (UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0)) { if (!silent) { zend_error(E_NOTICE, "Accessing static property %s::$%s as non static", ZSTR_VAL(ce->name), ZSTR_VAL(member)); } @@ -431,9 +431,7 @@ check_scope: && ((zend_property_info*)Z_PTR_P(zv))->flags & ZEND_ACC_PRIVATE && ((zend_property_info*)Z_PTR_P(zv))->ce == scope) { property_info = (zend_property_info*)Z_PTR_P(zv); - if (UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0)) { - return ZEND_DYNAMIC_PROPERTY_OFFSET; - } + goto no_changed; } else if (UNEXPECTED(property_info == NULL)) { exit_dynamic: if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0' && ZSTR_LEN(member) != 0)) { @@ -481,7 +479,7 @@ ZEND_API zend_property_info *zend_get_property_info(zend_class_entry *ce, zend_s if (flags & ZEND_ACC_PUBLIC) { if (!(flags & ZEND_ACC_CHANGED)) { no_changed: - if (UNEXPECTED((flags & ZEND_ACC_STATIC) != 0)) { + if (UNEXPECTED((property_info->flags & ZEND_ACC_STATIC) != 0)) { if (!silent) { zend_error(E_NOTICE, "Accessing static property %s::$%s as non static", ZSTR_VAL(ce->name), ZSTR_VAL(member)); } @@ -533,6 +531,7 @@ check_scope: && ((zend_property_info*)Z_PTR_P(zv))->flags & ZEND_ACC_PRIVATE && ((zend_property_info*)Z_PTR_P(zv))->ce == scope) { property_info = (zend_property_info*)Z_PTR_P(zv); + goto no_changed; } else if (UNEXPECTED(property_info == NULL)) { exit_dynamic: if (UNEXPECTED(ZSTR_VAL(member)[0] == '\0' && ZSTR_LEN(member) != 0)) { -- 2.40.0