Skip to content

Commit eac3998

Browse files
committed
Change from opcache.no_cache=1 to opcache.allow_cache=0
1 parent 2d75134 commit eac3998

File tree

6 files changed

+41
-39
lines changed

6 files changed

+41
-39
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ zend_bool accel_startup_ok = 0;
114114
static char *zps_failure_reason = NULL;
115115
char *zps_api_failure_reason = NULL;
116116
zend_bool file_cache_only = 0; /* process uses file cache only */
117-
zend_bool no_cache = 0; /* process does not use any cache (takes precedence over file_cache_only) */
117+
zend_bool allow_cache = 1; /* process does not use any cache (takes precedence over file_cache_only) */
118118
#if ENABLE_FILE_CACHE_FALLBACK
119119
zend_bool fallback_process = 0; /* process uses file cache fallback */
120120
#endif
@@ -470,7 +470,7 @@ zend_string* ZEND_FASTCALL accel_new_interned_string(zend_string *str)
470470
uint32_t pos, *hash_slot;
471471
zend_string *s;
472472

473-
if (UNEXPECTED(file_cache_only || no_cache)) {
473+
if (UNEXPECTED(file_cache_only || !allow_cache)) {
474474
return str;
475475
}
476476

@@ -1952,7 +1952,7 @@ zend_op_array *file_cache_compile_file(zend_file_handle *file_handle, int type)
19521952
zend_op_array *no_cache_compile_file(zend_file_handle *file_handle, int type)
19531953
{
19541954
zend_op_array *op_array = NULL;
1955-
zend_persistent_script *persistent_script; // not actually persistent with opcache.no_cache.
1955+
zend_persistent_script *persistent_script; // not actually persistent with opcache.allow_cache=0.
19561956

19571957
if (is_stream_path(file_handle->filename) &&
19581958
!is_cacheable_stream_path(file_handle->filename)) {
@@ -2007,14 +2007,14 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type)
20072007
ZCG(cache_persistent_script) = NULL;
20082008
if (file_handle->filename
20092009
&& ZCG(enabled) && accel_startup_ok) {
2010-
if (no_cache) {
2010+
if (!allow_cache) {
20112011
return no_cache_compile_file(file_handle, type);
20122012
} else if (ZCG(accel_directives).file_cache) {
20132013
return file_cache_compile_file(file_handle, type);
20142014
}
20152015
}
20162016
return accelerator_orig_compile_file(file_handle, type);
2017-
} else if (no_cache) {
2017+
} else if (!allow_cache) {
20182018
// TODO: Why is opcache_get_status using accelerator_enabled instead of enabled?
20192019
ZCG(cache_opline) = NULL;
20202020
ZCG(cache_persistent_script) = NULL;
@@ -2344,7 +2344,7 @@ static int persistent_stream_open_function(const char *filename, zend_file_handl
23442344
/* zend_resolve_path() replacement for PHP 5.3 and above */
23452345
static zend_string* persistent_zend_resolve_path(const char *filename, size_t filename_len)
23462346
{
2347-
if (!file_cache_only && !no_cache &&
2347+
if (!file_cache_only && allow_cache &&
23482348
ZCG(accelerator_enabled)) {
23492349

23502350
/* check if callback is called from include_once or it's a main request */
@@ -2468,7 +2468,7 @@ int accel_activate(INIT_FUNC_ARGS)
24682468
ZCG(cwd_key_len) = 0;
24692469
ZCG(cwd_check) = 1;
24702470

2471-
if (file_cache_only || no_cache) {
2471+
if (file_cache_only || !allow_cache) {
24722472
ZCG(accelerator_enabled) = 0;
24732473
return SUCCESS;
24742474
}
@@ -3028,8 +3028,8 @@ static int accel_post_startup(void)
30283028
/* End of non-SHM dependent initializations */
30293029
/********************************************/
30303030
file_cache_only = ZCG(accel_directives).file_cache_only;
3031-
no_cache = ZCG(accel_directives).no_cache;
3032-
if (!file_cache_only && !no_cache) {
3031+
allow_cache = ZCG(accel_directives).allow_cache;
3032+
if (!file_cache_only && allow_cache) {
30333033
size_t shm_size = ZCG(accel_directives).memory_consumption;
30343034
#ifdef HAVE_JIT
30353035
size_t jit_size = 0;
@@ -3181,7 +3181,7 @@ static int accel_post_startup(void)
31813181

31823182
zend_optimizer_startup();
31833183

3184-
if (!file_cache_only && !no_cache && ZCG(accel_directives).interned_strings_buffer) {
3184+
if (!file_cache_only && allow_cache && ZCG(accel_directives).interned_strings_buffer) {
31853185
accel_use_shm_interned_strings();
31863186
}
31873187

@@ -3199,7 +3199,7 @@ void accel_shutdown(void)
31993199
{
32003200
zend_ini_entry *ini_entry;
32013201
zend_bool _file_cache_only = 0;
3202-
zend_bool _no_cache = 0;
3202+
zend_bool _allow_cache = 1;
32033203

32043204
#ifdef HAVE_JIT
32053205
zend_jit_shutdown();
@@ -3221,15 +3221,15 @@ void accel_shutdown(void)
32213221
}
32223222

32233223
_file_cache_only = file_cache_only;
3224-
_no_cache = no_cache;
3224+
_allow_cache = allow_cache;
32253225

32263226
accel_reset_pcre_cache();
32273227

32283228
#ifdef ZTS
32293229
ts_free_id(accel_globals_id);
32303230
#endif
32313231

3232-
if (!_file_cache_only && !_no_cache) {
3232+
if (!_file_cache_only && _allow_cache) {
32333233
/* Delay SHM detach - this only needs to be done if SHM is used */
32343234
orig_post_shutdown_cb = zend_post_shutdown_cb;
32353235
zend_post_shutdown_cb = accel_post_shutdown;
@@ -4820,8 +4820,8 @@ static int accel_finish_startup(void)
48204820
}
48214821

48224822
if (ZCG(accel_directives).preload && *ZCG(accel_directives).preload) {
4823-
if (no_cache) {
4824-
zend_accel_error(ACCEL_LOG_ERROR, "Preloading cannot be combined with no_cache");
4823+
if (!allow_cache) {
4824+
zend_accel_error(ACCEL_LOG_ERROR, "Preloading cannot be combined with allow_cache=0");
48254825
return FAILURE;
48264826
}
48274827
#ifdef ZEND_WIN32
@@ -4847,8 +4847,8 @@ static int accel_finish_startup(void)
48474847
zend_bool old_reset_signals = SIGG(reset);
48484848
#endif
48494849

4850-
if (UNEXPECTED(no_cache)) {
4851-
zend_accel_error(ACCEL_LOG_WARNING, "Preloading doesn't work in \"no_cache\" mode");
4850+
if (UNEXPECTED(!allow_cache)) {
4851+
zend_accel_error(ACCEL_LOG_WARNING, "Preloading doesn't work in \"allow_cache=0\" mode");
48524852
return SUCCESS;
48534853
}
48544854
if (UNEXPECTED(file_cache_only)) {

ext/opcache/ZendAccelerator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ typedef struct _zend_accel_directives {
187187
#endif
188188
char *file_cache;
189189
zend_bool file_cache_only;
190-
zend_bool no_cache;
190+
zend_bool allow_cache;
191191
zend_bool file_cache_consistency_checks;
192192
#if ENABLE_FILE_CACHE_FALLBACK
193193
zend_bool file_cache_fallback;
@@ -296,7 +296,7 @@ extern char accel_uname_id[32];
296296
#endif
297297
extern zend_bool accel_startup_ok;
298298
extern zend_bool file_cache_only;
299-
extern zend_bool no_cache;
299+
extern zend_bool allow_cache;
300300
#if ENABLE_FILE_CACHE_FALLBACK
301301
extern zend_bool fallback_process;
302302
#endif

ext/opcache/tests/001_cli.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ var_dump($config["directives"]["opcache.enable"]);
1515
var_dump($config["directives"]["opcache.enable_cli"]);
1616
var_dump($status["opcache_enabled"]);
1717
var_dump($status["optimizations_enabled"]);
18+
var_dump($status["allow_cache"]);
1819
?>
1920
--EXPECT--
2021
bool(true)
2122
bool(true)
2223
bool(true)
2324
bool(true)
25+
bool(true)

ext/opcache/tests/no_cache_1.phpt renamed to ext/opcache/tests/allow_cache_1.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--TEST--
2-
no_cache_1: Opcache indicates if optimizations and caching are enabled
2+
allow_cache_1: Opcache indicates if optimizations and caching are enabled
33
--INI--
44
opcache.enable=1
55
opcache.enable_cli=1
6-
opcache.no_cache=1
6+
opcache.allow_cache=0
77
opcache.preload=
88
--SKIPIF--
99
<?php require_once('skipif.inc'); ?>
@@ -18,6 +18,6 @@ array(3) {
1818
bool(true)
1919
["opcache_enabled"]=>
2020
bool(false)
21-
["no_cache"]=>
22-
bool(true)
21+
["allow_cache"]=>
22+
bool(false)
2323
}

ext/opcache/tests/no_cache_2.phpt renamed to ext/opcache/tests/allow_cache_2.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
--TEST--
2-
no_cache_2: no_cache takes precedence over file_cache
2+
allow_cache_2: allow_cache=0 takes precedence over file_cache
33
--INI--
44
opcache.enable=1
55
opcache.enable_cli=1
66
opcache.file_cache_only=1
77
opcache.file_cache="{TMP}"
8-
opcache.no_cache=1
8+
opcache.allow_cache=0
99
opcache.opt_debug_level=0x20000
1010
opcache.optimization_level=-1
1111
opcache.preload=
@@ -15,7 +15,7 @@ opcache.preload=
1515
--FILE--
1616
<?php
1717
// Opcache should actually run.
18-
// Because no_cache is used, this will consistently emit debug output as a side effect.
18+
// Because allow_cache is used, this will consistently emit debug output as a side effect.
1919
// It should also indicate that file_cache is not used.
2020
$status = opcache_get_status();
2121
var_dump($status);
@@ -24,7 +24,7 @@ var_dump($status);
2424
$_main:
2525
; (lines=7, args=0, vars=1, tmps=1)
2626
; (after optimizer)
27-
; %sno_cache_2.php:1-8
27+
; %sallow_cache_2.php:1-8
2828
0000 INIT_FCALL 0 %d string("opcache_get_status")
2929
0001 V1 = DO_ICALL
3030
0002 ASSIGN CV0($status) V1
@@ -37,6 +37,6 @@ array(3) {
3737
bool(true)
3838
["opcache_enabled"]=>
3939
bool(false)
40-
["no_cache"]=>
41-
bool(true)
40+
["allow_cache"]=>
41+
bool(false)
4242
}

ext/opcache/zend_accelerator_module.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ ZEND_INI_BEGIN()
301301
#if ENABLE_FILE_CACHE_FALLBACK
302302
STD_PHP_INI_BOOLEAN("opcache.file_cache_fallback" , "1" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.file_cache_fallback, zend_accel_globals, accel_globals)
303303
#endif
304-
STD_PHP_INI_ENTRY("opcache.no_cache" , "0" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.no_cache, zend_accel_globals, accel_globals)
304+
STD_PHP_INI_ENTRY("opcache.allow_cache" , "1" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.allow_cache, zend_accel_globals, accel_globals)
305305
#ifdef HAVE_HUGE_CODE_PAGES
306306
STD_PHP_INI_BOOLEAN("opcache.huge_code_pages" , "0" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.huge_code_pages, zend_accel_globals, accel_globals)
307307
#endif
@@ -406,8 +406,8 @@ void zend_accel_override_file_functions(void)
406406
{
407407
zend_function *old_function;
408408
if (ZCG(enabled) && accel_startup_ok && ZCG(accel_directives).file_override_enabled) {
409-
if (no_cache) {
410-
zend_accel_error(ACCEL_LOG_WARNING, "file_override_enabled has no effect when no_cache is set");
409+
if (!allow_cache) {
410+
zend_accel_error(ACCEL_LOG_WARNING, "file_override_enabled has no effect when allow_cache=0");
411411
return;
412412
}
413413
if (file_cache_only) {
@@ -443,7 +443,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
443443
{
444444
php_info_print_table_start();
445445

446-
if ((ZCG(accelerator_enabled) || file_cache_only) && !no_cache) {
446+
if ((ZCG(accelerator_enabled) || file_cache_only) && allow_cache) {
447447
php_info_print_table_row(2, "Opcode Caching", "Up and Running");
448448
} else {
449449
php_info_print_table_row(2, "Opcode Caching", "Disabled");
@@ -453,12 +453,12 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
453453
} else {
454454
php_info_print_table_row(2, "Optimization", "Disabled");
455455
}
456-
if (!file_cache_only && !no_cache) {
456+
if (!file_cache_only && allow_cache) {
457457
php_info_print_table_row(2, "SHM Cache", "Enabled");
458458
} else {
459459
php_info_print_table_row(2, "SHM Cache", "Disabled");
460460
}
461-
if (ZCG(accel_directives).file_cache && !no_cache) {
461+
if (ZCG(accel_directives).file_cache && allow_cache) {
462462
php_info_print_table_row(2, "File Cache", "Enabled");
463463
} else {
464464
php_info_print_table_row(2, "File Cache", "Disabled");
@@ -476,7 +476,7 @@ void zend_accel_info(ZEND_MODULE_INFO_FUNC_ARGS)
476476
#else
477477
php_info_print_table_row(2, "JIT", "Not Available");
478478
#endif
479-
if (file_cache_only || no_cache) { // TODO test failure mode
479+
if (file_cache_only || !allow_cache) { // TODO test failure mode
480480
if (!accel_startup_ok || zps_api_failure_reason) {
481481
php_info_print_table_row(2, "Startup Failed", zps_api_failure_reason);
482482
} else {
@@ -623,8 +623,8 @@ ZEND_FUNCTION(opcache_get_status)
623623
/* Whether the caching is enabled */
624624
add_assoc_bool(return_value, "opcache_enabled", ZCG(accelerator_enabled));
625625

626-
if (no_cache) {
627-
add_assoc_bool(return_value, "no_cache", 1);
626+
add_assoc_bool(return_value, "allow_cache", allow_cache);
627+
if (!allow_cache) {
628628
return;
629629
}
630630
if (ZCG(accel_directives).file_cache) {
@@ -796,7 +796,7 @@ ZEND_FUNCTION(opcache_get_configuration)
796796
#if ENABLE_FILE_CACHE_FALLBACK
797797
add_assoc_bool(&directives, "opcache.file_cache_fallback", ZCG(accel_directives).file_cache_fallback);
798798
#endif
799-
add_assoc_bool(&directives, "opcache.no_cache", ZCG(accel_directives).no_cache);
799+
add_assoc_bool(&directives, "opcache.allow_cache", ZCG(accel_directives).allow_cache);
800800

801801
add_assoc_long(&directives, "opcache.file_update_protection", ZCG(accel_directives).file_update_protection);
802802
add_assoc_long(&directives, "opcache.opt_debug_level", ZCG(accel_directives).opt_debug_level);

0 commit comments

Comments
 (0)