@@ -2842,39 +2842,12 @@ static void zps_startup_failure(const char *reason, const char *api_reason, int
2842
2842
zend_llist_del_element (& zend_extensions , NULL , (int (* )(void * , void * ))cb );
2843
2843
}
2844
2844
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 )
2846
2848
{
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 ;
2878
2851
}
2879
2852
2880
2853
static zend_result zend_accel_init_shm (void )
@@ -3197,15 +3170,9 @@ static int accel_startup(zend_extension *extension)
3197
3170
}
3198
3171
#endif
3199
3172
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 ()) {
3202
3174
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 );
3209
3176
return SUCCESS ;
3210
3177
}
3211
3178
0 commit comments