Skip to content

Commit 0621d9c

Browse files
committed
Remove the opcache sapi whitelist
1 parent 659f55a commit 0621d9c

File tree

1 file changed

+5
-40
lines changed

1 file changed

+5
-40
lines changed

ext/opcache/ZendAccelerator.c

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

2844-
static inline zend_result accel_find_sapi(void)
2844+
static inline bool accel_sapi_is_cli(void)
28452845
{
2846-
static const char *supported_sapis[] = {
2847-
"apache",
2848-
"fastcgi",
2849-
"cli-server",
2850-
"cgi-fcgi",
2851-
"fpm-fcgi",
2852-
"fpmi-fcgi",
2853-
"apache2handler",
2854-
"litespeed",
2855-
"uwsgi",
2856-
"fuzzer",
2857-
"frankenphp",
2858-
"ngx-php",
2859-
NULL
2860-
};
2861-
const char **sapi_name;
2862-
2863-
if (sapi_module.name) {
2864-
for (sapi_name = supported_sapis; *sapi_name; sapi_name++) {
2865-
if (strcmp(sapi_module.name, *sapi_name) == 0) {
2866-
return SUCCESS;
2867-
}
2868-
}
2869-
if (ZCG(accel_directives).enable_cli && (
2870-
strcmp(sapi_module.name, "cli") == 0
2871-
|| strcmp(sapi_module.name, "phpdbg") == 0)) {
2872-
return SUCCESS;
2873-
}
2874-
}
2875-
2876-
return FAILURE;
2846+
return strcmp(sapi_module.name, "cli") == 0
2847+
|| strcmp(sapi_module.name, "phpdbg") == 0;
28772848
}
28782849

28792850
static zend_result zend_accel_init_shm(void)
@@ -3196,15 +3167,9 @@ static int accel_startup(zend_extension *extension)
31963167
}
31973168
#endif
31983169

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

0 commit comments

Comments
 (0)