svn: /php/php-src/ branches/PHP_5_2/NEWS branches/PHP_5_2/ext/spl/php_spl.c branches/PHP_5_2/ext/spl/tests/bug40091.phpt
branches/PHP_5_2/ext/spl/tests/bug44144.phpt branches/PHP_5_3/ext/spl/tests/bug44144.phpt trunk/ext/spl/tests/bug44144.phpt
| From: | Hannes Magnusson | Date: | Tue, 28 Jul 2009 22:25:31 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_2/NEWS branches/PHP_5_2/ext/spl/php_spl.c branches/PHP_5_2/ext/spl/tests/bug40091.phpt branches/PHP_5_2/ext/spl/tests/bug44144.phpt branches/PHP_5_3/ext/spl/tests/bug44144.phpt trunk/ext/spl/tests/bug44144.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-59885@lists.php.net to get a copy of this message | ||
bjori Tue, 28 Jul 2009 22:25:31 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=286476
Log:
MFH: Fixed bug #44144 & add test
Bug: http://bugs.php.net/44144 (Closed)
spl_autoload_functions() should return object instance when appropriate
Changed paths:
U php/php-src/branches/PHP_5_2/NEWS
U php/php-src/branches/PHP_5_2/ext/spl/php_spl.c
U php/php-src/branches/PHP_5_2/ext/spl/tests/bug40091.phpt
A php/php-src/branches/PHP_5_2/ext/spl/tests/bug44144.phpt
A php/php-src/branches/PHP_5_3/ext/spl/tests/bug44144.phpt
A php/php-src/trunk/ext/spl/tests/bug44144.phpt
Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS 2009-07-28 21:42:05 UTC (rev 286475)
+++ php/php-src/branches/PHP_5_2/NEWS 2009-07-28 22:25:31 UTC (rev 286476)
@@ -67,6 +67,8 @@
(Sriram Natarajan)
- Fixed bug #48182 (ssl handshake fails during asynchronous socket connection).
(Sriram Natarajan)
+- Fixed bug #44144 (spl_autoload_functions() should return object instance
+ when appropriate). (Hannes, Etienne)
- Fixed bug #42434 (ImageLine w/ antialias = 1px shorter). (wojjie at gmail dot
com, Kalle)
Modified: php/php-src/branches/PHP_5_2/ext/spl/php_spl.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/php_spl.c 2009-07-28 21:42:05 UTC (rev 286475)
+++ php/php-src/branches/PHP_5_2/ext/spl/php_spl.c 2009-07-28 22:25:31 UTC (rev 286476)
@@ -564,8 +564,9 @@
Return all registered __autoload() functionns */
PHP_FUNCTION(spl_autoload_functions)
{
- zend_function *fptr, **func_ptr_ptr;
+ zend_function *fptr;
HashPosition function_pos;
+ autoload_func_info *alfi;
if (!EG(autoload_func)) {
if (zend_hash_find(EG(function_table), ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME),
(void **) &fptr) == SUCCESS) {
@@ -582,17 +583,22 @@
array_init(return_value);
zend_hash_internal_pointer_reset_ex(SPL_G(autoload_functions), &function_pos);
while(zend_hash_has_more_elements_ex(SPL_G(autoload_functions), &function_pos) == SUCCESS) {
- zend_hash_get_current_data_ex(SPL_G(autoload_functions), (void **) &func_ptr_ptr,
&function_pos);
- if ((*func_ptr_ptr)->common.scope) {
+ zend_hash_get_current_data_ex(SPL_G(autoload_functions), (void **) &alfi,
&function_pos);
+ if (alfi->func_ptr->common.scope) {
zval *tmp;
MAKE_STD_ZVAL(tmp);
array_init(tmp);
- add_next_index_string(tmp, (*func_ptr_ptr)->common.scope->name, 1);
- add_next_index_string(tmp, (*func_ptr_ptr)->common.function_name, 1);
+ if (alfi->obj) {
+ alfi->obj->refcount++;
+ add_next_index_zval(tmp, alfi->obj);
+ } else {
+ add_next_index_string(tmp, alfi->ce->name, 1);
+ }
+ add_next_index_string(tmp, alfi->func_ptr->common.function_name, 1);
add_next_index_zval(return_value, tmp);
} else
- add_next_index_string(return_value, (*func_ptr_ptr)->common.function_name, 1);
+ add_next_index_string(return_value, alfi->func_ptr->common.function_name, 1);
zend_hash_move_forward_ex(SPL_G(autoload_functions), &function_pos);
}
Modified: php/php-src/branches/PHP_5_2/ext/spl/tests/bug40091.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/bug40091.phpt 2009-07-28 21:42:05 UTC (rev 286475)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/bug40091.phpt 2009-07-28 22:25:31 UTC (rev 286476)
@@ -25,13 +25,19 @@
(
[0] => Array
(
- [0] => MyAutoloader
+ [0] => MyAutoloader Object
+ (
+ )
+
[1] => autoload
)
[1] => Array
(
- [0] => MyAutoloader
+ [0] => MyAutoloader Object
+ (
+ )
+
[1] => autoload
)
Added: php/php-src/branches/PHP_5_2/ext/spl/tests/bug44144.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/spl/tests/bug44144.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/spl/tests/bug44144.phpt 2009-07-28 22:25:31 UTC (rev 286476)
@@ -0,0 +1,27 @@
+--TEST--
+Bug #44144 (spl_autoload_functions() should return object instance when appropriate)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+class Foo {
+ public function nonstaticMethod() {}
+}
+$foo = new Foo;
+spl_autoload_register(array($foo, 'nonstaticMethod'));
+$funcs = spl_autoload_functions();
+var_dump($funcs);
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ object(Foo)#%d (0) {
+ }
+ [1]=>
+ string(15) "nonstaticMethod"
+ }
+}
+
+
Added: php/php-src/branches/PHP_5_3/ext/spl/tests/bug44144.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/spl/tests/bug44144.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/spl/tests/bug44144.phpt 2009-07-28 22:25:31 UTC (rev 286476)
@@ -0,0 +1,27 @@
+--TEST--
+Bug #44144 (spl_autoload_functions() should return object instance when appropriate)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+class Foo {
+ public function nonstaticMethod() {}
+}
+$foo = new Foo;
+spl_autoload_register(array($foo, 'nonstaticMethod'));
+$funcs = spl_autoload_functions();
+var_dump($funcs);
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ object(Foo)#%d (0) {
+ }
+ [1]=>
+ string(15) "nonstaticMethod"
+ }
+}
+
+
Added: php/php-src/trunk/ext/spl/tests/bug44144.phpt
===================================================================
--- php/php-src/trunk/ext/spl/tests/bug44144.phpt (rev 0)
+++ php/php-src/trunk/ext/spl/tests/bug44144.phpt 2009-07-28 22:25:31 UTC (rev 286476)
@@ -0,0 +1,27 @@
+--TEST--
+Bug #44144 (spl_autoload_functions() should return object instance when appropriate)
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+class Foo {
+ public function nonstaticMethod() {}
+}
+$foo = new Foo;
+spl_autoload_register(array($foo, 'nonstaticMethod'));
+$funcs = spl_autoload_functions();
+var_dump($funcs);
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ object(Foo)#%d (0) {
+ }
+ [1]=>
+ string(15) "nonstaticMethod"
+ }
+}
+
+