com php-src: Reduce scope of preload compiler_options: ex t/opcache/ZendAccelerator.c
| From: | Nikita Popov | Date: | Tue, 14 Jul 2020 14:10:04 +0000 |
| Subject: | com php-src: Reduce scope of preload compiler_options: ex t/opcache/ZendAccelerator.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-112170@lists.php.net to get a copy of this message | ||
Commit: 27800441b56000f3df51c168ee0d3b51c326d66e
Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 14 Jul 2020 16:10:04 +0200
Parents: b702ad14c958befe6b2e9914959d88fa955d989d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=27800441b56000f3df51c168ee0d3b51c326d66e
Log:
Reduce scope of preload compiler_options
Only set preloading compiler_options while executing the preload
file, not when performing linking afterwards. Otherwise options
like IGNORE_INTERNAL_CLASSES will hide classes from inheritance
verification.
Changed paths:
M ext/opcache/ZendAccelerator.c
Diff:
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 8529a53bdd..120ba00289 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -4451,13 +4451,14 @@ static int preload_autoload(zend_string *filename)
return ret;
}
-static int accel_preload(const char *config)
+static int accel_preload(const char *config, zend_bool in_child)
{
zend_file_handle file_handle;
int ret;
char *orig_open_basedir;
size_t orig_map_ptr_last;
zval *zv;
+ uint32_t orig_compiler_options;
ZCG(enabled) = 0;
ZCG(accelerator_enabled) = 0;
@@ -4474,6 +4475,17 @@ static int accel_preload(const char *config)
preload_scripts = emalloc(sizeof(HashTable));
zend_hash_init(preload_scripts, 0, NULL, NULL, 0);
+ orig_compiler_options = CG(compiler_options);
+ if (in_child) {
+ CG(compiler_options) |= ZEND_COMPILE_PRELOAD_IN_CHILD;
+ }
+ 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;
+ CG(compiler_options) |= ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION;
+ CG(compiler_options) |= ZEND_COMPILE_IGNORE_OTHER_FILES;
+
zend_try {
zend_op_array *op_array;
@@ -4512,6 +4524,7 @@ static int accel_preload(const char *config)
} zend_end_try();
PG(open_basedir) = orig_open_basedir;
+ CG(compiler_options) = orig_compiler_options;
accelerator_orig_compile_file = preload_orig_compile_file;
ZCG(enabled) = 1;
@@ -4809,7 +4822,6 @@ static int accel_finish_startup(void)
char *(*orig_getenv)(const char *name, size_t name_len) = sapi_module.getenv;
size_t (*orig_ub_write)(const char *str, size_t str_length) = sapi_module.ub_write;
void (*orig_flush)(void *server_context) = sapi_module.flush;
- uint32_t orig_compiler_options = CG(compiler_options);
#ifdef ZEND_SIGNALS
zend_bool old_reset_signals = SIGG(reset);
#endif
@@ -4903,16 +4915,6 @@ static int accel_finish_startup(void)
sapi_module.ub_write = preload_ub_write;
sapi_module.flush = preload_flush;
- if (in_child) {
- CG(compiler_options) |= ZEND_COMPILE_PRELOAD_IN_CHILD;
- }
- 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;
- CG(compiler_options) |= ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION;
- CG(compiler_options) |= ZEND_COMPILE_IGNORE_OTHER_FILES;
-
zend_interned_strings_switch_storage(1);
#ifdef ZEND_SIGNALS
@@ -4945,7 +4947,7 @@ static int accel_finish_startup(void)
ZCG(cwd_key_len) = 0;
ZCG(cwd_check) = 1;
- if (accel_preload(ZCG(accel_directives).preload) != SUCCESS) {
+ if (accel_preload(ZCG(accel_directives).preload, in_child) != SUCCESS) {
ret = FAILURE;
}
@@ -4966,8 +4968,6 @@ static int accel_finish_startup(void)
SIGG(reset) = old_reset_signals;
#endif
- CG(compiler_options) = orig_compiler_options;
-
sapi_module.activate = orig_activate;
sapi_module.deactivate = orig_deactivate;
sapi_module.register_server_variables = orig_register_server_variables;