Skip to content

Instantly share code, notes, and snippets.

@dstogov
Created December 9, 2019 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstogov/b334962f7f184c2cf3e36b6b358cfb00 to your computer and use it in GitHub Desktop.
Save dstogov/b334962f7f184c2cf3e36b6b358cfb00 to your computer and use it in GitHub Desktop.
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index 1571093419..bcbd2f270f 100644
--- a/ext/opcache/zend_persist.c
+++ b/ext/opcache/zend_persist.c
@@ -700,6 +700,12 @@ static void zend_persist_class_entry(zval *zv)
zend_class_entry *ce = Z_PTR_P(zv);
if (ce->type == ZEND_USER_CLASS) {
+ /* The same zend_class_entry may be reused by class_alias */
+ zend_class_entry *new_ce = zend_shared_alloc_get_xlat_entry(ce);
+ if (new_ce) {
+ Z_PTR_P(zv) = new_ce;
+ return;
+ }
if ((ce->ce_flags & ZEND_ACC_LINKED)
&& (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)
&& (ce->ce_flags & ZEND_ACC_PROPERTY_TYPES_RESOLVED)
diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c
index cc798b27de..dacc2376e8 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -352,6 +352,12 @@ static void zend_persist_class_entry_calc(zval *zv)
Bucket *p;
if (ce->type == ZEND_USER_CLASS) {
+ /* The same zend_class_entry may be reused by class_alias */
+ if (zend_shared_alloc_get_xlat_entry(ce)) {
+ return;
+ }
+ zend_shared_alloc_register_xlat_entry(ce, ce);
+
check_property_type_resolution(ce);
ZCG(is_immutable_class) =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment