1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Don't assume that all includes have been executed

This commit is contained in:
Nikita Popov
2019-02-15 17:36:40 +01:00
parent 1b31b45f6f
commit 970dcd240f
4 changed files with 27 additions and 2 deletions

View File

@@ -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)))) {

View File

@@ -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

View File

@@ -0,0 +1,7 @@
<?php
$a = 1;
$b = 2;
if ($a == $b) {
include __DIR__ . "/preload_include_dummy.inc";
}

View File

@@ -0,0 +1,3 @@
<?php
echo "Dummy\n";