From: Dmitry Stogov Date: Mon, 5 Aug 2019 19:55:06 +0000 (+0300) Subject: Fixed bug #78376 (Incorrect preloading of constant static properties) X-Git-Tag: php-7.4.0beta2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3fc0e2bb80734c052dc1e0c34f93a3a7f4086557;p=php Fixed bug #78376 (Incorrect preloading of constant static properties) --- diff --git a/NEWS b/NEWS index ad352a4899..e8edf9d787 100644 --- 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) diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 5a3a7863c1..c2a97f67df 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -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 index 0000000000..efc69c927e --- /dev/null +++ b/ext/opcache/tests/bug78376.phpt @@ -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-- + +--FILE-- + +--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 index 0000000000..c482e0a821 --- /dev/null +++ b/ext/opcache/tests/preload_bug78376.inc @@ -0,0 +1,6 @@ +