diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-05-20 10:55:36 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-05-20 11:12:18 +0200 |
commit | db0cdcbb0a224f958870125a13bd5901fa6e8a0f (patch) | |
tree | eb2332349c4907e5844a8eb6d806e304431ff58f | |
parent | 8819d247c68bd1b86959b3e7dfb66d54803c5d85 (diff) | |
download | php-git-db0cdcbb0a224f958870125a13bd5901fa6e8a0f.tar.gz |
Fix static property indirections in file cache
If the class is already linked, we need to serialize and
unserialize INDIRECTed static properties. Normally these would
be set up when copying from cache.
-rw-r--r-- | ext/opcache/zend_file_cache.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/ext/opcache/zend_file_cache.c b/ext/opcache/zend_file_cache.c index 18c69288b3..b46edcb065 100644 --- a/ext/opcache/zend_file_cache.c +++ b/ext/opcache/zend_file_cache.c @@ -368,6 +368,10 @@ static void zend_file_cache_serialize_zval(zval *zv, zend_file_cache_serialize_ast(GC_AST(ast), script, info, buf); } break; + case IS_INDIRECT: + /* Used by static properties. */ + SERIALIZE_PTR(Z_INDIRECT_P(zv)); + break; } } @@ -626,7 +630,6 @@ static void zend_file_cache_serialize_class(zval *zv, void *buf) { zend_class_entry *ce; - zend_class_entry *parent = NULL; SERIALIZE_PTR(Z_PTR_P(zv)); ce = Z_PTR_P(zv); @@ -637,7 +640,6 @@ static void zend_file_cache_serialize_class(zval *zv, if (!(ce->ce_flags & ZEND_ACC_LINKED)) { SERIALIZE_STR(ce->parent_name); } else { - parent = ce->parent; SERIALIZE_PTR(ce->parent); } } @@ -655,16 +657,13 @@ static void zend_file_cache_serialize_class(zval *zv, } } if (ce->default_static_members_table) { - zval *table, *p, *end; + zval *p, *end; SERIALIZE_PTR(ce->default_static_members_table); - table = ce->default_static_members_table; - UNSERIALIZE_PTR(table); + p = ce->default_static_members_table; + UNSERIALIZE_PTR(p); - /* Serialize only static properties in this class. - * Static properties from parent classes will be handled in class_copy_ctor */ - p = table + (parent ? parent->default_static_members_count : 0); - end = table + ce->default_static_members_count; + end = p + ce->default_static_members_count; while (p < end) { zend_file_cache_serialize_zval(p, script, info, buf); p++; @@ -1081,6 +1080,10 @@ static void zend_file_cache_unserialize_zval(zval *zv, zend_file_cache_unserialize_ast(Z_ASTVAL_P(zv), script, buf); } break; + case IS_INDIRECT: + /* Used by static properties. */ + UNSERIALIZE_PTR(Z_INDIRECT_P(zv)); + break; } } @@ -1325,7 +1328,6 @@ static void zend_file_cache_unserialize_class(zval *zv, void *buf) { zend_class_entry *ce; - zend_class_entry *parent = NULL; UNSERIALIZE_PTR(Z_PTR_P(zv)); ce = Z_PTR_P(zv); @@ -1336,7 +1338,6 @@ static void zend_file_cache_unserialize_class(zval *zv, UNSERIALIZE_STR(ce->parent_name); } else { UNSERIALIZE_PTR(ce->parent); - parent = ce->parent; } } zend_file_cache_unserialize_hash(&ce->function_table, @@ -1353,14 +1354,10 @@ static void zend_file_cache_unserialize_class(zval *zv, } } if (ce->default_static_members_table) { - zval *table, *p, *end; - - /* Unserialize only static properties in this class. - * Static properties from parent classes will be handled in class_copy_ctor */ + zval *p, *end; UNSERIALIZE_PTR(ce->default_static_members_table); - table = ce->default_static_members_table; - p = table + (parent ? parent->default_static_members_count : 0); - end = table + ce->default_static_members_count; + p = ce->default_static_members_table; + end = p + ce->default_static_members_count; while (p < end) { zend_file_cache_unserialize_zval(p, script, buf); p++; |