From ff35fc9c532aac927a8dd050d97565ad49168d21 Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Wed, 12 Apr 2006 19:36:51 +0000 Subject: #58456: Clean URL tester broken --- modules/system.module | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'modules/system.module') diff --git a/modules/system.module b/modules/system.module index 8f2907882..0ea7f9c8c 100644 --- a/modules/system.module +++ b/modules/system.module @@ -100,8 +100,8 @@ function system_menu($may_cache) { 'type' => MENU_CALLBACK); // Clean URL tester - $items[] = array('path' => 'system/test', - 'callback' => 'system_test', + $items[] = array('path' => 'system/test-clean-url', + 'callback' => 'system_test_clean_url', 'access' => TRUE, 'type' => MENU_CALLBACK); @@ -153,11 +153,12 @@ function system_menu($may_cache) { } /** - * Menu callback: dummy clean URL tester. + * Menu callback: dummy clean URL tester and reset. + * + * When used as form #pre_render, it will reset the test variable. */ -function system_test() { - variable_set('clean_url_ok', 1); - exit; +function system_test_clean_url($form_id) { + variable_set('clean_url_ok', $form_id != 'system_settings_form'); } /** @@ -273,10 +274,10 @@ function system_view_general() { '#description' => t('This option makes Drupal emit clean URLs (i.e. without ?q= in the URL). You\'ll need ModRewrite support for this to work. See the .htaccess file in Drupal\'s top-level directory for more information.') ); - variable_set('clean_url_ok', 0); global $base_url; // We will use a random URL so there is no way a proxy or a browser could cache the "no such image" answer. - $form['general']['clean_url_test'] = array('#type' => 'markup', '#value' => ''); + $form['general']['clean_url_test'] = array('#type' => 'markup', '#value' => ''); + $form['#pre_render'] = array('system_test_clean_url'); // Error handling: @@ -753,6 +754,12 @@ function system_theme_settings_submit($form_id, $values) { function system_settings_form_submit($form_id, $values) { $op = isset($_POST['op']) ? $_POST['op'] : ''; + // Do the clean url validation, changing the form property if it doesn't work. + if ($values['clean_url'] && !variable_get('clean_url_ok', 0)) { + drupal_set_message(t('It appears your host is not configured correctly for Clean URLs. Please check for ModRewrite support with your administrator.'), 'error'); + $values['clean_url'] = 0; + } + foreach ($values as $key => $value) { if ($op == t('Reset to defaults')) { variable_del($key); @@ -773,21 +780,6 @@ function system_settings_form_submit($form_id, $values) { menu_rebuild(); } -/** - * Do the clean url validation, changing the form property if it doesn't work. - */ -function system_settings_validate($form_id, &$form) { - #TODO .. fix here. - if ($edit['clean_url'] && !variable_get('clean_url_ok', 0)) { - drupal_set_message(t('It appears your host is not configured correctly for Clean URLs. Please check for ModRewrite support with your administrator.'), 'error'); - $edit['clean_url'] = 0; - } - -} - - - - /** * Menu callback; displays a listing of all themes. */ -- cgit v1.2.3