Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.941
diff -u -r1.941 system.module
--- modules/system/system.module	25 Jun 2010 18:20:27 -0000	1.941
+++ modules/system/system.module	26 Jun 2010 03:07:24 -0000
@@ -2573,32 +2573,11 @@
   return isset($regions[0]) ? $regions[0] : '';
 }
 
-function _system_settings_form_automatic_defaults($form) {
-  // Get an array of all non-property keys
-  $keys = element_children($form);
-
-  foreach ($keys as $key) {
-    // If the property (key) '#default_value' exists, replace it.
-    if (array_key_exists('#default_value', $form[$key])) {
-      $form[$key]['#default_value'] = variable_get($key, $form[$key]['#default_value']);
-    }
-    else {
-      // Recurse through child elements
-      $form[$key] = _system_settings_form_automatic_defaults($form[$key]);
-    }
-  }
-
-  return $form;
-}
-
 /**
  * Add default buttons to a form and set its prefix.
  *
  * @param $form
  *   An associative array containing the structure of the form.
- * @param $automatic_defaults
- *   Automatically load the saved values for each field from the system variables
- *   (defaults to TRUE).
  *
  * @return
  *   The form structure.
@@ -2606,14 +2585,10 @@
  * @see system_settings_form_submit()
  * @ingroup forms
  */
-function system_settings_form($form, $automatic_defaults = TRUE) {
+function system_settings_form($form) {
   $form['actions']['#type'] = 'actions';
   $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
 
-  if ($automatic_defaults) {
-    $form = _system_settings_form_automatic_defaults($form);
-  }
-
   if (!empty($_POST) && form_get_errors()) {
     drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
   }
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.289
diff -u -r1.289 system.admin.inc
--- modules/system/system.admin.inc	21 Jun 2010 02:27:47 -0000	1.289
+++ modules/system/system.admin.inc	26 Jun 2010 03:07:23 -0000
@@ -643,7 +643,7 @@
     }
   }
 
-  $form = system_settings_form($form, FALSE);
+  $form = system_settings_form($form);
   // We don't want to call system_settings_form_submit(), so change #submit.
   array_pop($form['#submit']);
   $form['#submit'][] = 'system_theme_settings_submit';
@@ -1567,7 +1567,7 @@
 
   $form['#validate'][] = 'system_site_information_settings_validate';
 
-  return system_settings_form($form, FALSE);
+  return system_settings_form($form);
 }
 
 /**
@@ -1596,7 +1596,7 @@
   $form['error_level'] = array(
     '#type' => 'radios',
     '#title' => t('Error messages to display'),
-    '#default_value' => ERROR_REPORTING_DISPLAY_ALL,
+    '#default_value' => variable_get('error_level', ERROR_REPORTING_DISPLAY_ALL),
     '#options' => array(
       ERROR_REPORTING_HIDE => t('None'),
       ERROR_REPORTING_DISPLAY_SOME => t('Errors and warnings'),
@@ -1695,7 +1695,7 @@
   $form['#submit'][] = 'drupal_clear_css_cache';
   $form['#submit'][] = 'drupal_clear_js_cache';
 
-  return system_settings_form($form, FALSE);
+  return system_settings_form($form);
 }
 
 /**
@@ -1715,11 +1715,10 @@
  * @see system_settings_form()
  */
 function system_file_system_settings() {
-
   $form['file_public_path'] = array(
     '#type' => 'textfield',
     '#title' => t('Public file system path'),
-    '#default_value' => file_directory_path(),
+    '#default_value' => variable_get('file_public_path', file_directory_path()),
     '#maxlength' => 255,
     '#description' => t('A local file system path where public files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web.'),
     '#after_build' => array('system_check_directory'),
@@ -1728,7 +1727,7 @@
   $form['file_private_path'] = array(
     '#type' => 'textfield',
     '#title' => t('Private file system path'),
-    '#default_value' => file_directory_path('private'),
+    '#default_value' => variable_get('file_private_path', file_directory_path('private')),
     '#maxlength' => 255,
     '#description' => t('A local file system path where private files will be stored. This directory must exist and be writable by Drupal. This directory should not be accessible over the web.'),
     '#after_build' => array('system_check_directory'),
@@ -1737,7 +1736,7 @@
   $form['file_temporary_path'] = array(
     '#type' => 'textfield',
     '#title' => t('Temporary directory'),
-    '#default_value' => file_directory_path('temporary'),
+    '#default_value' => variable_get('file_temporary_path', file_directory_path('temporary')),
     '#maxlength' => 255,
     '#description' => t('A local file system path where temporary files will be stored. This directory should not be accessible over the web.'),
     '#after_build' => array('system_check_directory'),
@@ -1752,13 +1751,13 @@
     $form['file_default_scheme'] = array(
       '#type' => 'radios',
       '#title' => t('Default download method'),
-      '#default_value' => isset($options['public']) ? 'public' : key($options),
+      '#default_value' => variable_get('file_default_scheme', isset($options['public']) ? 'public' : key($options)),
       '#options' => $options,
       '#description' => t('This setting is used as the preferred download method. The use of public files is more efficient, but does not provide any access control.'),
     );
   }
 
-  return system_settings_form($form, TRUE);
+  return system_settings_form($form);
 }
 
 /**
@@ -1783,7 +1782,7 @@
     $form['image_toolkit'] = array(
       '#type' => 'radios',
       '#title' => t('Select an image processing toolkit'),
-      '#default_value' => $current_toolkit,
+      '#default_value' => variable_get('image_toolkit', $current_toolkit),
       '#options' => $toolkits_available
     );
   }
@@ -1797,7 +1796,7 @@
     $form['image_toolkit_settings'] = $function();
   }
 
-  return system_settings_form($form, TRUE);
+  return system_settings_form($form);
 }
 
 /**
@@ -1807,29 +1806,28 @@
  * @see system_settings_form()
  */
 function system_rss_feeds_settings() {
-
   $form['feed_description'] = array(
     '#type' => 'textarea',
     '#title' => t('Feed description'),
-    '#default_value' => '',
+    '#default_value' => variable_get('feed_description', ''),
     '#description' => t('Description of your site, included in each feed.')
   );
   $form['feed_default_items'] = array(
     '#type' => 'select',
     '#title' => t('Number of items in each feed'),
-    '#default_value' => 10,
+    '#default_value' => variable_get('feed_default_items', 10),
     '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
     '#description' => t('Default number of items to include in each feed.')
   );
   $form['feed_item_length'] = array(
     '#type' => 'select',
     '#title' => t('Feed content'),
-    '#default_value' => 'fulltext',
+    '#default_value' => variable_get('feed_item_length', 'fulltext'),
     '#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')),
     '#description' => t('Global setting for the default display of content items in each feed.')
   );
 
-  return system_settings_form($form, TRUE);
+  return system_settings_form($form);
 }
 
 /**
@@ -1916,7 +1914,7 @@
     '#description' => t('Only applied if users may set their own time zone.')
   );
 
-  return system_settings_form($form, FALSE);
+  return system_settings_form($form);
 }
 
 /**
@@ -1991,7 +1989,7 @@
   // Display a message if no date types configured.
   $form['#empty_text'] = t('No date types available. <a href="@link">Add date type</a>.', array('@link' => url('admin/config/regional/date-time/types/add')));
 
-  return system_settings_form($form, FALSE);
+  return system_settings_form($form);
 }
 
 /**
@@ -2152,17 +2150,17 @@
   $form['maintenance_mode'] = array(
     '#type' => 'checkbox',
     '#title' => t('Put site into maintenance mode'),
-    '#default_value' => 0,
+    '#default_value' => variable_get('maintenance_mode', 0),
     '#description' => t('When enabled, only users with the "Access site in maintenance mode" <a href="@permissions-url">permission</a> are able to access your site to perform maintenance; all other visitors see the maintenance mode message configured below. Authorized users can log in directly via the <a href="@user-login">user login</a> page.', array('@permissions-url' => url('admin/people/permissions'), '@user-login' => url('user'))),
   );
   $form['maintenance_mode_message'] = array(
     '#type' => 'textarea',
     '#title' => t('Maintenance mode message'),
-    '#default_value' => t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))),
+    '#default_value' => variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
     '#description' => t('Message to show visitors when the site is in maintenance mode.')
   );
 
-  return system_settings_form($form, TRUE);
+  return system_settings_form($form);
 }
 
 /**
@@ -2193,7 +2191,7 @@
     $form['clean_url'] = array(
       '#type' => 'checkbox',
       '#title' => t('Enable clean URLs'),
-      '#default_value' => 0,
+      '#default_value' => variable_get('clean_url', 0),
       '#description' => t('Use URLs like <code>example.com/user</code> instead of <code>example.com/?q=user</code>.'),
     );
     $form = system_settings_form($form);
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.127
diff -u -r1.127 system.test
--- modules/system/system.test	21 Jun 2010 02:27:47 -0000	1.127
+++ modules/system/system.test	26 Jun 2010 03:07:25 -0000
@@ -1226,83 +1226,6 @@
   }
 }
 
-class SystemSettingsForm extends DrupalWebTestCase {
-  /**
-   * Implement getInfo().
-   */
-  public static function getInfo() {
-    return array(
-      'name' => 'System setting forms',
-      'description' => 'Tests correctness of system_settings_form() processing.',
-      'group' => 'System'
-    );
-  }
-
-  /**
-   * Implement setUp().
-   */
-  function setUp() {
-    parent::setUp();
-
-    variable_set('system_settings_form_test', TRUE);
-    variable_set('system_settings_form_test_4', TRUE);
-  }
-
-  /**
-   * Reset page title.
-   */
-  function tearDown() {
-    variable_del('system_settings_form_test');
-    variable_del('system_settings_form_test_4');
-
-    parent::tearDown();
-  }
-
-  /**
-   * Tests the handling of automatic defaults in systems_settings_form().
-   */
-  function testAutomaticDefaults() {
-    $form['system_settings_form_test'] = array(
-      '#type' => 'checkbox',
-      '#default_value' => FALSE,
-    );
-
-    $form['system_settings_form_test_2'] = array(
-      '#type' => 'checkbox',
-      '#default_value' => FALSE,
-    );
-
-    $form['system_settings_form_test_3'] = array(
-      '#type' => 'checkbox',
-      '#default_value' => TRUE,
-    );
-
-    $form['has_children']['system_settings_form_test_4'] = array(
-      '#type' => 'checkbox',
-      '#default_value' => FALSE,
-    );
-
-    $form['has_children']['system_settings_form_test_5'] = array(
-      '#type' => 'checkbox',
-      '#default_value' => TRUE,
-    );
-
-    $automatic = system_settings_form($form, FALSE);
-    $this->assertFalse($automatic['system_settings_form_test']['#default_value']);
-    $this->assertFalse($automatic['system_settings_form_test_2']['#default_value']);
-    $this->assertTrue($automatic['system_settings_form_test_3']['#default_value']);
-    $this->assertFalse($automatic['has_children']['system_settings_form_test_4']['#default_value']);
-    $this->assertTrue($automatic['has_children']['system_settings_form_test_5']['#default_value']);
-
-    $no_automatic = system_settings_form($form);
-    $this->assertTrue($no_automatic['system_settings_form_test']['#default_value']);
-    $this->assertFalse($no_automatic['system_settings_form_test_2']['#default_value']);
-    $this->assertTrue($no_automatic['system_settings_form_test_3']['#default_value']);
-    $this->assertTrue($no_automatic['has_children']['system_settings_form_test_4']['#default_value']);
-    $this->assertTrue($no_automatic['has_children']['system_settings_form_test_5']['#default_value']);
-  }
-}
-
 /**
  * Tests for the theme interface functionality.
  */
Index: modules/statistics/statistics.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.admin.inc,v
retrieving revision 1.39
diff -u -r1.39 statistics.admin.inc
--- modules/statistics/statistics.admin.inc	28 Feb 2010 20:10:34 -0000	1.39
+++ modules/statistics/statistics.admin.inc	26 Jun 2010 03:07:22 -0000
@@ -248,13 +248,13 @@
   $form['access']['statistics_enable_access_log'] = array(
     '#type' => 'checkbox',
     '#title' => t('Enable access log'),
-    '#default_value' => 0,
+    '#default_value' => variable_get('statistics_enable_access_log', 0),
     '#description' => t('Log each page access. Required for referrer statistics.'),
   );
   $form['access']['statistics_flush_accesslog_timer'] = array(
     '#type' => 'select',
     '#title' => t('Discard access logs older than'),
-    '#default_value' => 259200,
+    '#default_value' => variable_get('statistics_flush_accesslog_timer', 259200),
     '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'),
     '#description' => t('Older access log entries (including referrer statistics) will be automatically discarded. (Requires a correctly configured <a href="@cron">cron maintenance task</a>.)', array('@cron' => url('admin/reports/status'))),
   );
@@ -267,7 +267,7 @@
   $form['content']['statistics_count_content_views'] = array(
     '#type' => 'checkbox',
     '#title' => t('Count content views'),
-    '#default_value' => 0,
+    '#default_value' => variable_get('statistics_count_content_views', 0),
     '#description' => t('Increment a counter each time content is viewed.'),
   );
 
Index: modules/user/user.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v
retrieving revision 1.110
diff -u -r1.110 user.admin.inc
--- modules/user/user.admin.inc	27 May 2010 12:29:39 -0000	1.110
+++ modules/user/user.admin.inc	26 Jun 2010 03:07:26 -0000
@@ -635,7 +635,7 @@
     '#rows' => 3,
   );
 
-  return system_settings_form($form, FALSE);
+  return system_settings_form($form);
 }
 
 /**
Index: modules/menu/menu.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.admin.inc,v
retrieving revision 1.80
diff -u -r1.80 menu.admin.inc
--- modules/menu/menu.admin.inc	20 Jun 2010 17:34:51 -0000	1.80
+++ modules/menu/menu.admin.inc	26 Jun 2010 03:07:22 -0000
@@ -681,7 +681,7 @@
   $form['menu_main_links_source'] = array(
     '#type' => 'select',
     '#title' => t('Source for the Main links'),
-    '#default_value' => 'main-menu',
+    '#default_value' => variable_get('menu_main_links_source', 'main-menu'),
     '#options' => $main_options,
     '#tree' => FALSE,
     '#description' => t('Select what should be displayed as the Main links (typically at the top of the page).'),
@@ -691,11 +691,11 @@
   $form['menu_secondary_links_source'] = array(
     '#type' => 'select',
     '#title' => t('Source for the Secondary links'),
-    '#default_value' => 'user-menu',
+    '#default_value' => variable_get('menu_secondary_links_source', 'user-menu'),
     '#options' => $secondary_options,
     '#tree' => FALSE,
     '#description' => t("Select the source for the Secondary links. An advanced option allows you to use the same source for both Main links (currently %main) and Secondary links: if your source menu has two levels of hierarchy, the top level menu links will appear in the Main links, and the children of the active link will appear in the Secondary links." , array('%main' => $main_options[$main])),
   );
 
-  return system_settings_form($form, TRUE);
+  return system_settings_form($form);
 }
Index: modules/search/search.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.admin.inc,v
retrieving revision 1.14
diff -u -r1.14 search.admin.inc
--- modules/search/search.admin.inc	30 Jan 2010 07:59:25 -0000	1.14
+++ modules/search/search.admin.inc	26 Jun 2010 03:07:22 -0000
@@ -83,7 +83,7 @@
   $form['indexing_throttle']['search_cron_limit'] = array(
     '#type' => 'select',
     '#title' => t('Number of items to index per cron run'),
-    '#default_value' => 100,
+    '#default_value' => variable_get('search_cron_limit', 100),
     '#options' => $items,
     '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status')))
   );
@@ -98,7 +98,7 @@
   $form['indexing_settings']['minimum_word_size'] = array(
     '#type' => 'textfield',
     '#title' => t('Minimum word length to index'),
-    '#default_value' => 3,
+    '#default_value' => variable_get('minimum_word_size', 3),
     '#size' => 5,
     '#maxlength' => 3,
     '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).')
@@ -106,7 +106,7 @@
   $form['indexing_settings']['overlap_cjk'] = array(
     '#type' => 'checkbox',
     '#title' => t('Simple CJK handling'),
-    '#default_value' => TRUE,
+    '#default_value' => variable_get('overlap_cjk', TRUE),
     '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.')
   );
 
@@ -116,7 +116,7 @@
   );
   $form['active']['search_active_modules'] = array(
     '#type' => 'checkboxes',
-    '#default_value' => array('node', 'user'),
+    '#default_value' => variable_get('search_active_modules', array('node', 'user')),
     '#options' => _search_get_module_names(),
     '#description' => t('Determine which search modules are active from the available modules.')
   );
@@ -131,7 +131,7 @@
     }
   }
 
-  return system_settings_form($form, TRUE);
+  return system_settings_form($form);
 }
 
 /**
Index: modules/book/book.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.admin.inc,v
retrieving revision 1.35
diff -u -r1.35 book.admin.inc
--- modules/book/book.admin.inc	1 May 2010 08:12:22 -0000	1.35
+++ modules/book/book.admin.inc	26 Jun 2010 03:07:21 -0000
@@ -34,7 +34,7 @@
   $form['book_allowed_types'] = array(
     '#type' => 'checkboxes',
     '#title' => t('Content types allowed in book outlines'),
-    '#default_value' => array('book'),
+    '#default_value' => variable_get('book_allowed_types', array('book')),
     '#options' => $types,
     '#description' => t('Users with the %outline-perm permission can add all content types.', array('%outline-perm' => t('Administer book outlines'))),
     '#required' => TRUE,
@@ -42,14 +42,14 @@
   $form['book_child_type'] = array(
     '#type' => 'radios',
     '#title' => t('Content type for child pages'),
-    '#default_value' => 'book',
+    '#default_value' => variable_get('book_child_type', 'book'),
     '#options' => $types,
     '#required' => TRUE,
   );
   $form['array_filter'] = array('#type' => 'value', '#value' => TRUE);
   $form['#validate'][] = 'book_admin_settings_validate';
 
-  return system_settings_form($form, TRUE);
+  return system_settings_form($form);
 }
 
 /**
Index: modules/forum/forum.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.admin.inc,v
retrieving revision 1.33
diff -u -r1.33 forum.admin.inc
--- modules/forum/forum.admin.inc	24 Apr 2010 14:49:13 -0000	1.33
+++ modules/forum/forum.admin.inc	26 Jun 2010 03:07:22 -0000
@@ -210,25 +210,25 @@
   $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
   $form['forum_hot_topic'] = array('#type' => 'select',
     '#title' => t('Hot topic threshold'),
-    '#default_value' => 15,
+    '#default_value' => variable_get('forum_hot_topic', 15),
     '#options' => $number,
     '#description' => t('The number of replies a topic must have to be considered "hot".'),
   );
   $number = drupal_map_assoc(array(10, 25, 50, 75, 100));
   $form['forum_per_page'] = array('#type' => 'select',
     '#title' => t('Topics per page'),
-    '#default_value' => 25,
+    '#default_value' => variable_get('forum_per_page', 25),
     '#options' => $number,
     '#description' => t('Default number of forum topics displayed per page.'),
   );
   $forder = array(1 => t('Date - newest first'), 2 => t('Date - oldest first'), 3 => t('Posts - most active first'), 4 => t('Posts - least active first'));
   $form['forum_order'] = array('#type' => 'radios',
     '#title' => t('Default order'),
-    '#default_value' => '1',
+    '#default_value' => variable_get('forum_order', 1),
     '#options' => $forder,
     '#description' => t('Default display order for topics.'),
   );
-  return system_settings_form($form, TRUE);
+  return system_settings_form($form);
 }
 
 /**
Index: modules/update/update.settings.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/update/update.settings.inc,v
retrieving revision 1.10
diff -u -r1.10 update.settings.inc
--- modules/update/update.settings.inc	2 Dec 2009 01:05:11 -0000	1.10
+++ modules/update/update.settings.inc	26 Jun 2010 03:07:25 -0000
@@ -47,7 +47,7 @@
     '#description' => t('You can choose to send e-mail only if a security update is available, or to be notified about all newer versions. If there are updates available of Drupal core or any of your installed modules and themes, your site will always print a message on the <a href="@status_report">status report</a> page, and will also display an error message on administration pages if there is a security update.', array('@status_report' => url('admin/reports/status')))
   );
 
-  $form = system_settings_form($form, FALSE);
+  $form = system_settings_form($form);
   // Custom validation callback for the email notification setting.
   $form['#validate'][] = 'update_settings_validate';
   // We need to call our own submit callback first, not the one from
