com php-src: Fix #74454: Wrong exception being thrown when using ReflectionMethod: NEWS ext/reflection/php_reflection.c ex
t/reflection/tests/bug74454.inc ext/reflection/te sts/bug74454.phpt

From: Date: Wed, 05 Sep 2018 13:05:19 +0000
Subject: com php-src: Fix #74454: Wrong exception being thrown when using ReflectionMethod: NEWS ext/reflection/php_reflection.c ex
t/reflection/tests/bug74454.inc ext/reflection/te sts/bug74454.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-103005@lists.php.net to get a copy of this message
Commit: c0a389a9277070f5ef53c230f34aa5072a9f0985 Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 5 Sep 2018 15:05:19 +0200 Parents: 0f724453c03b7ff500563c019f5dab736d326ad8 Branches: PHP-7.1 PHP-7.2 PHP-7.3 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c0a389a9277070f5ef53c230f34aa5072a9f0985 Log: Fix #74454: Wrong exception being thrown when using ReflectionMethod If zend_throw_exception_ex() already threw an exception, we should not throw again.. Bugs: https://bugs.php.net/74454 Changed paths: M NEWS M ext/reflection/php_reflection.c A ext/reflection/tests/bug74454.inc A ext/reflection/tests/bug74454.phpt Diff: diff --git a/NEWS b/NEWS index ea1fd8e..50b9d68 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,10 @@ PHP NEWS - POSIX: . Fixed bug #75696 (posix_getgrnam fails to print details of group). (cmb) +- Reflection: + . Fixed bug #74454 (Wrong exception being thrown when using ReflectionMethod). + (cmb) + - Standard: . Fixed bug #73457 (Wrong error message when fopen FTP wrapped fails to open data connection). (Ville Hukkamäki) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 690aaa0..bd2d824 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3130,8 +3130,10 @@ ZEND_METHOD(reflection_method, __construct) switch (Z_TYPE_P(classname)) { case IS_STRING: if ((ce = zend_lookup_class(Z_STR_P(classname))) == NULL) { - zend_throw_exception_ex(reflection_exception_ptr, 0, - "Class %s does not exist", Z_STRVAL_P(classname)); + if (!EG(exception)) { + zend_throw_exception_ex(reflection_exception_ptr, 0, + "Class %s does not exist", Z_STRVAL_P(classname)); + } if (classname == &ztmp) { zval_dtor(&ztmp); } diff --git a/ext/reflection/tests/bug74454.inc b/ext/reflection/tests/bug74454.inc new file mode 100644 index 0000000..5136591 --- /dev/null +++ b/ext/reflection/tests/bug74454.inc @@ -0,0 +1,4 @@ +<?php +class A { + if (wrongsyntax) +} diff --git a/ext/reflection/tests/bug74454.phpt b/ext/reflection/tests/bug74454.phpt new file mode 100644 index 0000000..d2d6e88 --- /dev/null +++ b/ext/reflection/tests/bug74454.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #74454 (Wrong exception being thrown when using ReflectionMethod) +--FILE-- +<?php +spl_autoload_register('load_file'); +try { + $x = new ReflectionMethod('A', 'b'); +} catch (\Throwable $e) { + echo get_class($e), ': ', $e->getMessage(), PHP_EOL; +} + +function load_file() { + require __DIR__ . '/bug74454.inc'; +} +?> +===DONE=== +--EXPECTF-- +ParseError: syntax error, unexpected 'if' (T_IF), expecting function (T_FUNCTION) or const (T_CONST) +===DONE===

« previous php.cvs (#103005) next »