Skip to content

Commit 3ef6c42

Browse files
committed
get working with opcache
1 parent f393cf3 commit 3ef6c42

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

Zend/zend_compile.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9164,6 +9164,7 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
91649164

91659165
zval name_zv;
91669166
ZVAL_STR(&name_zv, name);
9167+
GC_ADDREF(name);
91679168

91689169
// configure the current ce->flags for a nested class. This should only include:
91699170
// - final
@@ -9182,8 +9183,12 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel)
91829183
// - a constant that contains the name of the nested class
91839184
// this "tricks" the engine into thinking that the nested class is a normal class
91849185
zend_type t = ZEND_TYPE_INIT_CODE(IS_STRING, 0, 0);
9185-
zend_declare_typed_property(CG(active_class_entry), unqualified_name, &name_zv, propFlags | ZEND_ACC_STATIC | ZEND_ACC_READONLY, decl->doc_comment, t);
9186-
zend_declare_class_constant_ex(CG(active_class_entry), unqualified_name, &name_zv, propFlags, decl->doc_comment);
9186+
zval propz, constz;
9187+
ZVAL_COPY_OR_DUP(&propz, &name_zv);
9188+
ZVAL_COPY_OR_DUP(&constz, &name_zv);
9189+
zend_declare_typed_property(CG(active_class_entry), unqualified_name, &propz, propFlags | ZEND_ACC_STATIC | ZEND_ACC_READONLY, decl->doc_comment, t);
9190+
zend_declare_class_constant_ex(CG(active_class_entry), unqualified_name, &constz, propFlags, decl->doc_comment);
9191+
ZVAL_PTR_DTOR(&name_zv);
91879192

91889193
// if a class is private or protected, we need to require scope for type checks
91899194
ce->required_scope = propFlags & (ZEND_ACC_PROTECTED|ZEND_ACC_PRIVATE) ? CG(active_class_entry) : NULL;

ext/opcache/zend_persist.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,18 @@ zend_class_entry *zend_persist_class_entry(zend_class_entry *orig_ce)
11171117
return ce;
11181118
}
11191119

1120+
void zend_update_required_scope(zend_class_entry *ce)
1121+
{
1122+
if (ce->required_scope) {
1123+
zend_class_entry *required_scope = ce->required_scope;
1124+
1125+
zend_class_entry *r = zend_shared_alloc_get_xlat_entry(required_scope);
1126+
if (r) {
1127+
ce->required_scope = r;
1128+
}
1129+
}
1130+
}
1131+
11201132
void zend_update_parent_ce(zend_class_entry *ce)
11211133
{
11221134
if (ce->ce_flags & ZEND_ACC_LINKED) {
@@ -1290,6 +1302,7 @@ static void zend_accel_persist_class_table(HashTable *class_table)
12901302
if (EXPECTED(Z_TYPE(p->val) != IS_ALIAS_PTR)) {
12911303
ce = Z_PTR(p->val);
12921304
zend_update_parent_ce(ce);
1305+
zend_update_required_scope(ce);
12931306
}
12941307
} ZEND_HASH_FOREACH_END();
12951308
#ifdef HAVE_JIT

0 commit comments

Comments
 (0)