Skip to content

Commit 0a00d29

Browse files
committed
Fixed bug #64482 (Opcodes for dynamic includes should not be cached)
1 parent 64b029a commit 0a00d29

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ static inline int is_stream_path(const char *filename)
134134
return ((*p == ':') && (p - filename > 1) && (p[1] == '/') && (p[2] == '/'));
135135
}
136136

137+
static inline int is_cachable_stream_path(const char *filename)
138+
{
139+
return memcmp(filename, "file://", sizeof("file://") - 1) == 0 ||
140+
memcmp(filename, "phar://", sizeof("file://") - 1) == 0;
141+
}
142+
137143
/* O+ overrides PHP chdir() function and remembers the current working directory
138144
* in ZCG(cwd) and ZCG(cwd_len). Later accel_getcwd() can use stored value and
139145
* avoid getcwd() call.
@@ -1373,7 +1379,9 @@ static zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int
13731379
!ZCG(enabled) || !accel_startup_ok ||
13741380
(!ZCG(counted) && !ZCSG(accelerator_enabled)) ||
13751381
CG(interactive) ||
1376-
(ZCSG(restart_in_progress) && accel_restart_is_active(TSRMLS_C))) {
1382+
(ZCSG(restart_in_progress) && accel_restart_is_active(TSRMLS_C)) ||
1383+
(is_stream_path(file_handle->filename) &&
1384+
!is_cachable_stream_path(file_handle->filename))) {
13771385
/* The Accelerator is disabled, act as if without the Accelerator */
13781386
return accelerator_orig_compile_file(file_handle, type TSRMLS_CC);
13791387
}

ext/opcache/tests/bug64482.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?php
2+
echo "Dynamic include";

ext/opcache/tests/bug64482.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #64482 (Opcodes for dynamic includes should not be cached)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
--SKIPIF--
7+
<?php require_once('skipif.inc'); ?>
8+
--FILE--
9+
<?php
10+
include 'bug64482.inc';
11+
echo "\n";
12+
include 'php://filter/read=string.toupper/resource=bug64482.inc';
13+
echo "\n";
14+
?>
15+
--EXPECT--
16+
Dynamic include
17+
DYNAMIC INCLUDE

0 commit comments

Comments
 (0)