Skip to content

Commit 7580815

Browse files
committed
Merge branch 'PHP-5.5'
Conflicts: Zend/zend_vm_execute.h
2 parents b64e221 + e20fc85 commit 7580815

File tree

3 files changed

+146
-71
lines changed

3 files changed

+146
-71
lines changed

Zend/tests/bug65254.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #65254 (Exception not catchable when exception thrown in autoload with a namespace)
3+
--FILE--
4+
<?php
5+
function __autoload($class)
6+
{
7+
eval("namespace ns_test; class test {}");
8+
9+
throw new \Exception('abcd');
10+
}
11+
12+
try
13+
{
14+
\ns_test\test::go();
15+
}
16+
catch (Exception $e)
17+
{
18+
echo 'caught';
19+
}
20+
--EXPECT--
21+
caught

Zend/zend_vm_def.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2519,9 +2519,11 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS
25192519
ce = CACHED_PTR(opline->op1.literal->cache_slot);
25202520
} else {
25212521
ce = zend_fetch_class_by_name(Z_STRVAL_P(opline->op1.zv), Z_STRLEN_P(opline->op1.zv), opline->op1.literal + 1, opline->extended_value TSRMLS_CC);
2522+
if (UNEXPECTED(EG(exception) != NULL)) {
2523+
HANDLE_EXCEPTION();
2524+
}
25222525
if (UNEXPECTED(ce == NULL)) {
2523-
CHECK_EXCEPTION();
2524-
ZEND_VM_NEXT_OPCODE();
2526+
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op1.zv));
25252527
}
25262528
CACHE_PTR(opline->op1.literal->cache_slot, ce);
25272529
}
@@ -3532,9 +3534,11 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
35323534
ce = CACHED_PTR(opline->op1.literal->cache_slot);
35333535
} else {
35343536
ce = zend_fetch_class_by_name(Z_STRVAL_P(opline->op1.zv), Z_STRLEN_P(opline->op1.zv), opline->op1.literal + 1, opline->extended_value TSRMLS_CC);
3537+
if (UNEXPECTED(EG(exception) != NULL)) {
3538+
HANDLE_EXCEPTION();
3539+
}
35353540
if (UNEXPECTED(ce == NULL)) {
3536-
CHECK_EXCEPTION();
3537-
ZEND_VM_NEXT_OPCODE();
3541+
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op1.zv));
35383542
}
35393543
CACHE_PTR(opline->op1.literal->cache_slot, ce);
35403544
}
@@ -3911,15 +3915,17 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
39113915
ce = CACHED_PTR(opline->op2.literal->cache_slot);
39123916
} else {
39133917
ce = zend_fetch_class_by_name(Z_STRVAL_P(opline->op2.zv), Z_STRLEN_P(opline->op2.zv), opline->op2.literal + 1, 0 TSRMLS_CC);
3914-
if (UNEXPECTED(ce == NULL)) {
3918+
if (UNEXPECTED(EG(exception) != NULL)) {
39153919
if (OP1_TYPE != IS_CONST && varname == &tmp) {
39163920
zval_dtor(&tmp);
39173921
} else if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
39183922
zval_ptr_dtor(&varname);
39193923
}
39203924
FREE_OP1();
3921-
CHECK_EXCEPTION();
3922-
ZEND_VM_NEXT_OPCODE();
3925+
HANDLE_EXCEPTION();
3926+
}
3927+
if (UNEXPECTED(ce == NULL)) {
3928+
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op2.zv));
39233929
}
39243930
CACHE_PTR(opline->op2.literal->cache_slot, ce);
39253931
}

0 commit comments

Comments
 (0)