-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Remove the opcache sapi whitelist #19351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2841,39 +2841,10 @@ static void zps_startup_failure(const char *reason, const char *api_reason, int | |
zend_llist_del_element(&zend_extensions, NULL, (int (*)(void *, void *))cb); | ||
} | ||
|
||
static inline zend_result accel_find_sapi(void) | ||
static inline bool accel_sapi_is_cli(void) | ||
{ | ||
static const char *supported_sapis[] = { | ||
"apache", | ||
"fastcgi", | ||
"cli-server", | ||
"cgi-fcgi", | ||
"fpm-fcgi", | ||
"fpmi-fcgi", | ||
"apache2handler", | ||
"litespeed", | ||
"uwsgi", | ||
"fuzzer", | ||
"frankenphp", | ||
"ngx-php", | ||
NULL | ||
}; | ||
const char **sapi_name; | ||
|
||
if (sapi_module.name) { | ||
for (sapi_name = supported_sapis; *sapi_name; sapi_name++) { | ||
if (strcmp(sapi_module.name, *sapi_name) == 0) { | ||
return SUCCESS; | ||
} | ||
} | ||
if (ZCG(accel_directives).enable_cli && ( | ||
strcmp(sapi_module.name, "cli") == 0 | ||
|| strcmp(sapi_module.name, "phpdbg") == 0)) { | ||
return SUCCESS; | ||
} | ||
} | ||
|
||
return FAILURE; | ||
return strcmp(sapi_module.name, "cli") == 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not that it's terribly relevant to have opcache active for Just a question, trying to read into the source. cli-server is e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Opcache is disabled by default on cli because populating a cache in this context will just consume more memory for no benefits (as the cache lives only for the duration of a single "request"), unless the file_cache is used. It is possible to enable opcache in cli by setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, the if statement will have to be changed then, though: if (!ZCG(accel_directives).enable_cli && accel_sapi_is_cli()) { Would enable it for phpdbg when enable_cli is enabled. Or is that intended? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is intended :) Opcache is disabled by default in phpdbg for the same reasons. |
||
|| strcmp(sapi_module.name, "phpdbg") == 0; | ||
} | ||
|
||
static zend_result zend_accel_init_shm(void) | ||
|
@@ -3196,15 +3167,9 @@ static int accel_startup(zend_extension *extension) | |
} | ||
#endif | ||
|
||
/* no supported SAPI found - disable acceleration and stop initialization */ | ||
if (accel_find_sapi() == FAILURE) { | ||
if (!ZCG(accel_directives).enable_cli && accel_sapi_is_cli()) { | ||
accel_startup_ok = false; | ||
if (!ZCG(accel_directives).enable_cli && | ||
strcmp(sapi_module.name, "cli") == 0) { | ||
zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb); | ||
} else { | ||
zps_startup_failure("Opcode Caching is only supported in Apache, FPM, FastCGI, FrankenPHP, LiteSpeed and uWSGI SAPIs", NULL, accelerator_remove_cb); | ||
} | ||
zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb); | ||
return SUCCESS; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or something like that, considering that it's not only cli sapi but also phpdbg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the naming is not ideal, but I've decided to keep it because it matches the INI parameter
opcache.enable_cli
. "cli" should be understood as any Command LIne SAPI here.