]> granicus.if.org Git - php/commitdiff
- MFH Fix "f" modifier for zend_parse_parameters_ex in case of a __call call
authorJohannes Schlüter <johannes@php.net>
Mon, 30 Apr 2007 19:54:41 +0000 (19:54 +0000)
committerJohannes Schlüter <johannes@php.net>
Mon, 30 Apr 2007 19:54:41 +0000 (19:54 +0000)
# only affects iterator_apply() in 5_2 branch

Zend/zend_API.c
ext/spl/tests/spl_007.phpt [new file with mode: 0755]

index ad58ac4490408e2257a7b6148af5695a4bb749d8..724c6137d3c4d8ceaae27ba8bcdb204d1def58f5 100644 (file)
@@ -2361,17 +2361,24 @@ ZEND_API int zend_fcall_info_init(zval *callable, zend_fcall_info *fci, zend_fca
        fci->size = sizeof(*fci);
        fci->function_table = ce ? &ce->function_table : EG(function_table);
        fci->object_pp = obj;
-       fci->function_name = NULL;
+       fci->function_name = callable;
        fci->retval_ptr_ptr = NULL;
        fci->param_count = 0;
        fci->params = NULL;
        fci->no_separation = 1;
        fci->symbol_table = NULL;
 
-       fcc->initialized = 1;
-       fcc->function_handler = func;
-       fcc->calling_scope = ce;
-       fcc->object_pp = obj;
+        if (strlen(func->common.function_name) == sizeof(ZEND_CALL_FUNC_NAME) - 1 && !memcmp(func->common.function_name, ZEND_CALL_FUNC_NAME, sizeof(ZEND_CALL_FUNC_NAME))) {
+               fcc->initialized = 0;
+               fcc->function_handler = NULL;
+               fcc->calling_scope = NULL;
+               fcc->object_pp = NULL;
+       } else {
+               fcc->initialized = 1;
+               fcc->function_handler = func;
+               fcc->calling_scope = ce;
+               fcc->object_pp = obj;
+       }
 
        return SUCCESS;
 }
diff --git a/ext/spl/tests/spl_007.phpt b/ext/spl/tests/spl_007.phpt
new file mode 100755 (executable)
index 0000000..dcd63f9
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+SPL: iterator_apply() with callback using __call()
+--SKIPIF--
+<?php if (!extension_loaded("spl")) print "skip"; ?>
+--FILE--
+<?php
+
+class Foo {
+    public function __call($name, $params) {
+        echo "Called $name.\n";
+        return true;
+    }
+}
+
+$it = new ArrayIterator(array(1, 2, 3));
+
+iterator_apply($it, array(new Foo, "foobar"));
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+Called foobar.
+Called foobar.
+Called foobar.
+===DONE===