]> granicus.if.org Git - php/commitdiff
Fixed bug #64482 (Opcodes for dynamic includes should not be cached)
authorDmitry Stogov <dmitry@zend.com>
Mon, 25 Mar 2013 09:05:16 +0000 (13:05 +0400)
committerDmitry Stogov <dmitry@zend.com>
Mon, 25 Mar 2013 09:05:16 +0000 (13:05 +0400)
ext/opcache/ZendAccelerator.c
ext/opcache/tests/bug64482.inc [new file with mode: 0644]
ext/opcache/tests/bug64482.phpt [new file with mode: 0644]

index 9d1fdce1b57acca1747894225ad3ecce9dabd5fe..bfe9d67fcbfc63ec2d7372c33397f7f07bbdfdf2 100644 (file)
@@ -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 (file)
index 0000000..e3d2b21
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+echo "Dynamic include";
diff --git a/ext/opcache/tests/bug64482.phpt b/ext/opcache/tests/bug64482.phpt
new file mode 100644 (file)
index 0000000..fa722f6
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Bug #64482 (Opcodes for dynamic includes should not be cached)
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php 
+include 'bug64482.inc';
+echo "\n";
+include 'php://filter/read=string.toupper/resource=bug64482.inc';
+echo "\n";
+?>
+--EXPECT--
+Dynamic include
+DYNAMIC INCLUDE