]> granicus.if.org Git - php/commitdiff
Report parse errors during preloading
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 3 Nov 2020 15:24:54 +0000 (16:24 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 3 Nov 2020 15:24:54 +0000 (16:24 +0100)
ext/opcache/ZendAccelerator.c
ext/opcache/tests/preload_parse_error.inc [new file with mode: 0644]
ext/opcache/tests/preload_parse_error.phpt [new file with mode: 0644]

index 5f1d80c083322dc7c0998e8b5e334cc15afb306a..4d2fbb71303d6cfe4d673d6857a58b6927da5b08 100644 (file)
@@ -4480,6 +4480,10 @@ static int accel_preload(const char *config, zend_bool in_child)
                        destroy_op_array(op_array);
                        efree_size(op_array, sizeof(zend_op_array));
                } else {
+                       if (EG(exception)) {
+                               zend_exception_error(EG(exception), E_ERROR);
+                       }
+
                        CG(unclean_shutdown) = 1;
                        ret = FAILURE;
                }
diff --git a/ext/opcache/tests/preload_parse_error.inc b/ext/opcache/tests/preload_parse_error.inc
new file mode 100644 (file)
index 0000000..08b9d77
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+parse error
diff --git a/ext/opcache/tests/preload_parse_error.phpt b/ext/opcache/tests/preload_parse_error.phpt
new file mode 100644 (file)
index 0000000..b1ad812
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Parse error in preload script
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.preload={PWD}/preload_parse_error.inc
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
+?>
+--FILE--
+OK
+--EXPECTF--
+Parse error: syntax error, unexpected identifier "error" in %s on line %d