mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
- Fixed bug #49908 (throwing exception in __autoload crashes when interface is not defined)
This commit is contained in:
parent
be32cb2268
commit
779ce8fd00
2
NEWS
2
NEWS
@ -16,6 +16,8 @@ PHP NEWS
|
||||
(Pierre)
|
||||
|
||||
- Fixed bug #50023 (pdo_mysql doesn't use PHP_MYSQL_UNIX_SOCK_ADDR). (Ilia)
|
||||
- Fixed bug #49908 (throwing exception in __autoload crashes when interface
|
||||
is not defined). (Felipe)
|
||||
- Fixed bug #49719 (ReflectionClass::hasProperty returns true for a private
|
||||
property in base class). (Felipe)
|
||||
- Fixed bug #49142 (crash when exception thrown from __tostring()).
|
||||
|
28
Zend/tests/bug49908.phpt
Normal file
28
Zend/tests/bug49908.phpt
Normal file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #49908 (throwing exception in __autoload crashes when interface is not defined)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function __autoload($className) {
|
||||
var_dump($className);
|
||||
|
||||
if ($className == 'Foo') {
|
||||
class Foo implements Bar {};
|
||||
} else {
|
||||
throw new Exception($className);
|
||||
}
|
||||
}
|
||||
|
||||
new Foo;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
%unicode|string%(3) "Foo"
|
||||
%unicode|string%(3) "Bar"
|
||||
|
||||
Fatal error: Uncaught exception 'Exception' with message 'Bar' in %s:%d
|
||||
Stack trace:
|
||||
#0 %s(7): __autoload('Bar')
|
||||
#1 %s(13): __autoload('Foo')
|
||||
#2 {main}
|
||||
thrown in %s on line %d
|
@ -4245,12 +4245,13 @@ ZEND_VM_HANDLER(144, ZEND_ADD_INTERFACE, ANY, CONST)
|
||||
zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
|
||||
zend_class_entry *iface = zend_fetch_class(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), opline->extended_value TSRMLS_CC);
|
||||
|
||||
if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
|
||||
zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name);
|
||||
if (iface) {
|
||||
if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
|
||||
zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name);
|
||||
}
|
||||
zend_do_implement_interface(ce, iface TSRMLS_CC);
|
||||
}
|
||||
|
||||
zend_do_implement_interface(ce, iface TSRMLS_CC);
|
||||
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
|
@ -889,12 +889,13 @@ static int ZEND_FASTCALL ZEND_ADD_INTERFACE_SPEC_CONST_HANDLER(ZEND_OPCODE_HAND
|
||||
zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry;
|
||||
zend_class_entry *iface = zend_fetch_class(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant), opline->extended_value TSRMLS_CC);
|
||||
|
||||
if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
|
||||
zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name);
|
||||
if (iface) {
|
||||
if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) {
|
||||
zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name);
|
||||
}
|
||||
zend_do_implement_interface(ce, iface TSRMLS_CC);
|
||||
}
|
||||
|
||||
zend_do_implement_interface(ce, iface TSRMLS_CC);
|
||||
|
||||
ZEND_VM_NEXT_OPCODE();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user