From 9fabe160c612304b4091fa9c3e8a37ea8c28f39a Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Fri, 17 Feb 2012 14:13:56 +1000
Subject: [PATCH 2/2] 1440584 File module reports server is not capable of using uploadprogress when running on Litespeed

---
 core/modules/file/file.install |   60 ++++++++++++++++++++-------------------
 1 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index 47ee4fd..4221b66 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -53,39 +53,41 @@ function file_requirements($phase) {
 
   // Check the server's ability to indicate upload progress.
   if ($phase == 'runtime') {
-    $implementation = file_progress_implementation();
-    $apache = strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== FALSE;
-    $fastcgi = strpos($_SERVER['SERVER_SOFTWARE'], 'mod_fastcgi') !== FALSE || strpos($_SERVER["SERVER_SOFTWARE"], 'mod_fcgi') !== FALSE;
     $description = NULL;
-    if (!$apache) {
-      $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.');
-      $severity = REQUIREMENT_INFO;
-    }
-    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.');
-      $severity = REQUIREMENT_INFO;
-    }
-    elseif (!$implementation && extension_loaded('apc')) {
-      $value = t('Not enabled');
-      $description = t('Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>, which supports more than one simultaneous upload.');
-      $severity = REQUIREMENT_INFO;
-    }
-    elseif (!$implementation) {
-      $value = t('Not enabled');
-      $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> (preferred) or to install <a href="http://us2.php.net/apc">APC</a>.');
-      $severity = REQUIREMENT_INFO;
-    }
-    elseif ($implementation == 'apc') {
-      $value = t('Enabled (<a href="http://php.net/manual/en/apc.configuration.php#ini.apc.rfc1867">APC RFC1867</a>)');
-      $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> if possible.');
-      $severity = REQUIREMENT_OK;
-    }
-    elseif ($implementation == 'uploadprogress') {
+    $implementation = file_progress_implementation();
+    if ($implementation == 'uploadprogress') {
       $value = t('Enabled (<a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>)');
       $severity = REQUIREMENT_OK;
     }
+    else {
+      $apache = strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== FALSE;
+      $fastcgi = strpos($_SERVER['SERVER_SOFTWARE'], 'mod_fastcgi') !== FALSE || strpos($_SERVER["SERVER_SOFTWARE"], 'mod_fcgi') !== FALSE;
+      if (!$apache) {
+        $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.');
+        $severity = REQUIREMENT_INFO;
+      }
+      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.');
+        $severity = REQUIREMENT_INFO;
+      }
+      elseif (!$implementation && extension_loaded('apc')) {
+        $value = t('Not enabled');
+        $description = t('Your server is capable of displaying file upload progress through APC, but it is not enabled. Add <code>apc.rfc1867 = 1</code> to your php.ini configuration. Alternatively, it is recommended to use <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress</a>, which supports more than one simultaneous upload.');
+        $severity = REQUIREMENT_INFO;
+      }
+      elseif (!$implementation) {
+        $value = t('Not enabled');
+        $description = t('Your server is capable of displaying file upload progress, but does not have the required libraries. It is recommended to install the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> (preferred) or to install <a href="http://us2.php.net/apc">APC</a>.');
+        $severity = REQUIREMENT_INFO;
+      }
+      elseif ($implementation == 'apc') {
+        $value = t('Enabled (<a href="http://php.net/manual/en/apc.configuration.php#ini.apc.rfc1867">APC RFC1867</a>)');
+        $description = t('Your server is capable of displaying file upload progress using APC RFC1867. Note that only one upload at a time is supported. It is recommended to use the <a href="http://pecl.php.net/package/uploadprogress">PECL uploadprogress library</a> if possible.');
+        $severity = REQUIREMENT_OK;
+      }
+    }
     $requirements['file_progress'] = array(
       'title' => t('Upload progress'),
       'value' => $value,
-- 
1.7.4

