Skip to content

Commit 1197a96

Browse files
committed
opcache: file_cache_read_only code review update 2 (#16484)
1 parent 79dd38e commit 1197a96

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3329,16 +3329,22 @@ static zend_result accel_post_startup(void)
33293329
#endif
33303330
}
33313331

3332-
if ( ZCG(accel_directives).file_cache &&
3332+
if ( ZCG(accel_directives).file_cache ){
3333+
zend_stat_t buf = {0};
3334+
3335+
if (!IS_ABSOLUTE_PATH(ZCG(accel_directives).file_cache, strlen(ZCG(accel_directives).file_cache)) ||
3336+
zend_stat(ZCG(accel_directives).file_cache, &buf) != 0 ||
3337+
!S_ISDIR(buf.st_mode) ||
33333338
#ifndef ZEND_WIN32
33343339
access(ZCG(accel_directives).file_cache, file_cache_access_mode) != 0
33353340
#else
33363341
_access(ZCG(accel_directives).file_cache, file_cache_access_mode) != 0
33373342
#endif
3338-
) {
3339-
accel_startup_ok = false;
3340-
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "opcache.file_cache must be a full path of an accessible directory");
3341-
return SUCCESS;
3343+
) {
3344+
accel_startup_ok = false;
3345+
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "opcache.file_cache must be a full path of an accessible directory");
3346+
return SUCCESS;
3347+
}
33423348
}
33433349

33443350
#if ENABLE_FILE_CACHE_FALLBACK

ext/opcache/zend_accelerator_module.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -160,26 +160,6 @@ static ZEND_INI_MH(OnEnable)
160160
}
161161
}
162162

163-
static ZEND_INI_MH(OnUpdateFileCache)
164-
{
165-
if (new_value) {
166-
if (!ZSTR_LEN(new_value)) {
167-
new_value = NULL;
168-
} else {
169-
zend_stat_t buf = {0};
170-
171-
if (!IS_ABSOLUTE_PATH(ZSTR_VAL(new_value), ZSTR_LEN(new_value)) ||
172-
zend_stat(ZSTR_VAL(new_value), &buf) != 0 ||
173-
!S_ISDIR(buf.st_mode)) {
174-
zend_accel_error(ACCEL_LOG_WARNING, "opcache.file_cache must be a full path of accessible directory.\n");
175-
new_value = NULL;
176-
}
177-
}
178-
}
179-
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
180-
return SUCCESS;
181-
}
182-
183163
#ifdef HAVE_JIT
184164
static ZEND_INI_MH(OnUpdateJit)
185165
{
@@ -306,7 +286,7 @@ ZEND_INI_BEGIN()
306286
STD_PHP_INI_ENTRY("opcache.mmap_base", NULL, PHP_INI_SYSTEM, OnUpdateString, accel_directives.mmap_base, zend_accel_globals, accel_globals)
307287
#endif
308288

309-
STD_PHP_INI_ENTRY("opcache.file_cache" , NULL , PHP_INI_SYSTEM, OnUpdateFileCache, accel_directives.file_cache, zend_accel_globals, accel_globals)
289+
STD_PHP_INI_ENTRY("opcache.file_cache" , NULL , PHP_INI_SYSTEM, OnUpdateStringUnempty, accel_directives.file_cache, zend_accel_globals, accel_globals)
310290
STD_PHP_INI_BOOLEAN("opcache.file_cache_read_only" , "0" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.file_cache_read_only, zend_accel_globals, accel_globals)
311291
STD_PHP_INI_BOOLEAN("opcache.file_cache_only" , "0" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.file_cache_only, zend_accel_globals, accel_globals)
312292
STD_PHP_INI_BOOLEAN("opcache.file_cache_consistency_checks" , "1" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.file_cache_consistency_checks, zend_accel_globals, accel_globals)

0 commit comments

Comments
 (0)