com php-src: preserve the orig class name when extending the ErrorException: Zend/tests/exception_020.phpt Zend/ zend_exceptions.c
| From: | Anatol Belski | Date: | Wed, 17 Jun 2015 22:30:16 +0000 |
| Subject: | com php-src: preserve the orig class name when extending the ErrorException: Zend/tests/exception_020.phpt Zend/ zend_exceptions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87348@lists.php.net to get a copy of this message | ||
Commit: 577c1f3e955636ba0d88b79d6fa32ab3a01f1f0d
Author: Anatol Belski <ab@php.net> Thu, 18 Jun 2015 00:30:16 +0200
Parents: 9076eb26c79c518ea5f10b29c4670cd655ae2f5f
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=577c1f3e955636ba0d88b79d6fa32ab3a01f1f0d
Log:
preserve the orig class name when extending the ErrorException
Changed paths:
A Zend/tests/exception_020.phpt
M Zend/zend_exceptions.c
Diff:
diff --git a/Zend/tests/exception_020.phpt b/Zend/tests/exception_020.phpt
new file mode 100644
index 0000000..72a6033
--- /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--
+<?php
+
+class MyErrorException extends ErrorException{}
+throw new MyErrorException(new stdClass);
+
+?>
+--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 0d95064..d6d4fc7 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;
}