@@ -172,26 +172,8 @@ function getPhpServiceStatus() {
172172}
173173
174174function findActivePhpFpmService () {
175- // Common PHP-FPM service name patterns to check (ordered by likelihood)
176- $ php_patterns = [
177- 'php8.4-fpm ' ,
178- 'php8.3-fpm ' ,
179- 'php8.2-fpm ' ,
180- 'php8.1-fpm ' ,
181- 'php-fpm ' ,
182- 'php-fpm8.4 ' ,
183- 'php84-fpm ' ,
184- ];
185-
186- // Try each pattern
187- foreach ($ php_patterns as $ service_name ) {
188- $ status = getSystemServiceStatus ($ service_name );
189- if ($ status === 'active ' ) {
190- return $ service_name ;
191- }
192- }
193-
194- // Fallback: Use systemctl to find any active PHP-FPM service
175+ // Use systemctl to find any active PHP-FPM service
176+ // This approach is more flexible and works with any PHP version
195177 $ services_output = SystemCommand::getSystemdServices (); // codacy:ignore - Static utility class pattern
196178
197179 if ($ services_output === false || empty ($ services_output )) {
@@ -222,9 +204,11 @@ function findActivePhpFpmService() {
222204 $ service_name = preg_replace ('/\.service$/ ' , '' , $ service_name );
223205
224206 // Check if it contains both "php" and "fpm" (case insensitive)
207+ // This matches: php-fpm, php8.4-fpm, php-fpm8.4, php84-fpm, phpfpm, etc.
225208 if (stripos ($ service_name , 'php ' ) !== false && stripos ($ service_name , 'fpm ' ) !== false ) {
226209 // Validate the service name matches our flexible pattern for PHP-FPM services
227- // Pattern: php + optional version/text + fpm + optional version/text
210+ // Pattern allows: php[version]fpm or php-fpm[version] or any combination
211+ // Examples: php-fpm, php8.4-fpm, php-fpm8.4, php84-fpm, phpfpm84
228212 if (preg_match ('/^php[a-zA-Z0-9\.\-_]*fpm[a-zA-Z0-9\.\-_]*$/ ' , $ service_name )) {
229213 // Double-check that it's actually active before returning
230214 $ status = getSystemServiceStatus ($ service_name );
0 commit comments