mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
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.
This commit is contained in:
parent
2d083a3da7
commit
a484b9a535
2
NEWS
2
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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
22
tests/classes/bug75765.phpt
Normal file
22
tests/classes/bug75765.phpt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user