From e21cb2daeabe459db996407df2113bb47a320937 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 23 Dec 2015 07:48:00 -0800 Subject: Fixed bug #71202 (Autoload function registered by another not activated immediately) --- ext/spl/php_spl.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ext/spl/php_spl.c') diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index e89caa2059..b2f59328d2 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -417,11 +417,17 @@ PHP_FUNCTION(spl_autoload_call) } if (SPL_G(autoload_functions)) { + HashPosition pos; + zend_ulong num_idx; int l_autoload_running = SPL_G(autoload_running); SPL_G(autoload_running) = 1; lc_name = zend_string_alloc(Z_STRLEN_P(class_name), 0); zend_str_tolower_copy(ZSTR_VAL(lc_name), Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)); - ZEND_HASH_FOREACH_STR_KEY_PTR(SPL_G(autoload_functions), func_name, alfi) { + zend_hash_internal_pointer_reset_ex(SPL_G(autoload_functions), &pos); + while (zend_hash_get_current_key_ex(SPL_G(autoload_functions), &func_name, &num_idx, &pos) == HASH_KEY_IS_STRING) { + if ((alfi = zend_hash_get_current_data_ptr_ex(SPL_G(autoload_functions), &pos)) == NULL) { + continue; + } zend_call_method(Z_ISUNDEF(alfi->obj)? NULL : &alfi->obj, alfi->ce, &alfi->func_ptr, ZSTR_VAL(func_name), ZSTR_LEN(func_name), retval, 1, class_name, NULL); zend_exception_save(); if (retval) { @@ -431,7 +437,8 @@ PHP_FUNCTION(spl_autoload_call) if (zend_hash_exists(EG(class_table), lc_name)) { break; } - } ZEND_HASH_FOREACH_END(); + zend_hash_move_forward_ex(SPL_G(autoload_functions), &pos); + } zend_exception_restore(); zend_string_free(lc_name); SPL_G(autoload_running) = l_autoload_running; -- cgit v1.2.1 From 9cc4cdbe574112885cb85f6eaf4014616959bfbd Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 23 Dec 2015 07:52:24 -0800 Subject: This should never fail --- ext/spl/php_spl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'ext/spl/php_spl.c') diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index b2f59328d2..719a9f3e48 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -425,9 +425,7 @@ PHP_FUNCTION(spl_autoload_call) zend_str_tolower_copy(ZSTR_VAL(lc_name), Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)); zend_hash_internal_pointer_reset_ex(SPL_G(autoload_functions), &pos); while (zend_hash_get_current_key_ex(SPL_G(autoload_functions), &func_name, &num_idx, &pos) == HASH_KEY_IS_STRING) { - if ((alfi = zend_hash_get_current_data_ptr_ex(SPL_G(autoload_functions), &pos)) == NULL) { - continue; - } + alfi = zend_hash_get_current_data_ptr_ex(SPL_G(autoload_functions), &pos); zend_call_method(Z_ISUNDEF(alfi->obj)? NULL : &alfi->obj, alfi->ce, &alfi->func_ptr, ZSTR_VAL(func_name), ZSTR_LEN(func_name), retval, 1, class_name, NULL); zend_exception_save(); if (retval) { -- cgit v1.2.1 From 620ccc9b1a0a593786a364af15d45fd797a6cf1f Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Wed, 23 Dec 2015 08:10:59 -0800 Subject: Fixed bug #71204 (segfault if clean spl_autoload_funcs while autoloading) --- ext/spl/php_spl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ext/spl/php_spl.c') diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 3424b90aea..d3228698de 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -669,10 +669,14 @@ PHP_FUNCTION(spl_autoload_unregister) if (SPL_G(autoload_functions)) { if (func_name_len == sizeof("spl_autoload_call")-1 && !strcmp(lc_name, "spl_autoload_call")) { /* remove all */ - zend_hash_destroy(SPL_G(autoload_functions)); - FREE_HASHTABLE(SPL_G(autoload_functions)); - SPL_G(autoload_functions) = NULL; - EG(autoload_func) = NULL; + if (!SPL_G(autoload_running)) { + zend_hash_destroy(SPL_G(autoload_functions)); + FREE_HASHTABLE(SPL_G(autoload_functions)); + SPL_G(autoload_functions) = NULL; + EG(autoload_func) = NULL; + } else { + zend_hash_clean(SPL_G(autoload_functions)); + } success = SUCCESS; } else { /* remove specific */ -- cgit v1.2.1 From 49493a2dcfb2cd1758b69b13d9006ead3be0e066 Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Fri, 1 Jan 2016 19:19:27 +0200 Subject: Happy new year (Update copyright to 2016) --- ext/spl/php_spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/spl/php_spl.c') diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index d3228698de..0f302787be 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | -- cgit v1.2.1 From 2b4625d68737c553c1fa50a5442bc976814ae855 Mon Sep 17 00:00:00 2001 From: Bogdan Padalko Date: Tue, 12 Jan 2016 01:26:34 +0200 Subject: Remove obj handlers ptr value from spl_object_hash() We still keep the same output length, for people who rely on the return value having a specific format. The handler part will now simply be always the same (it was the same nearly always anyway). The motivation behind this change is to avoid breaking spl_object_hash() and SplObjectStorage if an extension changes the handlers table of an object. This has come up, for example, in weakref implementations. --- ext/spl/php_spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/spl/php_spl.c') diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 57e43d4fae..9c7611d117 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -777,7 +777,7 @@ PHPAPI zend_string *php_spl_object_hash(zval *obj) /* {{{*/ } hash_handle = SPL_G(hash_mask_handle)^(intptr_t)Z_OBJ_HANDLE_P(obj); - hash_handlers = SPL_G(hash_mask_handlers)^(intptr_t)Z_OBJ_HT_P(obj); + hash_handlers = SPL_G(hash_mask_handlers); return strpprintf(32, "%016lx%016lx", hash_handle, hash_handlers); } -- cgit v1.2.1