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:
Scott MacVicar 2009-06-19 03:29:47 +00:00
parent e64f0795e1
commit d976be4bda
2 changed files with 26 additions and 2 deletions

View 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

View File

@ -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);