? .project
? sites/default/files
? sites/default/private
? sites/default/settings.php
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.228
diff -u -p -r1.228 system.admin.inc
--- modules/system/system.admin.inc	26 Nov 2009 05:54:48 -0000	1.228
+++ modules/system/system.admin.inc	27 Nov 2009 04:36:57 -0000
@@ -1976,16 +1976,7 @@ function system_clean_url_settings($form
 
   // When accessing this form using a non-clean URL, allow a re-check to make
   // sure clean URLs can be disabled at all times.
-  $available = FALSE;
-  if (strpos(request_uri(), '?q=') === FALSE || !empty($_SESSION['clean_url'])) {
-    $available = TRUE;
-  }
-  else {
-    $request = drupal_http_request($base_url . '/admin/config/search/clean-urls/check');
-    if (isset($request->code) && $request->code == 200) {
-      $available = TRUE;
-    }
-  }
+  $available = system_check_clean_url();
 
   if ($available) {
     $_SESSION['clean_url'] = TRUE;
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.422
diff -u -p -r1.422 system.install
--- modules/system/system.install	11 Nov 2009 17:06:30 -0000	1.422
+++ modules/system/system.install	27 Nov 2009 04:37:01 -0000
@@ -194,6 +194,39 @@ function system_requirements($phase) {
     );
   }
 
+  // Test the status of clean URLs.
+  if ($phase == 'runtime') {
+    $clean_url_available = system_check_clean_url();
+    $clean_url_enabled = variable_get('clean_url', FALSE);
+
+    if ($clean_url_available == FALSE && $clean_url_enabled == FALSE) {
+      $severity = REQUIREMENT_WARNING;
+      $summary = $t('Clean URLs are not currently supported on your website.');
+      $description = $t('Clean URLs are not currently supported on your website.');
+    }
+    if ($clean_url_available == TRUE && $clean_url_enabled == FALSE) {
+      $severity = REQUIREMENT_WARNING;
+      $summary = $t('Clean URLs are currently disabled on your website.');
+      $description = $t('Clean URLs are currently disabled on your website.');
+    }
+    if ($clean_url_available == FALSE && $clean_url_enabled == TRUE) {
+      $severity = REQUIREMENT_ERROR;
+      $summary = $t("Clean URLs are currently enabled on your website, but your website doesn't support clean URLs.");
+      $description = $t("Clean URLs are currently enabled on your website, but your website doesn't support clean URLs.");
+    }
+    if ($clean_url_available == TRUE && $clean_url_enabled == TRUE) {
+      $severity = REQUIREMENT_OK;
+      $summary = $t('Clean URLs are functioning properly on your website.');
+      $description = $t('Clean URLs are functioning properly on your website.');
+    }
+    $requirements['clean_url'] = array(
+      'title' => $t('Clean URL status'),
+      'severity' => $severity,
+      'value' => $summary,
+      'description' => $description,
+    );
+  }
+
   // Test files directories.
   $directories = array(
     variable_get('file_public_path', conf_path() . '/files'),
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.844
diff -u -p -r1.844 system.module
--- modules/system/system.module	22 Nov 2009 01:33:45 -0000	1.844
+++ modules/system/system.module	27 Nov 2009 04:37:05 -0000
@@ -2682,6 +2682,12 @@ function system_cron() {
     ))
     ->condition('expire', REQUEST_TIME, '<')
     ->execute();
+
+  // Disable clean URLs if they are enabled but not functioning.
+  if (system_check_clean_url() && variable_get('clean_url', FALSE)) {
+    variable_set('clean_url', FALSE);
+    watchdog('system', 'Clean URLs were automatically disabled as they are not functioning properly.', array(), WATCHDOG_ALERT);
+  }
 }
 
 /**
@@ -3635,3 +3641,24 @@ function system_build_contextual_links($
   return $build;
 }
 
+/**
+ * Check if clean URLs are functional on this Drupal installation.
+ *
+ * @return
+ *   TRUE if clean URLs are working properly, FALSE otherwise. 
+ */
+function system_check_clean_url() {
+  global $base_url;
+  $clean_url = &drupal_static(__FUNCTION__);
+  if (strpos(request_uri(), '?q=') === FALSE || $clean_url) {
+    return TRUE;
+  }
+  else {
+    $request = drupal_http_request($base_url . '/admin/config/search/clean-urls/check');
+    if (isset($request->code) && $request->code == 200) {
+      $clean_url = TRUE;
+      return TRUE;
+    }
+  }
+  return FALSE;
+}
