]> granicus.if.org Git - php/commitdiff
Fixed bug #74372
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 6 Dec 2017 22:32:39 +0000 (23:32 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 6 Dec 2017 22:36:09 +0000 (23:36 +0100)
NEWS
UPGRADING
ext/spl/php_spl.c
ext/spl/tests/bug74372.phpt [new file with mode: 0644]
ext/spl/tests/spl_autoload_003.phpt
ext/spl/tests/spl_autoload_012.phpt

diff --git a/NEWS b/NEWS
index b67b975e47c0d6365474bb9ef21e49314d5d0b22..ccd359605083d6d600a1a7fce1d5cd8923e80abf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -125,8 +125,10 @@ PHP                                                                        NEWS
 - SPL:
   . Fixed bug #74977 (Appending AppendIterator leads to segfault). 
     (Andrew Nester)
-  . Fixed bug #75173 (incorrect behavior of AppendIterator::append in foreach loop).
-    (jhdxr)
+  . Fixed bug #75173 (incorrect behavior of AppendIterator::append in foreach
+    loop). (jhdxr)
+  . Fixed bug #74372 (autoloading file with syntax error uses next autoloader,
+    may hide parse error). (Nikita)
 
 - SQLite3:
   . Updated bundled libsqlite to 3.21.0. (cmb)
index d19780c5259dbdd99e701fd601efedd9c42a7f7d..64ce1a0cb038d3752aac41e19d6a3ee4bf8e1811 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -31,6 +31,11 @@ BCMath:
   . bcmul() and bcpow() now return numbers with the requested scale. Formerly,
     the returned numbers may have omitted trailing decimal zeroes.
 
+SPL:
+  . If an SPL autoloader throws an exception, following autoloaders will not be
+    executed. Previously all autoloaders were executed and exceptions were
+    chained.
+
 Standard:
   . getimagesize() and related functions now report the mime type of BMP images
          as image/bmp instead of image/x-ms-bmp, since the former has been registered
index 6b1426e70131577c1093188d34d3ec589566da24..fb9f80506bf4de6345bd13cab15b350a0ea0ccb2 100644 (file)
@@ -447,16 +447,18 @@ PHP_FUNCTION(spl_autoload_call)
                        }
 
                        zend_call_function(&fci, &fcic);
-
-                       zend_exception_save();
                        zval_ptr_dtor(&retval);
+
+                       if (EG(exception)) {
+                               break;
+                       }
+
                        if (pos + 1 == SPL_G(autoload_functions)->nNumUsed ||
                            zend_hash_exists(EG(class_table), lc_name)) {
                                break;
                        }
                        zend_hash_move_forward_ex(SPL_G(autoload_functions), &pos);
                }
-               zend_exception_restore();
                zend_string_release(lc_name);
                SPL_G(autoload_running) = l_autoload_running;
        } else {
diff --git a/ext/spl/tests/bug74372.phpt b/ext/spl/tests/bug74372.phpt
new file mode 100644 (file)
index 0000000..161238a
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Bug #74372: autoloading file with syntax error uses next autoloader, may hide parse error
+--FILE--
+<?php
+
+spl_autoload_register(function($class) {
+    eval("ha ha ha");
+});
+spl_autoload_register(function($class) {
+    echo "Don't call me.\n";
+});
+
+new Foo;
+
+?>
+--EXPECTF--
+Parse error: syntax error, unexpected 'ha' (T_STRING) in %s on line %d
index 7c0bd1a02114b2796a2a340e1e4ab0997efbf123..00fdd2734f4b34d8a98cca003a96a8ebfe60cf16 100644 (file)
@@ -40,6 +40,5 @@ catch(Exception $e)
 --EXPECTF--
 TestFunc1(TestClass)
 TestFunc2(TestClass)
-TestFunc3(TestClass)
 Exception: Class TestClass missing
 ===DONE===
index 16389fa4faf1e98cec501c0b836093f7e6ccce96..7b13b7105a16bc476c1a806b6ac0df1cb77bec8e 100644 (file)
@@ -39,15 +39,10 @@ class_exists('ThisClassDoesNotExist');
 ===DONE===
 --EXPECTF--
 autoload_first
-autoload_second
-second
 first
 autoload_first
-autoload_second
-second
 first
 autoload_first
-autoload_second
 
 Fatal error: Uncaught Exception: first in %sspl_autoload_012.php:%d
 Stack trace:
@@ -55,11 +50,4 @@ Stack trace:
 #1 [internal function]: spl_autoload_call('ThisClassDoesNo...')
 #2 %sspl_autoload_012.php(%d): class_exists('ThisClassDoesNo...')
 #3 {main}
-
-Next Exception: second in %sspl_autoload_012.php:%d
-Stack trace:
-#0 [internal function]: autoload_second('ThisClassDoesNo...')
-#1 [internal function]: spl_autoload_call('ThisClassDoesNo...')
-#2 %sspl_autoload_012.php(%d): class_exists('ThisClassDoesNo...')
-#3 {main}
-  thrown in %sspl_autoload_012.php on line %d
+  thrown in %s on line %d