summaryrefslogtreecommitdiff
path: root/Zend/zend_API.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-02-15 11:20:28 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-02-15 11:20:28 +0100
commit3cafa7f4df07e2dd5c4f34e74bfdf2631fc2ef6a (patch)
tree93c99ec1ad2a420958e4f444c0d5aa075a6725a1 /Zend/zend_API.c
parentffc7e953ea908f05703d573faadc51707936321c (diff)
downloadphp-git-3cafa7f4df07e2dd5c4f34e74bfdf2631fc2ef6a.tar.gz
Assign (un)serialize_func during compilation
This avoids writing this cache at runtime, which is illegal if preloading is used. Not every serialize/unserialize function actually belongs to the Serializable interface, but I think it's not a problem to assign these anyway -- whether they are used ultimately depends on whether Serializable is implemented. Alternatively it might make sense to just drop these entirely. I don't think this is performance critical functionality.
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r--Zend/zend_API.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index f191ca25b9..97ccb61141 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2093,7 +2093,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
int count=0, unload=0;
HashTable *target_function_table = function_table;
int error_type;
- zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL, *__debugInfo = NULL;
+ zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__callstatic = NULL, *__tostring = NULL, *__debugInfo = NULL, *serialize_func = NULL, *unserialize_func = NULL;
zend_string *lowercase_name;
size_t fname_len;
const char *lc_class_name = NULL;
@@ -2268,6 +2268,10 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
*/
if ((fname_len == class_name_len) && !ctor && !memcmp(ZSTR_VAL(lowercase_name), lc_class_name, class_name_len+1)) {
ctor = reg_function;
+ } else if (zend_string_equals_literal(lowercase_name, "serialize")) {
+ serialize_func = reg_function;
+ } else if (zend_string_equals_literal(lowercase_name, "unserialize")) {
+ unserialize_func = reg_function;
} else if (ZSTR_VAL(lowercase_name)[0] != '_' || ZSTR_VAL(lowercase_name)[1] != '_') {
reg_function = NULL;
} else if (zend_string_equals_literal(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME)) {
@@ -2339,6 +2343,8 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
scope->__unset = __unset;
scope->__isset = __isset;
scope->__debugInfo = __debugInfo;
+ scope->serialize_func = serialize_func;
+ scope->unserialize_func = unserialize_func;
if (ctor) {
ctor->common.fn_flags |= ZEND_ACC_CTOR;
if (ctor->common.fn_flags & ZEND_ACC_STATIC) {