From: Anatol Belski Date: Wed, 17 Jun 2015 22:30:16 +0000 (+0200) Subject: preserve the orig class name when extending the ErrorException X-Git-Tag: php-7.0.0alpha2~2^2~88 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=577c1f3e955636ba0d88b79d6fa32ab3a01f1f0d;p=php preserve the orig class name when extending the ErrorException --- diff --git a/Zend/tests/exception_020.phpt b/Zend/tests/exception_020.phpt new file mode 100644 index 0000000000..72a603325f --- /dev/null +++ b/Zend/tests/exception_020.phpt @@ -0,0 +1,15 @@ +--TEST-- +Testing throw exception doesn't crash with wrong params, variant 2 +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught Error: Wrong parameters for MyErrorException([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]]) in %sexception_020.php:%d +Stack trace: +#0 %sexception_020.php(%d): ErrorException->__construct(Object(stdClass)) +#1 {main} + thrown in %sexception_020.php on line %d diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 0d9506445e..d6d4fc735a 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -282,7 +282,14 @@ ZEND_METHOD(error_exception, __construct) size_t message_len, filename_len; if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|sllslO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, zend_ce_throwable) == FAILURE) { - zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for ErrorException([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]])"); + zend_class_entry *ce; + + if (execute_data->called_scope) { + ce = execute_data->called_scope; + } else { + ce = error_exception_ce; + } + zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for %s([string $message [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Throwable $previous = NULL]]]]]])", ce->name->val); return; }