Commit:    f0c926564c5f7de9462d9ca7bd75014b14a63f56
Author:    Nikita Popov <ni...@php.net>         Sun, 29 Sep 2013 17:58:25 +0200
Parents:   d143c2b60f87f5cd221bd070bfde887374b74eb4
Branches:  PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=f0c926564c5f7de9462d9ca7bd75014b14a63f56

Log:
Fix bug #65322: compile time errors won't trigger auto loading

Also fixes duplicate bugs #54054 and #42098.

Furthermore this fixes incorrect error messages thrown from code
running inside an error handler when a compilation is in progress.
The error file and line are now correctly associated with the
file/line of the executor, rather than the compiler.

Bugs:
https://bugs.php.net/65322
https://bugs.php.net/54054
https://bugs.php.net/42098

Changed paths:
  M  NEWS
  A  Zend/tests/bug65322.phpt
  A  Zend/tests/errmsg_045.phpt
  M  Zend/zend.c


Diff:
diff --git a/NEWS b/NEWS
index 37daabb..4dc7ef7 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                             
           NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2013, PHP 5.4.21
 
+- Core:
+  . Fixed bug #65322 (compile time errors won't trigger auto loading). (Nikita)
+
 - CLI server:
   . Fixed bug #65633 (built-in server treat some http headers as
     case-sensitive). (Adam)
diff --git a/Zend/tests/bug65322.phpt b/Zend/tests/bug65322.phpt
new file mode 100644
index 0000000..aab163d
--- /dev/null
+++ b/Zend/tests/bug65322.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #65322: compile time errors won't trigger auto loading
+--FILE--
+<?php
+
+spl_autoload_register(function($class) {
+    var_dump($class);
+    class B {}
+});
+
+set_error_handler(function($_, $msg, $file) {
+    var_dump($msg, $file);
+    new B;
+});
+
+eval('class A { function a() {} function __construct() {} }');
+
+?>
+--EXPECTF--
+string(50) "Redefining already defined constructor for class A"
+string(%d) "%s(%d) : eval()'d code"
+string(1) "B"
diff --git a/Zend/tests/errmsg_045.phpt b/Zend/tests/errmsg_045.phpt
new file mode 100644
index 0000000..b27f67a
--- /dev/null
+++ b/Zend/tests/errmsg_045.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Error message in error handler during compilation
+--FILE--
+<?php
+
+set_error_handler(function($_, $msg, $file) {
+       var_dump($msg, $file);
+       echo $undefined;
+});
+
+eval('class A { function a() {} function __construct() {} }');
+
+?>
+--EXPECTF--
+string(50) "Redefining already defined constructor for class A"
+string(%d) "%s(%d) : eval()'d code"
+
+Notice: Undefined variable: undefined in %s on line %d
diff --git a/Zend/zend.c b/Zend/zend.c
index 1629228..0602c45 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -1183,7 +1183,7 @@ ZEND_API void zend_error(int type, const char *format, 
...) /* {{{ */
                         * such scripts recursivly, but some CG() variables may 
be
                         * inconsistent. */
 
-                       in_compilation = zend_is_compiling(TSRMLS_C);
+                       in_compilation = CG(in_compilation);
                        if (in_compilation) {
                                saved_class_entry = CG(active_class_entry);
                                CG(active_class_entry) = NULL;
@@ -1195,6 +1195,7 @@ ZEND_API void zend_error(int type, const char *format, 
...) /* {{{ */
                                SAVE_STACK(declare_stack);
                                SAVE_STACK(list_stack);
                                SAVE_STACK(context_stack);
+                               CG(in_compilation) = 0;
                        }
 
                        if (call_user_function_ex(CG(function_table), NULL, 
orig_user_error_handler, &retval, 5, params, 1, NULL TSRMLS_CC) == SUCCESS) {
@@ -1219,6 +1220,7 @@ ZEND_API void zend_error(int type, const char *format, 
...) /* {{{ */
                                RESTORE_STACK(declare_stack);
                                RESTORE_STACK(list_stack);
                                RESTORE_STACK(context_stack);
+                               CG(in_compilation) = 1;
                        }
 
                        if (!EG(user_error_handler)) {


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to