From 0a00d292569a8fbd2d5c96c9d141b23ae916f00b Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 25 Mar 2013 13:05:16 +0400 Subject: [PATCH] Fixed bug #64482 (Opcodes for dynamic includes should not be cached) --- ext/opcache/ZendAccelerator.c | 10 +++++++++- ext/opcache/tests/bug64482.inc | 2 ++ ext/opcache/tests/bug64482.phpt | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 ext/opcache/tests/bug64482.inc create mode 100644 ext/opcache/tests/bug64482.phpt diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 9d1fdce1b5..bfe9d67fcb 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -134,6 +134,12 @@ static inline int is_stream_path(const char *filename) return ((*p == ':') && (p - filename > 1) && (p[1] == '/') && (p[2] == '/')); } +static inline int is_cachable_stream_path(const char *filename) +{ + return memcmp(filename, "file://", sizeof("file://") - 1) == 0 || + memcmp(filename, "phar://", sizeof("file://") - 1) == 0; +} + /* O+ overrides PHP chdir() function and remembers the current working directory * in ZCG(cwd) and ZCG(cwd_len). Later accel_getcwd() can use stored value and * avoid getcwd() call. @@ -1373,7 +1379,9 @@ static zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int !ZCG(enabled) || !accel_startup_ok || (!ZCG(counted) && !ZCSG(accelerator_enabled)) || CG(interactive) || - (ZCSG(restart_in_progress) && accel_restart_is_active(TSRMLS_C))) { + (ZCSG(restart_in_progress) && accel_restart_is_active(TSRMLS_C)) || + (is_stream_path(file_handle->filename) && + !is_cachable_stream_path(file_handle->filename))) { /* The Accelerator is disabled, act as if without the Accelerator */ return accelerator_orig_compile_file(file_handle, type TSRMLS_CC); } diff --git a/ext/opcache/tests/bug64482.inc b/ext/opcache/tests/bug64482.inc new file mode 100644 index 0000000000..e3d2b210c5 --- /dev/null +++ b/ext/opcache/tests/bug64482.inc @@ -0,0 +1,2 @@ + +--FILE-- + +--EXPECT-- +Dynamic include +DYNAMIC INCLUDE -- 2.40.0