Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ static void accel_allocate_ce_cache_slots(void)

ce = (zend_class_entry*)Z_PTR(p->val);
if (ce->name) {
zend_accel_get_class_name_map_ptr(ce->name, ce, /* have_xlat */ false);
zend_accel_get_class_name_map_ptr(ce->name);
}
} ZEND_HASH_FOREACH_END();
}
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/ZendAccelerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type);

zend_string* ZEND_FASTCALL accel_new_interned_string(zend_string *str);

uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name, zend_class_entry *scope, bool have_xlat);
uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name);

/* memory write protection */
#define SHM_PROTECT() \
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/zend_file_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ static void zend_file_cache_unserialize_type(
UNSERIALIZE_STR(type_name);
ZEND_TYPE_SET_PTR(*type, type_name);
if (!script->corrupted) {
zend_accel_get_class_name_map_ptr(type_name, scope, /* have_xlat */ false);
zend_accel_get_class_name_map_ptr(type_name);
}
} else if (ZEND_TYPE_HAS_CE(*type)) {
zend_class_entry *ce = ZEND_TYPE_CE(*type);
Expand Down Expand Up @@ -1499,7 +1499,7 @@ static void zend_file_cache_unserialize_class(zval *zv,
UNSERIALIZE_STR(ce->name);
if (!(ce->ce_flags & ZEND_ACC_ANON_CLASS)
&& !script->corrupted) {
zend_accel_get_class_name_map_ptr(ce->name, ce, /* have_xlat */ false);
zend_accel_get_class_name_map_ptr(ce->name);
}
if (ce->parent) {
if (!(ce->ce_flags & ZEND_ACC_LINKED)) {
Expand Down
31 changes: 6 additions & 25 deletions ext/opcache/zend_persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,32 +298,13 @@ static HashTable *zend_persist_attributes(HashTable *attributes)
return ptr;
}

uint32_t zend_accel_get_class_name_map_ptr(
zend_string *type_name, zend_class_entry *scope, bool have_xlat)
uint32_t zend_accel_get_class_name_map_ptr(zend_string *type_name)
{
uint32_t ret;

if (zend_string_equals_literal_ci(type_name, "self")) {
if (!scope || (scope->ce_flags & ZEND_ACC_TRAIT)) {
return 0;
}
type_name = scope->name;
} else if (zend_string_equals_literal_ci(type_name, "parent")) {
if (!scope || !scope->parent) {
return 0;
}
if (scope->ce_flags & ZEND_ACC_RESOLVED_PARENT) {
/* This runs before zend_update_parent_ce(), so manually fetch the persisted parent
* class, as the original may be no longer valid. */
zend_class_entry *new_parent;
if (have_xlat && (new_parent = zend_shared_alloc_get_xlat_entry(scope->parent))) {
type_name = new_parent->name;
} else {
type_name = scope->parent->name;
}
} else {
type_name = scope->parent_name;
}
if (zend_string_equals_literal_ci(type_name, "self") ||
zend_string_equals_literal_ci(type_name, "parent")) {
return 0;
}

/* We use type.name.gc.refcount to keep map_ptr of corresponding type */
Expand Down Expand Up @@ -383,7 +364,7 @@ static void zend_persist_type(zend_type *type, zend_class_entry *scope) {
zend_accel_store_interned_string(type_name);
ZEND_TYPE_SET_PTR(*single_type, type_name);
if (!ZCG(current_persistent_script)->corrupted) {
zend_accel_get_class_name_map_ptr(type_name, scope, /* have_xlat */ true);
zend_accel_get_class_name_map_ptr(type_name);
}
}
} ZEND_TYPE_FOREACH_END();
Expand Down Expand Up @@ -893,7 +874,7 @@ zend_class_entry *zend_persist_class_entry(zend_class_entry *orig_ce)
if (ZSTR_HAS_CE_CACHE(ce->name)) {
ZSTR_SET_CE_CACHE(ce->name, NULL);
} else {
zend_accel_get_class_name_map_ptr(ce->name, ce, /* have_xlat */ true);
zend_accel_get_class_name_map_ptr(ce->name);
}
}
if (ce->parent_name && !(ce->ce_flags & ZEND_ACC_LINKED)) {
Expand Down