Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.326
diff -u -p -r1.326 system.admin.inc
--- modules/system/system.admin.inc 23 Nov 2010 02:54:13 -0000 1.326
+++ modules/system/system.admin.inc 28 Dec 2010 01:18:03 -0000
@@ -2182,22 +2182,43 @@ function system_site_maintenance_mode()
function system_clean_url_settings($form, &$form_state) {
global $base_url;
- // 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'])) {
+ $conflict = FALSE;
+ // If the request uri is a clean URL, clean URLs must be available.
+ // Otherwise, run a test.
+ if (strpos(request_uri(), '?q=') === FALSE) {
$available = TRUE;
}
else {
$request = drupal_http_request($base_url . '/admin/config/search/clean-urls/check');
+ // If the request returns HTTP 200, clean URLs are available.
if (isset($request->code) && $request->code == 200) {
$available = TRUE;
+ // If the user started the clean URL test, provide explicit feedback.
+ if (isset($form_state['input']['op']) && $form_state['input']['op'] == t('Run the clean URL test')) {
+ drupal_set_message(t('The clean URL test passed.'));
+ }
+ }
+ else {
+ // If the test failed while clean URLs are enabled, make sure clean URLs
+ // can be disabled.
+ if (variable_get('clean_url',0)) {
+ $conflict = TRUE;
+ // Warn the user of a conflicting situation, unless after processing
+ // a submitted form.
+ if (!isset($form_state['input']['op'])) {
+ drupal_set_message(t('Clean URLs are enabled, but the clean URL test failed. If needed, you can disable clean URLs now.'), 'warning');
+ }
+ }
+ // If the user started the clean URL test, provide explicit feedback.
+ else if (isset($form_state['input']['op']) && $form_state['input']['op'] == t('Run the clean URL test')) {
+ drupal_set_message(t('The clean URL test failed.'), 'warning');
+ }
}
- }
- if ($available) {
- $_SESSION['clean_url'] = TRUE;
+ }
+ if ($available || $conflict) {
$form['clean_url'] = array(
'#type' => 'checkbox',
'#title' => t('Enable clean URLs'),
@@ -2205,6 +2226,9 @@ function system_clean_url_settings($form
'#description' => t('Use URLs like example.com/user
instead of example.com/?q=user
.'),
);
$form = system_settings_form($form);
+ if ($conflict) {
+ $form_state['redirect'] = $base_url . '?q=/admin/config/search/clean-urls';
+ }
}
else {
drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
@@ -2212,7 +2236,11 @@ function system_clean_url_settings($form
$form_state['redirect'] = $base_url . '/admin/config/search/clean-urls';
$form['clean_url_description'] = array(
'#type' => 'markup',
- '#markup' => '
' . t('Use URLs like example.com/user
instead of example.com/?q=user
.') . ' ' . t('If you are directed to a Page not found (404) error after testing for clean URLs, see the online handbook.', array('@handbook' => 'http://drupal.org/node/15365')) . '
' . t('Use URLs like example.com/user
instead of example.com/?q=user
.'),
+ );
+ $form['clean_url_test_result'] = array(
+ '#type' => 'markup',
+ '#markup' => '
' . t('Clean URLs cannot be enabled. If you are directed to this page or to a Page not found (404) error after testing for clean URLs, see the online handbook.', array('@handbook' => 'http://drupal.org/node/15365')) . '
', ); $form['clean_url_test'] = array( '#type' => 'submit',