com php-src: Avoid magic method hash lookups: Zend/zend_excep tions.c ext/intl/calendar/calendar_methods.cpp ext/in tl/timezone/timezone_class.cpp
sapi/phpdbg/phpdbg_promp t.c
| From: | Dmitry Stogov | Date: | Mon, 02 Jul 2018 14:03:50 +0000 |
| Subject: | com php-src: Avoid magic method hash lookups: Zend/zend_excep tions.c ext/intl/calendar/calendar_methods.cpp ext/in tl/timezone/timezone_class.cpp sapi/phpdbg/phpdbg_promp t.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102357@lists.php.net to get a copy of this message | ||
Commit: 091d77f28a78a700ce0e72457606e01ed696de83
Author: Dmitry Stogov <dmitry@zend.com> Mon, 2 Jul 2018 17:03:50 +0300
Parents: 43aca3118ab011b878ec577904eafc18f86f69ae
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=091d77f28a78a700ce0e72457606e01ed696de83
Log:
Avoid magic method hash lookups
Changed paths:
M Zend/zend_exceptions.c
M ext/intl/calendar/calendar_methods.cpp
M ext/intl/timezone/timezone_class.cpp
M sapi/phpdbg/phpdbg_prompt.c
Diff:
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 72a3c80..81ee386 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -984,7 +984,7 @@ ZEND_API ZEND_COLD void zend_exception_error(zend_object *ex, int severity) /* {
zend_string *str, *file = NULL;
zend_long line = 0;
- zend_call_method_with_0_params(&exception, ce_exception, NULL, "__tostring",
&tmp);
+ zend_call_method_with_0_params(&exception, ce_exception, &ex->ce->__tostring,
"__tostring", &tmp);
if (!EG(exception)) {
if (Z_TYPE(tmp) != IS_STRING) {
zend_error(E_WARNING, "%s::__toString() must return a string",
ZSTR_VAL(ce_exception->name));
diff --git a/ext/intl/calendar/calendar_methods.cpp b/ext/intl/calendar/calendar_methods.cpp
index 8c6aaed..f5e0daf 100644
--- a/ext/intl/calendar/calendar_methods.cpp
+++ b/ext/intl/calendar/calendar_methods.cpp
@@ -1141,7 +1141,7 @@ U_CFUNC PHP_FUNCTION(intlcal_from_date_time)
if (!(Z_TYPE_P(zv_arg) == IS_OBJECT && instanceof_function(
Z_OBJCE_P(zv_arg), php_date_get_date_ce()))) {
object_init_ex(&zv_tmp, php_date_get_date_ce());
- zend_call_method_with_1_params(&zv_tmp, NULL, NULL, "__construct", NULL, zv_arg);
+ zend_call_method_with_1_params(&zv_tmp, NULL, &Z_OBJCE(zv_tmp)->constructor,
"__construct", NULL, zv_arg);
zv_datetime = &zv_tmp;
if (EG(exception)) {
zend_object_store_ctor_failed(Z_OBJ(zv_tmp));
@@ -1257,7 +1257,7 @@ U_CFUNC PHP_FUNCTION(intlcal_to_date_time)
/* Finally, instantiate object and call constructor */
object_init_ex(return_value, php_date_get_date_ce());
- zend_call_method_with_2_params(return_value, NULL, NULL, "__construct", NULL,
&ts_zval, timezone_zval);
+ zend_call_method_with_2_params(return_value, NULL, &Z_OBJCE_P(return_value)->constructor,
"__construct", NULL, &ts_zval, timezone_zval);
if (EG(exception)) {
intl_errors_set(CALENDAR_ERROR_P(co), U_ILLEGAL_ARGUMENT_ERROR,
"intlcal_to_date_time: DateTime constructor has thrown exception",
diff --git a/ext/intl/timezone/timezone_class.cpp b/ext/intl/timezone/timezone_class.cpp
index 2bf8c99..929797a 100644
--- a/ext/intl/timezone/timezone_class.cpp
+++ b/ext/intl/timezone/timezone_class.cpp
@@ -98,7 +98,7 @@ U_CFUNC zval *timezone_convert_to_datetimezone(const TimeZone *timeZone,
goto error;
}
ZVAL_STR(&arg, u8str);
- zend_call_method_with_1_params(ret, NULL, NULL, "__construct", NULL, &arg);
+ zend_call_method_with_1_params(ret, NULL, &Z_OBJCE_P(ret)->constructor,
"__construct", NULL, &arg);
if (EG(exception)) {
spprintf(&message, 0,
"%s: DateTimeZone constructor threw exception", func);
diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c
index 2202884..067ae73 100644
--- a/sapi/phpdbg/phpdbg_prompt.c
+++ b/sapi/phpdbg/phpdbg_prompt.c
@@ -775,7 +775,7 @@ static inline void phpdbg_handle_exception(void) /* {{{ */
EG(exception) = NULL;
ZVAL_OBJ(&zv, ex);
- zend_call_method_with_0_params(&zv, ex->ce, NULL, "__tostring", &tmp);
+ zend_call_method_with_0_params(&zv, ex->ce, &ex->ce->__tostring,
"__tostring", &tmp);
file = zval_get_string(zend_read_property(zend_get_exception_base(&zv), &zv,
ZEND_STRL("file"), 1, &rv));
line = zval_get_long(zend_read_property(zend_get_exception_base(&zv), &zv,
ZEND_STRL("line"), 1, &rv));