]> granicus.if.org Git - php/commitdiff
Handle __call() on protected/private method access for callbacks too.
authorAndrei Zmievski <andrei@php.net>
Thu, 8 Jan 2009 21:39:06 +0000 (21:39 +0000)
committerAndrei Zmievski <andrei@php.net>
Thu, 8 Jan 2009 21:39:06 +0000 (21:39 +0000)
Zend/tests/access_modifiers_012.phpt [new file with mode: 0644]
Zend/zend_API.c

diff --git a/Zend/tests/access_modifiers_012.phpt b/Zend/tests/access_modifiers_012.phpt
new file mode 100644 (file)
index 0000000..ac4d72c
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Trigger __call() in lieu of non visible methods when called via a callback.
+--FILE--
+<?php
+class C {
+       protected function prot() { }
+       private function priv() { }
+       public function __call($name, $args)    {
+        echo "In __call() for method $name()\n";
+    }
+}
+
+$c = new C;
+call_user_func(array($c, 'none'));
+call_user_func(array($c, 'prot'));
+call_user_func(array($c, 'priv'));
+?>
+--EXPECTF--
+In __call() for method none()
+In __call() for method prot()
+In __call() for method priv()
index 37340a7a3f1ce2253d316febc24b0eda34642cd6..4a8716371e571a24946cdaf68e7319061a840276 100644 (file)
@@ -2216,6 +2216,10 @@ static int zend_is_callable_check_func(int check_flags, zval ***zobj_ptr_ptr, ze
                                                retval = 0;
                                        }
                                }
+                               if (!retval && *zobj_ptr_ptr && *ce_ptr && (*ce_ptr)->__call != 0) {
+                                       retval = (*ce_ptr)->__call != NULL;
+                                       *fptr_ptr = (*ce_ptr)->__call;
+                               }
                        }
                }
        }