Skip to content

Commit 4ee7bbd

Browse files
committed
Merge branch 'PHP-5.5'
* PHP-5.5: Fixed issue #74 (Allowed per request OPcache disabling)
2 parents 36861bf + 1556d5d commit 4ee7bbd

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

ext/opcache/zend_accelerator_module.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,37 @@ static ZEND_INI_MH(OnUpdateMaxWastedPercentage)
177177
return SUCCESS;
178178
}
179179

180+
static ZEND_INI_MH(OnEnable)
181+
{
182+
if (stage == ZEND_INI_STAGE_STARTUP ||
183+
stage == ZEND_INI_STAGE_SHUTDOWN ||
184+
stage == ZEND_INI_STAGE_DEACTIVATE) {
185+
return OnUpdateBool(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
186+
} else {
187+
/* It may be only temporary disabled */
188+
zend_bool *p;
189+
#ifndef ZTS
190+
char *base = (char *) mh_arg2;
191+
#else
192+
char *base = (char *) ts_resource(*((int *) mh_arg2));
193+
#endif
194+
195+
p = (zend_bool *) (base+(size_t) mh_arg1);
196+
if ((new_value_length == 2 && strcasecmp("on", new_value) == 0) ||
197+
(new_value_length == 3 && strcasecmp("yes", new_value) == 0) ||
198+
(new_value_length == 4 && strcasecmp("true", new_value) == 0) ||
199+
atoi(new_value) != 0) {
200+
zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " can't be temporary enabled (it may be only disabled till the end of request)");
201+
return FAILURE;
202+
} else {
203+
*p = 0;
204+
return SUCCESS;
205+
}
206+
}
207+
}
208+
180209
ZEND_INI_BEGIN()
181-
STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_SYSTEM, OnUpdateBool, enabled , zend_accel_globals, accel_globals)
210+
STD_PHP_INI_BOOLEAN("opcache.enable" , "1", PHP_INI_ALL, OnEnable, enabled , zend_accel_globals, accel_globals)
182211
STD_PHP_INI_BOOLEAN("opcache.use_cwd" , "1", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.use_cwd , zend_accel_globals, accel_globals)
183212
STD_PHP_INI_BOOLEAN("opcache.validate_timestamps", "1", PHP_INI_ALL , OnUpdateBool, accel_directives.validate_timestamps, zend_accel_globals, accel_globals)
184213
STD_PHP_INI_BOOLEAN("opcache.inherited_hack" , "1", PHP_INI_SYSTEM, OnUpdateBool, accel_directives.inherited_hack , zend_accel_globals, accel_globals)

0 commit comments

Comments
 (0)