com php-src: Fixed bug #63111 (is_callable() lies f or abstract static method): NEWS Zend/tests/bug 63111.phpt Zend/zend_API.c
| From: | Dmitry Stogov | Date: | Fri, 21 Sep 2012 09:07:14 +0000 |
| Subject: | com php-src: Fixed bug #63111 (is_callable() lies f or abstract static method): NEWS Zend/tests/bug 63111.phpt Zend/zend_API.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-70213@lists.php.net to get a copy of this message | ||
Commit: 4db74b7f1981bf19805e815f983c50d93df2c26a
Author: Dmitry Stogov <dmitry@zend.com> Fri, 21 Sep 2012 13:07:14 +0400
Parents: fd0b3ea663431b7adaedde11668fbc0b6ba07494
Branches: PHP-5.3 PHP-5.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4db74b7f1981bf19805e815f983c50d93df2c26a
Log:
Fixed bug #63111 (is_callable() lies for abstract static method)
Bugs:
https://bugs.php.net/63111
Changed paths:
M NEWS
A Zend/tests/bug63111.phpt
M Zend/zend_API.c
Diff:
diff --git a/NEWS b/NEWS
index 787d76d...191264b 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ PHP NEWS
?? ??? 2012, PHP 5.3.18
- Core:
+ . Fixed bug #63111 (is_callable() lies for abstract static method). (Dmitry)
. Fixed bug #63093 (Segfault while load extension failed in zts-build).
(Laruence)
. Fixed bug #62976 (Notice: could not be converted to int when comparing
diff --git a/Zend/tests/bug63111.phpt b/Zend/tests/bug63111.phpt
new file mode 100644
index 0000000..3f19068
--- /dev/null
+++ b/Zend/tests/bug63111.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Bug #63111 (is_callable() lies for abstract static method)
+--FILE--
+<?php
+abstract class Foo {
+ abstract static function bar();
+}
+interface MyInterface {
+ static function bar();
+}
+abstract class Bar {
+ static function foo() {
+ echo "ok\n";
+ }
+}
+var_dump(is_callable(array("Foo", "bar")));
+var_dump(is_callable("Foo::bar"));
+var_dump(is_callable(array("MyInterface", "bar")));
+var_dump(is_callable("MyInterface::bar"));
+var_dump(is_callable(array("Bar", "foo")));
+var_dump(is_callable("Bar::foo"));
+Bar::foo();
+Foo::bar();
+?>
+--EXPECTF--
+Strict Standards: Static function Foo::bar() should not be abstract in %sbug63111.php on line 3
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+ok
+
+Fatal error: Cannot call abstract method Foo::bar() in %sbug63111.php on line 20
+
diff --git a/Zend/zend_API..c b/Zend/zend_API.c
index cf96743..d529775 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -2603,7 +2603,14 @@ get_function_via_handler:
if (retval) {
if (fcc->calling_scope && !call_via_handler) {
- if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags &
ZEND_ACC_STATIC)) {
+ if (!fcc->object_ptr && (fcc->function_handler->common.fn_flags &
ZEND_ACC_ABSTRACT)) {
+ if (error) {
+ zend_spprintf(error, 0, "cannot call abstract method %s::%s()",
fcc->calling_scope->name, fcc->function_handler->common.function_name);
+ retval = 0;
+ } else {
+ zend_error(E_ERROR, "Cannot call abstract method %s::%s()",
fcc->calling_scope->name, fcc->function_handler->common.function_name);
+ }
+ } else if (!fcc->object_ptr && !(fcc->function_handler->common.fn_flags &
ZEND_ACC_STATIC)) {
int severity;
char *verb;
if (fcc->function_handler->common.fn_flags & ZEND_ACC_ALLOW_STATIC) {