com php-src: Don't assume that all includes have been executed: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload_0 07.phpt
ext/opcache/tests/preload_include.inc ext /opcache/tests/preload_include_dummy.inc
| From: | Nikita Popov | Date: | Fri, 15 Feb 2019 16:36:40 +0000 |
| Subject: | com php-src: Don't assume that all includes have been executed: ext/opcache/ZendAccelerator.c ext/opcache/tests/preload_0 07.phpt ext/opcache/tests/preload_include.inc ext /opcache/tests/preload_include_dummy.inc |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-104670@lists.php.net to get a copy of this message | ||
Commit: 970dcd240f4ecd3e19a12f940aa85bbc29c3f146
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 15 Feb 2019 17:36:40 +0100
Parents: 1b31b45f6f731fda7586cbcfd710477f21d85b8c
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=970dcd240f4ecd3e19a12f940aa85bbc29c3f146
Log:
Don't assume that all includes have been executed
Changed paths:
M ext/opcache/ZendAccelerator.c
A ext/opcache/tests/preload_007.phpt
A ext/opcache/tests/preload_include.inc
A ext/opcache/tests/preload_include_dummy.inc
Diff:
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 3214477..d03a8b3 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -3565,7 +3565,7 @@ static void preload_remove_empty_includes(void)
if (resolved_path) {
zend_persistent_script *incl = zend_hash_find_ptr(preload_scripts, resolved_path);
zend_string_release(resolved_path);
- if (!incl->empty) {
+ if (!incl || !incl->empty) {
empty = 0;
break;
}
@@ -3604,7 +3604,7 @@ static void preload_remove_empty_includes(void)
if (resolved_path) {
zend_persistent_script *incl = zend_hash_find_ptr(preload_scripts, resolved_path);
- if (incl->empty) {
+ if (incl && incl->empty) {
MAKE_NOP(opline);
} else {
if (!IS_ABSOLUTE_PATH(Z_STRVAL_P(RT_CONSTANT(opline, opline->op1)),
Z_STRLEN_P(RT_CONSTANT(opline, opline->op1)))) {
diff --git a/ext/opcache/tests/preload_007.phpt b/ext/opcache/tests/preload_007.phpt
new file mode 100644
index 0000000..2054cd8
--- /dev/null
+++ b/ext/opcache/tests/preload_007.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Handling of includes that were not executed
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+opcache.preload={PWD}/preload_include.inc
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+echo "Foobar";
+?>
+--EXPECTF--
+Foobar
diff --git a/ext/opcache/tests/preload_include.inc b/ext/opcache/tests/preload_include.inc
new file mode 100644
index 0000000..95369e7
--- /dev/null
+++ b/ext/opcache/tests/preload_include.inc
@@ -0,0 +1,7 @@
+<?php
+
+$a = 1;
+$b = 2;
+if ($a == $b) {
+ include __DIR__ . "/preload_include_dummy.inc";
+}
diff --git a/ext/opcache/tests/preload_include_dummy.inc
b/ext/opcache/tests/preload_include_dummy.inc
new file mode 100644
index 0000000..8fba097
--- /dev/null
+++ b/ext/opcache/tests/preload_include_dummy.inc
@@ -0,0 +1,3 @@
+<?php
+
+echo "Dummy\n";