summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Kneuss <colder@php.net>2009-04-20 14:20:20 +0000
committerEtienne Kneuss <colder@php.net>2009-04-20 14:20:20 +0000
commit3b90499884f31016fc60a2e5aebd55af19fd59a4 (patch)
tree92e47041c91d7324e5878623a8e6ef3fa645c78f
parentaea9dfb3539500e2a2def74b651d08db4a94e143 (diff)
downloadphp-git-3b90499884f31016fc60a2e5aebd55af19fd59a4.tar.gz
MFH: Fix #48023 (spl_autoload_register didn't store closures)
-rw-r--r--NEWS1
-rwxr-xr-xext/spl/php_spl.c10
-rw-r--r--ext/spl/tests/bug48023.phpt12
3 files changed, 23 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index effe52f532..afa651a08d 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ PHP NEWS
disable this behaviour using "http"=>array("auto_decode"=>0) in stream
context. (Dmitry)
+- Fixed bug #48023 (spl_autoload_register didn't store closures). (Etienne)
- Fixed bug #47880 (crashes in call_user_func_array()). (Dmitry)
- Fixed bug #47856 (stristr() converts needle to lower-case). (Ilia)
- Fixed bug #47851 (is_callable throws fatal error). (Dmitry)
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 0406bb4414..dda04cbd01 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -353,6 +353,7 @@ PHP_FUNCTION(spl_autoload_extensions)
typedef struct {
zend_function *func_ptr;
zval *obj;
+ zval *closure;
zend_class_entry *ce;
} autoload_func_info;
@@ -361,6 +362,9 @@ static void autoload_func_info_dtor(autoload_func_info *alfi)
if (alfi->obj) {
zval_ptr_dtor(&alfi->obj);
}
+ if (alfi->closure) {
+ zval_ptr_dtor(&alfi->closure);
+ }
}
/* {{{ proto void spl_autoload_call(string class_name)
@@ -488,9 +492,14 @@ PHP_FUNCTION(spl_autoload_register)
RETURN_FALSE;
}
}
+ alfi.closure = NULL;
alfi.ce = fcc.calling_scope;
alfi.func_ptr = fcc.function_handler;
obj_ptr = fcc.object_ptr;
+ if (Z_TYPE_P(zcallable) == IS_OBJECT) {
+ alfi.closure = zcallable;
+ Z_ADDREF_P(zcallable);
+ }
if (error) {
efree(error);
}
@@ -527,6 +536,7 @@ PHP_FUNCTION(spl_autoload_register)
spl_alfi.func_ptr = spl_func_ptr;
spl_alfi.obj = NULL;
spl_alfi.ce = NULL;
+ spl_alfi.closure = NULL;
zend_hash_add(SPL_G(autoload_functions), "spl_autoload", sizeof("spl_autoload"), &spl_alfi, sizeof(autoload_func_info), NULL);
if (prepend && SPL_G(autoload_functions)->nNumOfElements > 1) {
/* Move the newly created element to the head of the hashtable */
diff --git a/ext/spl/tests/bug48023.phpt b/ext/spl/tests/bug48023.phpt
new file mode 100644
index 0000000000..ed0ff9e35a
--- /dev/null
+++ b/ext/spl/tests/bug48023.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Bug #48023 (spl_autoload_register didn't addref closures)
+--FILE--
+<?php
+spl_autoload_register(function(){});
+
+new Foo;
+
+?>
+===DONE===
+--EXPECTF--
+Fatal error: Class 'Foo' not found in %s on line %d