Skip to content

Commit 3088d64

Browse files
committed
Remove the Opcache SAPI whitelist
Closes GH-19351
1 parent 3ddbad9 commit 3088d64

File tree

1 file changed

+7
-40
lines changed

1 file changed

+7
-40
lines changed

ext/opcache/ZendAccelerator.c

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,39 +2842,12 @@ static void zps_startup_failure(const char *reason, const char *api_reason, int
28422842
zend_llist_del_element(&zend_extensions, NULL, (int (*)(void *, void *))cb);
28432843
}
28442844

2845-
static inline zend_result accel_find_sapi(void)
2845+
/* Return whether we are running a CLI (Command LIne) SAPI for which Opcache is
2846+
* disabled when `opcache.enable_cli=0` */
2847+
static inline bool accel_sapi_is_cli(void)
28462848
{
2847-
static const char *supported_sapis[] = {
2848-
"apache",
2849-
"fastcgi",
2850-
"cli-server",
2851-
"cgi-fcgi",
2852-
"fpm-fcgi",
2853-
"fpmi-fcgi",
2854-
"apache2handler",
2855-
"litespeed",
2856-
"uwsgi",
2857-
"fuzzer",
2858-
"frankenphp",
2859-
"ngx-php",
2860-
NULL
2861-
};
2862-
const char **sapi_name;
2863-
2864-
if (sapi_module.name) {
2865-
for (sapi_name = supported_sapis; *sapi_name; sapi_name++) {
2866-
if (strcmp(sapi_module.name, *sapi_name) == 0) {
2867-
return SUCCESS;
2868-
}
2869-
}
2870-
if (ZCG(accel_directives).enable_cli && (
2871-
strcmp(sapi_module.name, "cli") == 0
2872-
|| strcmp(sapi_module.name, "phpdbg") == 0)) {
2873-
return SUCCESS;
2874-
}
2875-
}
2876-
2877-
return FAILURE;
2849+
return strcmp(sapi_module.name, "cli") == 0
2850+
|| strcmp(sapi_module.name, "phpdbg") == 0;
28782851
}
28792852

28802853
static zend_result zend_accel_init_shm(void)
@@ -3197,15 +3170,9 @@ static int accel_startup(zend_extension *extension)
31973170
}
31983171
#endif
31993172

3200-
/* no supported SAPI found - disable acceleration and stop initialization */
3201-
if (accel_find_sapi() == FAILURE) {
3173+
if (!ZCG(accel_directives).enable_cli && accel_sapi_is_cli()) {
32023174
accel_startup_ok = false;
3203-
if (!ZCG(accel_directives).enable_cli &&
3204-
strcmp(sapi_module.name, "cli") == 0) {
3205-
zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb);
3206-
} else {
3207-
zps_startup_failure("Opcode Caching is only supported in Apache, FPM, FastCGI, FrankenPHP, LiteSpeed and uWSGI SAPIs", NULL, accelerator_remove_cb);
3208-
}
3175+
zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb);
32093176
return SUCCESS;
32103177
}
32113178

0 commit comments

Comments
 (0)