Skip to content

Commit 1b1d313

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix static property indirections in file cache Don't require rc=1 for function static variables
2 parents 057875d + db0cdcb commit 1b1d313

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

Zend/zend_execute_API.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ void shutdown_executor(void) /* {{{ */
287287
if (op_array->static_variables) {
288288
HashTable *ht = ZEND_MAP_PTR_GET(op_array->static_variables_ptr);
289289
if (ht) {
290-
ZEND_ASSERT(GC_REFCOUNT(ht) == 1);
291-
zend_array_destroy(ht);
290+
zend_array_release(ht);
292291
ZEND_MAP_PTR_SET(op_array->static_variables_ptr, NULL);
293292
}
294293
}

ext/opcache/zend_file_cache.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ static void zend_file_cache_serialize_zval(zval *zv,
372372
zend_file_cache_serialize_ast(GC_AST(ast), script, info, buf);
373373
}
374374
break;
375+
case IS_INDIRECT:
376+
/* Used by static properties. */
377+
SERIALIZE_PTR(Z_INDIRECT_P(zv));
378+
break;
375379
}
376380
}
377381

@@ -631,7 +635,6 @@ static void zend_file_cache_serialize_class(zval *zv,
631635
void *buf)
632636
{
633637
zend_class_entry *ce;
634-
zend_class_entry *parent = NULL;
635638

636639
SERIALIZE_PTR(Z_PTR_P(zv));
637640
ce = Z_PTR_P(zv);
@@ -642,7 +645,6 @@ static void zend_file_cache_serialize_class(zval *zv,
642645
if (!(ce->ce_flags & ZEND_ACC_LINKED)) {
643646
SERIALIZE_STR(ce->parent_name);
644647
} else {
645-
parent = ce->parent;
646648
SERIALIZE_PTR(ce->parent);
647649
}
648650
}
@@ -660,16 +662,13 @@ static void zend_file_cache_serialize_class(zval *zv,
660662
}
661663
}
662664
if (ce->default_static_members_table) {
663-
zval *table, *p, *end;
665+
zval *p, *end;
664666

665667
SERIALIZE_PTR(ce->default_static_members_table);
666-
table = ce->default_static_members_table;
667-
UNSERIALIZE_PTR(table);
668+
p = ce->default_static_members_table;
669+
UNSERIALIZE_PTR(p);
668670

669-
/* Serialize only static properties in this class.
670-
* Static properties from parent classes will be handled in class_copy_ctor */
671-
p = table + (parent ? parent->default_static_members_count : 0);
672-
end = table + ce->default_static_members_count;
671+
end = p + ce->default_static_members_count;
673672
while (p < end) {
674673
zend_file_cache_serialize_zval(p, script, info, buf);
675674
p++;
@@ -1093,6 +1092,10 @@ static void zend_file_cache_unserialize_zval(zval *zv,
10931092
zend_file_cache_unserialize_ast(Z_ASTVAL_P(zv), script, buf);
10941093
}
10951094
break;
1095+
case IS_INDIRECT:
1096+
/* Used by static properties. */
1097+
UNSERIALIZE_PTR(Z_INDIRECT_P(zv));
1098+
break;
10961099
}
10971100
}
10981101

@@ -1344,7 +1347,6 @@ static void zend_file_cache_unserialize_class(zval *zv,
13441347
void *buf)
13451348
{
13461349
zend_class_entry *ce;
1347-
zend_class_entry *parent = NULL;
13481350

13491351
UNSERIALIZE_PTR(Z_PTR_P(zv));
13501352
ce = Z_PTR_P(zv);
@@ -1355,7 +1357,6 @@ static void zend_file_cache_unserialize_class(zval *zv,
13551357
UNSERIALIZE_STR(ce->parent_name);
13561358
} else {
13571359
UNSERIALIZE_PTR(ce->parent);
1358-
parent = ce->parent;
13591360
}
13601361
}
13611362
zend_file_cache_unserialize_hash(&ce->function_table,
@@ -1372,14 +1373,10 @@ static void zend_file_cache_unserialize_class(zval *zv,
13721373
}
13731374
}
13741375
if (ce->default_static_members_table) {
1375-
zval *table, *p, *end;
1376-
1377-
/* Unserialize only static properties in this class.
1378-
* Static properties from parent classes will be handled in class_copy_ctor */
1376+
zval *p, *end;
13791377
UNSERIALIZE_PTR(ce->default_static_members_table);
1380-
table = ce->default_static_members_table;
1381-
p = table + (parent ? parent->default_static_members_count : 0);
1382-
end = table + ce->default_static_members_count;
1378+
p = ce->default_static_members_table;
1379+
end = p + ce->default_static_members_count;
13831380
while (p < end) {
13841381
zend_file_cache_unserialize_zval(p, script, buf);
13851382
p++;

0 commit comments

Comments
 (0)