Skip to content

Commit 2c4f823

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
Conflicts: Zend/zend_vm_def.h Zend/zend_vm_execute.h
2 parents efc8936 + ebad517 commit 2c4f823

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
@@ -2517,9 +2517,11 @@ ZEND_VM_HANDLER(113, ZEND_INIT_STATIC_METHOD_CALL, CONST|VAR, CONST|TMP|VAR|UNUS
25172517
ce = CACHED_PTR(opline->op1.literal->cache_slot);
25182518
} else {
25192519
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);
2520+
if (UNEXPECTED(EG(exception) != NULL)) {
2521+
HANDLE_EXCEPTION();
2522+
}
25202523
if (UNEXPECTED(ce == NULL)) {
2521-
CHECK_EXCEPTION();
2522-
ZEND_VM_NEXT_OPCODE();
2524+
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op1.zv));
25232525
}
25242526
CACHE_PTR(opline->op1.literal->cache_slot, ce);
25252527
}
@@ -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
}
@@ -3912,15 +3916,17 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
39123916
ce = CACHED_PTR(opline->op2.literal->cache_slot);
39133917
} else {
39143918
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);
3915-
if (UNEXPECTED(ce == NULL)) {
3919+
if (UNEXPECTED(EG(exception) != NULL)) {
39163920
if (OP1_TYPE != IS_CONST && varname == &tmp) {
39173921
zval_dtor(&tmp);
39183922
} else if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
39193923
zval_ptr_dtor(&varname);
39203924
}
39213925
FREE_OP1();
3922-
CHECK_EXCEPTION();
3923-
ZEND_VM_NEXT_OPCODE();
3926+
HANDLE_EXCEPTION();
3927+
}
3928+
if (UNEXPECTED(ce == NULL)) {
3929+
zend_error_noreturn(E_ERROR, "Class '%s' not found", Z_STRVAL_P(opline->op2.zv));
39243930
}
39253931
CACHE_PTR(opline->op2.literal->cache_slot, ce);
39263932
}

0 commit comments

Comments
 (0)