From b4494afa1bf6f09b7914a41510657adb5db1400d Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Tue, 31 Mar 2015 15:52:58 +0100
Subject: [PATCH] Issue #1559116 by omega8cc, mva.name, droplet, Xano,
 mgifford: Make core aware of Nginx and PHP-FPM to avoid confusing alerts

---
 core/modules/file/file.install | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index 8d13c03ddfe9..6e188c6a5624 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -67,18 +67,34 @@ function file_requirements($phase) {
 
   // Check the server's ability to indicate upload progress.
   if ($phase == 'runtime') {
+    $description = NULL;
     $implementation = file_progress_implementation();
     $server_software = \Drupal::request()->server->get('SERVER_SOFTWARE');
-    $apache = strpos($server_software, 'Apache') !== FALSE;
-    $fastcgi = strpos($server_software, 'mod_fastcgi') !== FALSE || strpos($server_software, 'mod_fcgi') !== FALSE;
-    $description = NULL;
-    if (!$apache) {
+
+    // Test the web server identity.
+    if (preg_match("/Nginx/i", $server_software)) {
+      $is_nginx = TRUE;
+      $is_apache = FALSE;
+      $fastcgi = FALSE;
+    }
+    elseif (preg_match("/Apache/i", $server_software)) {
+      $is_nginx = FALSE;
+      $is_apache = TRUE;
+      $fastcgi = strpos($server_software, 'mod_fastcgi') !== FALSE || strpos($server_software, 'mod_fcgi') !== FALSE;
+    }
+    else {
+      $is_nginx = FALSE;
+      $is_apache = FALSE;
+      $fastcgi = FALSE;
+    }
+
+    if (!$is_apache && !$is_nginx) {
       $value = t('Not enabled');
-      $description = t('Your server is not capable of displaying file upload progress. File upload progress requires an Apache server running PHP with mod_php.');
+      $description = t('Your server is not capable of displaying file upload progress. File upload progress requires an Apache server running PHP with mod_php or Nginx with PHP-FPM.');
     }
     elseif ($fastcgi) {
       $value = t('Not enabled');
-      $description = t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php and not as FastCGI.');
+      $description = t('Your server is not capable of displaying file upload progress. File upload progress requires PHP be run with mod_php or PHP-FPM and not as FastCGI.');
     }
     elseif (!$implementation && extension_loaded('apc')) {
       $value = t('Not enabled');
-- 
GitLab