mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Make the check case sensitive, and since we can only have a constructor that matches the class name or is __construct
its probably safe to just check for __. This means we can skip lowering the function_name, which is hard to be binary safe sine we don't store the length. If we just did a zend_hash_exists lookup we'd be fine since its stored lowercased already :)
This commit is contained in:
parent
e64f0795e1
commit
d976be4bda
22
Zend/tests/bug48215_2.phpt
Normal file
22
Zend/tests/bug48215_2.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Bug #48215 - parent::method() calls __construct, case sensitive test
|
||||
--FILE--
|
||||
<?php
|
||||
class a {
|
||||
public function __CONSTRUCT() { echo __METHOD__ . "\n"; }
|
||||
public function a() { echo __METHOD__ . "\n"; }
|
||||
}
|
||||
class b extends a {}
|
||||
class c extends b {
|
||||
function C() {
|
||||
b::b();
|
||||
}
|
||||
}
|
||||
$c = new c();
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
|
||||
Strict Standards: Redefining already defined constructor for class a in %s on line %d
|
||||
|
||||
Fatal error: Call to undefined method b::b() in %s on line %d
|
@ -942,8 +942,10 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, char *f
|
||||
|
||||
if (function_name_strlen == ce->name_length && ce->constructor) {
|
||||
lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length);
|
||||
/* Only change the method to the constructor if a __construct() method doesn't exist */
|
||||
if (!memcmp(lc_class_name, function_name_strval, function_name_strlen) && memcmp(ce->constructor->common.function_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) {
|
||||
/* Only change the method to the constructor if the constructor isn't called __construct
|
||||
* we check for __ so we can be binary safe for lowering, we should use ZEND_CONSTRUCTOR_FUNC_NAME
|
||||
*/
|
||||
if (!memcmp(lc_class_name, function_name_strval, function_name_strlen) && memcmp(ce->constructor->common.function_name, "__", sizeof("__") - 1)) {
|
||||
fbc = ce->constructor;
|
||||
}
|
||||
efree(lc_class_name);
|
||||
|
Loading…
Reference in New Issue
Block a user