com php-src: Check for old style constructor only if method is not found: Zend/zend_object_handlers.c
| From: | Dmitry Stogov | Date: | Mon, 23 Jan 2017 11:54:58 +0000 |
| Subject: | com php-src: Check for old style constructor only if method is not found: Zend/zend_object_handlers.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96849@lists.php.net to get a copy of this message | ||
Commit: eac0b2e98f58351c8062536d39c36b4d1ac7c9a6
Author: Dmitry Stogov <dmitry@zend.com> Mon, 23 Jan 2017 14:54:58 +0300
Parents: b5cfe11c5b058a44ea8717f6dfad24ea94acd82b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eac0b2e98f58351c8062536d39c36b4d1ac7c9a6
Log:
Check for old style constructor only if method is not found
Changed paths:
M Zend/zend_object_handlers.c
Diff:
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 6e0b9d4..109f442 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1257,21 +1257,19 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce,
zend_st
lc_function_name = zend_string_tolower(function_name);
}
- if (ZSTR_LEN(function_name) == ZSTR_LEN(ce->name) && ce->constructor) {
- lc_class_name = zend_str_tolower_dup(ZSTR_VAL(ce->name), ZSTR_LEN(ce->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, ZSTR_VAL(lc_function_name), ZSTR_LEN(function_name)) &&
memcmp(ZSTR_VAL(ce->constructor->common.function_name), "__", sizeof("__")
- 1)) {
- fbc = ce->constructor;
- }
- efree(lc_class_name);
- }
-
- if (EXPECTED(!fbc)) {
+ do {
zval *func = zend_hash_find(&ce->function_table, lc_function_name);
if (EXPECTED(func != NULL)) {
fbc = Z_FUNC_P(func);
+ } else if (ce->constructor
+ && ZSTR_LEN(lc_function_name) == ZSTR_LEN(ce->name)
+ && zend_binary_strncasecmp(ZSTR_VAL(lc_function_name), ZSTR_LEN(lc_function_name),
ZSTR_VAL(ce->name), ZSTR_LEN(lc_function_name), ZSTR_LEN(lc_function_name)) == 0
+ /* 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
+ */
+ && (ZSTR_VAL(ce->constructor->common.function_name)[0] != '_'
+ || ZSTR_VAL(ce->constructor->common.function_name)[1] != '_')) {
+ fbc = ce->constructor;
} else {
if (UNEXPECTED(!key)) {
zend_string_release(lc_function_name);
@@ -1294,7 +1292,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce,
zend_st
return NULL;
}
}
- }
+ } while (0);
#if MBO_0
/* right now this function is used for non static method lookup too */