Skip to content

Commit 1d1fb69

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
2 parents f0c1ea1 + f0c9265 commit 1d1fb69

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

Zend/tests/bug65322.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #65322: compile time errors won't trigger auto loading
3+
--FILE--
4+
<?php
5+
6+
spl_autoload_register(function($class) {
7+
var_dump($class);
8+
class B {}
9+
});
10+
11+
set_error_handler(function($_, $msg, $file) {
12+
var_dump($msg, $file);
13+
new B;
14+
});
15+
16+
eval('class A { function a() {} function __construct() {} }');
17+
18+
?>
19+
--EXPECTF--
20+
string(50) "Redefining already defined constructor for class A"
21+
string(%d) "%s(%d) : eval()'d code"
22+
string(1) "B"

Zend/tests/errmsg_045.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Error message in error handler during compilation
3+
--FILE--
4+
<?php
5+
6+
set_error_handler(function($_, $msg, $file) {
7+
var_dump($msg, $file);
8+
echo $undefined;
9+
});
10+
11+
eval('class A { function a() {} function __construct() {} }');
12+
13+
?>
14+
--EXPECTF--
15+
string(50) "Redefining already defined constructor for class A"
16+
string(%d) "%s(%d) : eval()'d code"
17+
18+
Notice: Undefined variable: undefined in %s on line %d

Zend/zend.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
11841184
* such scripts recursivly, but some CG() variables may be
11851185
* inconsistent. */
11861186

1187-
in_compilation = zend_is_compiling(TSRMLS_C);
1187+
in_compilation = CG(in_compilation);
11881188
if (in_compilation) {
11891189
saved_class_entry = CG(active_class_entry);
11901190
CG(active_class_entry) = NULL;
@@ -1196,6 +1196,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
11961196
SAVE_STACK(declare_stack);
11971197
SAVE_STACK(list_stack);
11981198
SAVE_STACK(context_stack);
1199+
CG(in_compilation) = 0;
11991200
}
12001201

12011202
if (call_user_function_ex(CG(function_table), NULL, orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC) == SUCCESS) {
@@ -1220,6 +1221,7 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
12201221
RESTORE_STACK(declare_stack);
12211222
RESTORE_STACK(list_stack);
12221223
RESTORE_STACK(context_stack);
1224+
CG(in_compilation) = 1;
12231225
}
12241226

12251227
if (!EG(user_error_handler)) {

0 commit comments

Comments
 (0)