com php-src: Fix #75765 Exception on extend of undefined class: NEWS Zend/zend_compile.c ext/spl/tests/bug73423.ph pt tests/classes/autoload_011.phpt
tests/classes/ bug75765.phpt
| From: | Nikita Popov | Date: | Fri, 12 Jan 2018 17:41:39 +0000 |
| Subject: | com php-src: Fix #75765 Exception on extend of undefined class: NEWS Zend/zend_compile.c ext/spl/tests/bug73423.ph pt tests/classes/autoload_011.phpt tests/classes/ bug75765.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100858@lists.php.net to get a copy of this message | ||
Commit: a484b9a5359bd8252234c3965a6fb7f1a1a98b4a
Author: timurib <timok@ya.ru> Sat, 6 Jan 2018 23:04:45 +0300
Committer: Nikita Popov <nikita.ppv@gmail.com> Fri, 12 Jan 2018 18:41:39 +0100
Parents: 2d083a3da7e033ee049f4570d13d98c38444cb97
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a484b9a5359bd8252234c3965a6fb7f1a1a98b4a
Log:
Fix #75765 Exception on extend of undefined class
As the parent class is fetched prior to binding, there are no
safety concerns in this case and we can replace the fatal error
with an Error exception.
Bugs:
https://bugs.php.net/75765
Changed paths:
M NEWS
M Zend/zend_compile.c
M ext/spl/tests/bug73423.phpt
M tests/classes/autoload_011.phpt
A tests/classes/bug75765.phpt
Diff:
diff --git a/NEWS b/NEWS
index e8fc786..6dad612 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,8 @@ PHP NEWS
(Nikita)
. Fixed bug #73108 (Internal class cast handler uses integer instead of
float). (Nikita)
+ . Fixed bug #75765 (Fatal error instead of Error exception when base class is
+ not found). (Timur Ibragimov)
- BCMath:
. Fixed bug #66364 (BCMath bcmul ignores scale parameter). (cmb)
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index dbabfb3...0beadac 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -6387,7 +6387,7 @@ void zend_compile_class_decl(zend_ast *ast) /* {{{ */
"Cannot use '%s' as class name as it is reserved", ZSTR_VAL(extends_name));
}
- zend_compile_class_ref(&extends_node, extends_ast, 0);
+ zend_compile_class_ref(&extends_node, extends_ast, 1);
ce->ce_flags |= ZEND_ACC_INHERITED;
}
diff --git a/ext/spl/tests/bug73423.phpt b/ext/spl/tests/bug73423.phpt
index 58e1acb..965b633 100644
--- a/ext/spl/tests/bug73423.phpt
+++ b/ext/spl/tests/bug73423.phpt
@@ -68,4 +68,15 @@ foreach (new \RecursiveIteratorIterator (new fooIterator ($foo)) as $bar) ;
?>
--EXPECTF--
-Fatal error: Class 'NotExists' not found in %sbug73423.php(%d) : eval()'d code on
line 1
+Fatal error: Uncaught Error: Class 'NotExists' not found in %sbug73423.php(%d) :
eval()'d code:1
+Stack trace:
+#0 %sbug73423.php(%d): eval()
+#1 %sbug73423.php(%d): fooIterator->__destruct()
+#2 {main}
+
+Next Error: Class 'NotExists' not found in %sbug73423.php(%d) : eval()'d code:1
+Stack trace:
+#0 %sbug73423.php(%d): eval()
+#1 %sbug73423.php(%d): fooIterator->__destruct()
+#2 {main}
+ thrown in %sbug73423.php(%d) : eval()'d code on line 1
diff --git a/tests/classes/autoload_011.phpt b/tests/classes/autoload_011.phpt
index aaea38c..630cbf3 100644
--- a/tests/classes/autoload_011.phpt
+++ b/tests/classes/autoload_011..phpt
@@ -14,4 +14,7 @@ class C extends UndefBase
--EXPECTF--
In autoload: string(9) "UndefBase"
-Fatal error: Class 'UndefBase' not found in %s on line %d
+Fatal error: Uncaught Error: Class 'UndefBase' not found in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %sautoload_011.php on line %d
diff --git a/tests/classes/bug75765.phpt b/tests/classes/bug75765.phpt
new file mode 100644
index 0000000..d24f62d
--- /dev/null
+++ b/tests/classes/bug75765.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Ensure that extending of undefined class throws the exception
+--FILE--
+<?php
+
+try {
+ class A extends B {}
+} catch (Error $e) {
+ var_dump(class_exists('A'));
+ var_dump(class_exists('B'));
+ throw $e;
+}
+
+?>
+--EXPECTF--
+bool(false)
+bool(false)
+
+Fatal error: Uncaught Error: Class 'B' not found in %sbug75765.php:%d
+Stack trace:
+#0 {main}
+ thrown in %sbug75765.php on line %d