]> granicus.if.org Git - php/commitdiff
Fixed bug #78376 (Incorrect preloading of constant static properties)
authorDmitry Stogov <dmitry@zend.com>
Mon, 5 Aug 2019 19:55:06 +0000 (22:55 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 5 Aug 2019 19:55:06 +0000 (22:55 +0300)
NEWS
ext/opcache/ZendAccelerator.c
ext/opcache/tests/bug78376.phpt [new file with mode: 0644]
ext/opcache/tests/preload_bug78376.inc [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index ad352a48992e2b95fa8491e847fc42713cfdb72c..e8edf9d7877e0ab2df1a59567d24eede6fd2f2fb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -27,6 +27,8 @@ PHP                                                                        NEWS
 
 - Opcache:
   . Fixed bug #78341 (Failure to detect smart branch in DFA pass). (Nikita)
+  . Fixed bug #78376 (Incorrect preloading of constant static properties).
+    (Dmitry)
 
 - PCRE:
   . Fixed bug #78338 (Array cross-border reading in PCRE). (cmb)
index 5a3a7863c1ce3c8d5cba285dd9f57ff58fa1425f..c2a97f67dfc66cbae172485c5d3e05dc09f1c70f 100644 (file)
@@ -4268,6 +4268,16 @@ static int accel_preload(const char *config)
                        ZEND_ASSERT(ce->ce_flags & ZEND_ACC_PRELOADED);
                        if (ce->default_static_members_count) {
                                zend_cleanup_internal_class_data(ce);
+                               if (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED) {
+                                       int i;
+
+                                       for (i = 0; i < ce->default_static_members_count; i++) {
+                                               if (Z_TYPE(ce->default_static_members_table[i]) == IS_CONSTANT_AST) {
+                                                       ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED;
+                                                       break;
+                                               }
+                                       }
+                               }
                        }
                        if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
                                zend_op_array *op_array;
diff --git a/ext/opcache/tests/bug78376.phpt b/ext/opcache/tests/bug78376.phpt
new file mode 100644 (file)
index 0000000..efc69c9
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #78376 (Incorrect preloading of constant static properties)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.preload={PWD}/preload_bug78376.inc
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+var_dump(\A::$a);
+?>
+--EXPECT--
+string(4) "aaaa"
\ No newline at end of file
diff --git a/ext/opcache/tests/preload_bug78376.inc b/ext/opcache/tests/preload_bug78376.inc
new file mode 100644 (file)
index 0000000..c482e0a
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+const CNST = 'aaaa';
+class A {
+       public static $a = CNST;
+}
+$a = \A::$a;