Skip to content

Commit da6465a

Browse files
committed
Fixed bug #61761 ('Overriding' a private static method with a different signature causes crash)
1 parent d55afe4 commit da6465a

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

NEWS

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
$_SERVER['SCRIPT_FILENAME'] when using router). (Laruence)
99
. "Connection: close" instead of "Connection: closed" (Gustavo)
1010

11+
- Core:
12+
. Fixed bug #61761 ('Overriding' a private static method with a different
13+
signature causes crash). (Laruence)
14+
1115
- JSON
1216
. Fixed bug #61537 (json_encode() incorrectly truncates/discards
1317
information). (Adam)
@@ -17,7 +21,8 @@ PHP NEWS
1721
(merge after 5.3.11 release)
1822

1923
- Core:
20-
. Fixed bug #61728 (PHP crash when calling ob_start in request_shutdown phase). (Laruence)
24+
. Fixed bug #61728 (PHP crash when calling ob_start in request_shutdown
25+
phase). (Laruence)
2126
. Fixed bug #61660 (bin2hex(hex2bin($data)) != $data). (Nikita Popov)
2227
. Fixed bug #61650 (ini parser crashes when using ${xxxx} ini variables
2328
(without apache2)). (Laruence)

Zend/tests/bug61761.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug #61761 ('Overriding' a private static method with a different signature causes crash)
3+
--FILE--
4+
<?php
5+
6+
class A
7+
{
8+
private static function test($a) { }
9+
}
10+
11+
class B extends A
12+
{
13+
private static function test($a, $b) { }
14+
}
15+
16+
?>
17+
--EXPECTF--
18+
Strict Standards: Declaration of B::test() should be compatible with A::test($a) in %sbug61761.php on line %d

Zend/zend_compile.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3260,11 +3260,11 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function *
32603260

32613261
if (child->common.prototype && (child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT)) {
32623262
if (!zend_do_perform_implementation_check(child, child->common.prototype TSRMLS_CC)) {
3263-
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_get_function_declaration(child->common.prototype TSRMLS_CC));
3263+
zend_error(E_COMPILE_ERROR, "Declaration of %s::%s() must be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, zend_get_function_declaration(child->common.prototype? child->common.prototype : parent TSRMLS_CC));
32643264
}
32653265
} else if (EG(error_reporting) & E_STRICT || EG(user_error_handler)) { /* Check E_STRICT (or custom error handler) before the check so that we save some time */
32663266
if (!zend_do_perform_implementation_check(child, parent TSRMLS_CC)) {
3267-
char *method_prototype = zend_get_function_declaration(child->common.prototype TSRMLS_CC);
3267+
char *method_prototype = zend_get_function_declaration(child->common.prototype? child->common.prototype : parent TSRMLS_CC);
32683268
zend_error(E_STRICT, "Declaration of %s::%s() should be compatible with %s", ZEND_FN_SCOPE_NAME(child), child->common.function_name, method_prototype);
32693269
efree(method_prototype);
32703270
}

0 commit comments

Comments
 (0)