diff options
-rw-r--r-- | Zend/zend_API.c | 10 | ||||
-rw-r--r-- | Zend/zend_compile.c | 10 | ||||
-rw-r--r-- | Zend/zend_inheritance.c | 12 | ||||
-rwxr-xr-x | run-tests.php | 17 |
4 files changed, 43 insertions, 6 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index c03b6bfa5b..cd374383b1 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -2072,7 +2072,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; @@ -2242,7 +2242,11 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio if (scope) { /* Look for ctor, dtor, clone */ - if (ZSTR_VAL(lowercase_name)[0] != '_' || ZSTR_VAL(lowercase_name)[1] != '_') { + 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)) { ctor = reg_function; @@ -2313,6 +2317,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) { diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 33e6e47e9c..8ad0f8038b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5600,8 +5600,14 @@ void zend_begin_method_decl(zend_op_array *op_array, zend_string *name, zend_boo "public visibility and cannot be static"); } } - } else if (ZSTR_VAL(lcname)[0] == '_' && ZSTR_VAL(lcname)[1] == '_') { - if (zend_string_equals_literal(lcname, ZEND_CONSTRUCTOR_FUNC_NAME)) { + } else { + if (zend_string_equals_literal(lcname, "serialize")) { + ce->serialize_func = (zend_function *) op_array; + } else if (zend_string_equals_literal(lcname, "unserialize")) { + ce->unserialize_func = (zend_function *) op_array; + } else if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') { + /* pass */ + } else if (zend_string_equals_literal(lcname, ZEND_CONSTRUCTOR_FUNC_NAME)) { ce->constructor = (zend_function *) op_array; } else if (zend_string_equals_literal(lcname, ZEND_DESTRUCTOR_FUNC_NAME)) { ce->destructor = (zend_function *) op_array; diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 072e0b1801..5ffc0b6520 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -124,9 +124,15 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */ if (EXPECTED(!ce->clone)) { ce->clone = parent->clone; } + if (EXPECTED(!ce->serialize_func)) { + ce->serialize_func = parent->serialize_func; + } if (EXPECTED(!ce->serialize)) { ce->serialize = parent->serialize; } + if (EXPECTED(!ce->unserialize_func)) { + ce->unserialize_func = parent->unserialize_func; + } if (EXPECTED(!ce->unserialize)) { ce->unserialize = parent->unserialize; } @@ -1287,7 +1293,11 @@ static void zend_do_implement_interfaces(zend_class_entry *ce) /* {{{ */ static void zend_add_magic_methods(zend_class_entry* ce, zend_string* mname, zend_function* fe) /* {{{ */ { - if (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_') { + if (zend_string_equals_literal(mname, "serialize")) { + ce->serialize_func = fe; + } else if (zend_string_equals_literal(mname, "unserialize")) { + ce->unserialize_func = fe; + } else if (ZSTR_VAL(mname)[0] != '_' || ZSTR_VAL(mname)[1] != '_') { /* pass */ } else if (zend_string_equals_literal(mname, ZEND_CLONE_FUNC_NAME)) { ce->clone = fe; diff --git a/run-tests.php b/run-tests.php index 7c135b2dd4..92d605c4e7 100755 --- a/run-tests.php +++ b/run-tests.php @@ -264,7 +264,6 @@ $ini_overwrites = array( 'log_errors_max_len=0', 'opcache.fast_shutdown=0', 'opcache.file_update_protection=0', - 'opcache.preload=', 'zend.assertions=1', ); @@ -510,6 +509,7 @@ $temp_urlbase = null; $conf_passed = null; $no_clean = false; $slow_min_ms = INF; +$preload = false; $cfgtypes = array('show', 'keep'); $cfgfiles = array('skip', 'php', 'clean', 'out', 'diff', 'exp', 'mem'); @@ -625,6 +625,9 @@ if (isset($argc) && $argc > 1) { case 'e': $pass_options .= ' -e'; break; + case '--preload': + $preload = true; + break; case '--no-clean': $no_clean = true; break; @@ -1256,6 +1259,7 @@ function run_test($php, $file, $env) global $SHOW_ONLY_GROUPS; global $no_file_cache; global $slow_min_ms; + global $preload; $temp_filenames = null; $org_file = $file; @@ -1496,6 +1500,7 @@ TEST $file $test_skipif = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'skip.php'; $temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php'; $test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php'; + $preload_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'preload.php'; $tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.'); $tmp_relative_file = str_replace(__DIR__ . DIRECTORY_SEPARATOR, '', $test_file) . 't'; @@ -1546,6 +1551,7 @@ TEST $file @unlink($tmp_post); @unlink($temp_clean); @unlink($test_clean); + @unlink($preload_filename); // Reset environment from any previous test. $env['REDIRECT_STATUS'] = ''; @@ -1790,6 +1796,14 @@ TEST $file $args = isset($section_text['ARGS']) ? ' -- ' . $section_text['ARGS'] : ''; + if ($preload) { + save_text($preload_filename, "<?php\nerror_reporting(0);\nopcache_compile_file('" . $test_file . "');"); + $local_pass_options = $pass_options; + unset($pass_options); + $pass_options = $local_pass_options; + $pass_options .= " -d opcache.preload=" . $preload_filename; + } + if (array_key_exists('POST_RAW', $section_text) && !empty($section_text['POST_RAW'])) { $post = trim($section_text['POST_RAW']); @@ -1975,6 +1989,7 @@ COMMAND $cmd } @unlink($tmp_post); + @unlink($preload_filename); $leaked = false; $passed = false; |