diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index b1ab5b3273b..967ac9100e6 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -1042,6 +1042,12 @@ END_EXTERN_C() /* ignore functions and classes declared in other files */ #define ZEND_COMPILE_IGNORE_OTHER_FILES (1<<12) +/* this flag is set when compiler invoked by opcache_compile_file() */ +#define ZEND_COMPILE_WITHOUT_EXECUTION (1<<13) + +/* this flag is set when compiler invoked during preloading */ +#define ZEND_COMPILE_PRELOAD (1<<14) + /* The default value for CG(compiler_options) */ #define ZEND_COMPILE_DEFAULT ZEND_COMPILE_HANDLE_OP_ARRAY diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 7b9fcb9fd95..e4fae4ba4c6 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3749,6 +3749,7 @@ static int accel_preload(const char *config) accelerator_orig_compile_file = preload_compile_file; orig_compiler_options = CG(compiler_options); + CG(compiler_options) |= ZEND_COMPILE_PRELOAD; CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY; // CG(compiler_options) |= ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; CG(compiler_options) |= ZEND_COMPILE_DELAYED_BINDING; diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 7a1f46653c0..899fddc3f38 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -844,6 +844,7 @@ static ZEND_FUNCTION(opcache_compile_file) zend_file_handle handle; zend_op_array *op_array = NULL; zend_execute_data *orig_execute_data = NULL; + uint32_t orig_compiler_options; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &script_name, &script_name_len) == FAILURE) { return; @@ -855,6 +856,8 @@ static ZEND_FUNCTION(opcache_compile_file) handle.type = ZEND_HANDLE_FILENAME; orig_execute_data = EG(current_execute_data); + orig_compiler_options = CG(compiler_options); + CG(compiler_options) |= ZEND_COMPILE_WITHOUT_EXECUTION; zend_try { op_array = persistent_compile_file(&handle, ZEND_INCLUDE); @@ -863,6 +866,8 @@ static ZEND_FUNCTION(opcache_compile_file) zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " could not compile file %s", handle.filename); } zend_end_try(); + CG(compiler_options) = orig_compiler_options; + if(op_array != NULL) { destroy_op_array(op_array); efree(op_array);