com php-src: Fixed bug #77643: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload_010.phpt ext/opcache/test s/preload_overwritten_prop_init.inc

From: Date: Thu, 21 Feb 2019 09:59:30 +0000
Subject: com php-src: Fixed bug #77643: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload_010.phpt ext/opcache/test s/preload_overwritten_prop_init.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-104794@lists.php.net to get a copy of this message
Commit: 6b110b151ddb2eb123407131476aa510b73f54d0 Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 21 Feb 2019 10:59:30 +0100 Parents: 0989b7001597fe59e54109ce2839bbfa8d041f2d Branches: PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6b110b151ddb2eb123407131476aa510b73f54d0 Log: Fixed bug #77643 Resolve property initializers against the correct class, even when parent slots are reused. Bugs: https://bugs.php.net/77643 Changed paths: M ext/opcache/ZendAccelerator.c A ext/opcache/tests/preload_010.phpt A ext/opcache/tests/preload_overwritten_prop_init.inc Diff: diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 5c05afc..f5fa1d9 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3414,23 +3414,16 @@ static void preload_link(void) } } ZEND_HASH_FOREACH_END(); if (ce->default_properties_count) { - zend_class_entry *pce = ce; - - val = ce->default_properties_table + ce->default_properties_count - 1; - do { - uint32_t count = pce->parent ? pce->default_properties_count - pce->parent->default_properties_count : pce->default_properties_count; - - while (count) { - if (Z_TYPE_P(val) == IS_CONSTANT_AST) { - if (UNEXPECTED(zval_update_constant_ex(val, pce) != SUCCESS)) { - ok = 0; - } + uint32_t i; + for (i = 0; i < ce->default_properties_count; i++) { + val = &ce->default_properties_table[i]; + if (Z_TYPE_P(val) == IS_CONSTANT_AST) { + zend_property_info *prop = ce->properties_info_table[i]; + if (UNEXPECTED(zval_update_constant_ex(val, prop->ce) != SUCCESS)) { + ok = 0; } - val--; - count--; } - pce = pce->parent; - } while (pce && pce-> default_properties_count); + } } if (ce->default_static_members_count) { uint32_t count = ce->parent ? ce->default_static_members_count - ce->parent->default_static_members_count : ce->default_static_members_count; diff --git a/ext/opcache/tests/preload_010.phpt b/ext/opcache/tests/preload_010.phpt new file mode 100644 index 0000000..80967f6 --- /dev/null +++ b/ext/opcache/tests/preload_010.phpt @@ -0,0 +1,15 @@ +--TEST-- +Initializer of overwritten property should be resolved against the correct class +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.preload={PWD}/preload_overwritten_prop_init.inc +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +var_dump((new Bar)->prop); +?> +--EXPECT-- +int(42) diff --git a/ext/opcache/tests/preload_overwritten_prop_init.inc b/ext/opcache/tests/preload_overwritten_prop_init.inc new file mode 100644 index 0000000..9d2c602 --- /dev/null +++ b/ext/opcache/tests/preload_overwritten_prop_init.inc @@ -0,0 +1,10 @@ +<?php + +class Foo { + public $prop; +} + +class Bar extends Foo { + public $prop = self::FOOBAR; + const FOOBAR = 42; +}

« previous php.cvs (#104794) next »