com php-src: Fixed issue #74 (Allowed per request OPcache disabling): ext/opcache/zend_accelerator_module.c
| From: | Dmitry Stogov | Date: | Wed, 27 Mar 2013 19:13:21 +0000 |
| Subject: | com php-src: Fixed issue #74 (Allowed per request OPcache disabling): ext/opcache/zend_accelerator_module.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-71770@lists.php.net to get a copy of this message | ||
Commit: 1556d5df8ad50a175f8bac0aa4366756bd8904de
Author: Dmitry Stogov <dmitry@zend.com> Wed, 27 Mar 2013 23:13:21 +0400
Parents: 91ab11ed078f0fde6d17f278f7f3705c9fb38805
Branches: PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1556d5df8ad50a175f8bac0aa4366756bd8904de
Log:
Fixed issue #74 (Allowed per request OPcache disabling)
Bugs:
https://bugs.php.net/74
Changed paths:
M ext/opcache/zend_accelerator_module.c
Diff:
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index 0d452ad..8cfab79 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -177,8 +177,37 @@ static ZEND_INI_MH(OnUpdateMaxWastedPercentage)
return SUCCESS;
}
+static ZEND_INI_MH(OnEnable)
+{
+ if (stage == ZEND_INI_STAGE_STARTUP ||
+ stage == ZEND_INI_STAGE_SHUTDOWN ||
+ stage == ZEND_INI_STAGE_DEACTIVATE) {
+ return OnUpdateBool(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage
TSRMLS_CC);
+ } else {
+ /* It may be only temporary disabled */
+ zend_bool *p;
+#ifndef ZTS
+ char *base = (char *) mh_arg2;
+#else
+ char *base = (char *) ts_resource(*((int *) mh_arg2));
+#endif
+
+ p = (zend_bool *) (base+(size_t) mh_arg1);
+ if ((new_value_length == 2 && strcasecmp("on", new_value) == 0) ||
+ (new_value_length == 3 && strcasecmp("yes", new_value) == 0) ||
+ (new_value_length == 4 && strcasecmp("true", new_value) == 0) ||
+ atoi(new_value) != 0) {
+ zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " can't be temporary enabled (it may be
only disabled till the end of request)");
+ return FAILURE;
+ } else {
+ *p = 0;
+ return SUCCESS;
+ }
+ }
+}
+
ZEND_INI_BEGIN()
- STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_SYSTEM,
OnUpdateBool, enabled , zend_accel_globals, accel_globals)
+ STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_ALL,
OnEnable, enabled , zend_accel_globals, accel_globals)
STD_PHP_INI_BOOLEAN("opcache.use_cwd" , "1", PHP_INI_SYSTEM,
OnUpdateBool, accel_directives.use_cwd , zend_accel_globals, accel_globals)
STD_PHP_INI_BOOLEAN("opcache.validate_timestamps", "1", PHP_INI_ALL ,
OnUpdateBool, accel_directives.validate_timestamps, zend_accel_globals, accel_globals)
STD_PHP_INI_BOOLEAN("opcache.inherited_hack" , "1", PHP_INI_SYSTEM,
OnUpdateBool, accel_directives.inherited_hack , zend_accel_globals, accel_globals)