Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.160
diff -u -p -r1.160 install.php
--- install.php	17 Mar 2009 15:26:29 -0000	1.160
+++ install.php	22 Mar 2009 10:58:13 -0000
@@ -1099,10 +1099,12 @@ function install_configure_form_validate
 function install_configure_form_submit($form, &$form_state) {
   global $user;
 
-  variable_set('site_name', $form_state['values']['site_name']);
-  variable_set('site_mail', $form_state['values']['site_mail']);
-  variable_set('date_default_timezone', $form_state['values']['date_default_timezone']);
-  variable_set('site_default_country', $form_state['values']['site_default_country']);
+   variable_set(array(
+     'site_name' => $form_state['values']['site_name'],
+     'site_mail' => $form_state['values']['site_mail'],
+     'date_default_timezone' => $form_state['values']['date_default_timezone'],
+     'site_default_country', $form_state['values']['site_default_country'],
+   ));
 
   // Enable update.module if this option was selected.
   if ($form_state['values']['update_status_module'][1]) {
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.272
diff -u -p -r1.272 bootstrap.inc
--- includes/bootstrap.inc	18 Mar 2009 09:21:21 -0000	1.272
+++ includes/bootstrap.inc	22 Mar 2009 10:58:14 -0000
@@ -641,19 +641,32 @@ function variable_get($name, $default = 
  * Set a persistent variable.
  *
  * @param $name
- *   The name of the variable to set.
+ *   The name of the variable to set.  Alternatively, if an associative
+ *   array is passed each key will be taken as the name of a variable and
+ *   the value as the value to set it to.  Setting multiple values in one call
+ *   is faster as the cache need be cleared only once.
  * @param $value
  *   The value to set. This can be any PHP data type; these functions take care
  *   of serialization as necessary.
  */
-function variable_set($name, $value) {
+function variable_set($name, $value = NULL) {
   global $conf;
 
-  db_merge('variable')->key(array('name' => $name))->fields(array('value' => serialize($value)))->execute();
+  // Convert all calls to multi-value so that there's only a single code path.
+  if (!is_array($name)) {
+    $name = array($name => $value);
+  }
+  $variables = $name;
+
+  foreach ($variables as $name => $value) {
+    db_merge('variable')
+      ->key(array('name' => $name))
+      ->fields(array('value' => serialize($value)))
+      ->execute();
+    $conf[$name] = $value;
+  }
 
   cache_clear_all('variables', 'cache');
-
-  $conf[$name] = $value;
 }
 
 /**
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.207
diff -u -p -r1.207 locale.inc
--- includes/locale.inc	19 Mar 2009 10:48:51 -0000	1.207
+++ includes/locale.inc	22 Mar 2009 10:58:16 -0000
@@ -135,8 +135,10 @@ function locale_languages_overview_form_
     $languages[$langcode] = $language;
   }
   drupal_set_message(t('Configuration saved.'));
-  variable_set('language_default', $languages[$form_state['values']['site_default']]);
-  variable_set('language_count', $enabled_count);
+  variable_set(array(
+    'language_default' => $languages[$form_state['values']['site_default']],
+    'language_count' => $enabled_count,
+  ));
 
   // Changing the language settings impacts the interface.
   cache_clear_all('*', 'cache_page', TRUE);
Index: modules/book/book.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.install,v
retrieving revision 1.27
diff -u -p -r1.27 book.install
--- modules/book/book.install	19 Jan 2009 10:46:50 -0000	1.27
+++ modules/book/book.install	22 Mar 2009 10:58:16 -0000
@@ -37,10 +37,12 @@ function _book_install_type_create() {
   $book_node_type = node_type_set_defaults($book_node_type);
   node_type_save($book_node_type);
   // Default to not promoted.
-  variable_set('node_options_book', array('status'));
-  // Use this default type for adding content to books.
-  variable_set('book_allowed_types', array('book'));
-  variable_set('book_child_type', 'book');
+  variable_set(array(
+    'node_options_book' => array('status'),
+    // Use this default type for adding content to books.
+    'book_allowed_types' => array('book'),
+    'book_child_type' => 'book',
+  ));
 }
 
 /**
Index: modules/color/color.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/color/color.module,v
retrieving revision 1.56
diff -u -p -r1.56 color.module
--- modules/color/color.module	18 Feb 2009 14:28:22 -0000	1.56
+++ modules/color/color.module	22 Mar 2009 10:58:16 -0000
@@ -317,8 +317,10 @@ function color_scheme_form_submit($form,
   $paths['files'] = $paths['map'] = array();
 
   // Save palette and logo location.
-  variable_set('color_' . $theme . '_palette', $palette);
-  variable_set('color_' . $theme . '_logo', $paths['target'] . 'logo.png');
+  variable_set(array(
+    'color_' . $theme . '_palette' => $palette,
+    'color_' . $theme . '_logo' => $paths['target'] . 'logo.png',
+  ));
 
   // Copy over neutral images.
   foreach ($info['copy'] as $file) {
@@ -371,8 +373,10 @@ function color_scheme_form_submit($form,
   }
 
   // Maintain list of files.
-  variable_set('color_' . $theme . '_stylesheets', $css);
-  variable_set('color_' . $theme . '_files', $paths['files']);
+  variable_set(array(
+    'color_' . $theme . '_stylesheets' => $css,
+    'color_' . $theme . '_files' => $paths['files'],
+  ));
 }
 
 /**
Index: modules/comment/comment.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v
retrieving revision 1.32
diff -u -p -r1.32 comment.install
--- modules/comment/comment.install	26 Feb 2009 07:30:26 -0000	1.32
+++ modules/comment/comment.install	22 Mar 2009 10:58:16 -0000
@@ -88,9 +88,11 @@ function comment_update_6002() {
   $types = node_get_types();
   foreach ($settings as $setting => $default) {
     $value = variable_get($setting, $default);
+    $variables = array();
     foreach ($types as $type => $object) {
-      variable_set($setting . '_' . $type, $value);
+      $variables[$setting . '_' . $type] = $value;
     }
+    variable_set($variables);
     variable_del($setting);
   }
   return array(array('success' => TRUE, 'query' => 'Global comment settings copied to all node types.'));
Index: modules/simpletest/tests/bootstrap.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/bootstrap.test,v
retrieving revision 1.12
diff -u -p -r1.12 bootstrap.test
--- modules/simpletest/tests/bootstrap.test	31 Jan 2009 16:50:57 -0000	1.12
+++ modules/simpletest/tests/bootstrap.test	22 Mar 2009 10:58:18 -0000
@@ -134,6 +134,8 @@ class BootstrapVariableTestCase extends 
 
   function setUp() {
     parent::setUp('system_test');
+
+    variable_del('simpletest_bootstrap_variable_test');
   }
 
   function getInfo() {
@@ -145,7 +147,7 @@ class BootstrapVariableTestCase extends 
   }
 
   /**
-   * testVariable
+   * Test that we can set and delete a single variable.
    */
   function testVariable() {
     // Setting and retrieving values.
@@ -154,7 +156,7 @@ class BootstrapVariableTestCase extends 
     $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), t('Setting and retrieving values'));
 
     // Make sure the variable persists across multiple requests.
-    $this->drupalGet('system-test/variable-get');
+    $this->drupalGet('system-test/variable-get/simpletest_bootstrap_variable_test');
     $this->assertText($variable, t('Variable persists across multiple requests'));
 
     // Deleting variables.
@@ -175,6 +177,31 @@ class BootstrapVariableTestCase extends 
     $this->assertIdentical(5, variable_get('simpletest_bootstrap_variable_test', 5), t('The default variable parameter is passed through correctly.'));
   }
 
+  /**
+   * Test that we can set and delete multiple variables at once.
+   */
+  function testVariableMultiSet() {
+    // Setting and retrieving values.
+    $variable = $this->randomName();
+    variable_set(array(
+      'simpletest_bootstrap_variable_test' => $variable,
+      'simpletest_bootstrap_variable_test_2' => $variable,
+    ));
+    $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test', NULL), t('Setting and retrieving values'));
+
+    // Make sure the variable persists across multiple requests.
+    $this->drupalGet('system-test/variable-get/simpletest_bootstrap_variable_test');
+    $this->assertText($variable, t('First variable persists across multiple requests'));
+    $this->drupalGet('system-test/variable-get/simpletest_bootstrap_variable_test_2');
+    $this->assertText($variable, t('Second variable persists across multiple requests'));
+
+    // Deleting variables.
+    $default_value = $this->randomName();
+    variable_del('simpletest_bootstrap_variable_test');
+    $variable = variable_get('simpletest_bootstrap_variable_test', $default_value);
+    $this->assertIdentical($variable, $default_value, t('Deleting variables'));
+  }
+
 }
 
 /**
Index: modules/simpletest/tests/system_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/system_test.module,v
retrieving revision 1.8
diff -u -p -r1.8 system_test.module
--- modules/simpletest/tests/system_test.module	9 Dec 2008 11:09:26 -0000	1.8
+++ modules/simpletest/tests/system_test.module	22 Mar 2009 10:58:19 -0000
@@ -43,7 +43,7 @@ function system_test_menu() {
   $items['system-test/variable-get'] = array(
     'title' => 'Variable Get',
     'page callback' => 'variable_get',
-    'page arguments' => array('simpletest_bootstrap_variable_test', NULL),
+    'page arguments' => array(2, NULL),
     'access arguments' => array('access content'),
     'type' => MENU_CALLBACK,
   );
Index: modules/statistics/statistics.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v
retrieving revision 1.299
diff -u -p -r1.299 statistics.module
--- modules/statistics/statistics.module	8 Mar 2009 04:25:06 -0000	1.299
+++ modules/statistics/statistics.module	22 Mar 2009 10:58:19 -0000
@@ -288,9 +288,11 @@ function statistics_block_configure($del
  * Implementation of hook_block_save().
  */
 function statistics_block_save($delta = '', $edit = array()) {
-  variable_set('statistics_block_top_day_num', $edit['statistics_block_top_day_num']);
-  variable_set('statistics_block_top_all_num', $edit['statistics_block_top_all_num']);
-  variable_set('statistics_block_top_last_num', $edit['statistics_block_top_last_num']);
+  variable_set(array(
+    'statistics_block_top_day_num' => $edit['statistics_block_top_day_num'],
+    'statistics_block_top_all_num'=>$edit['statistics_block_top_all_num'],
+    'statistics_block_top_last_num'=>$edit['statistics_block_top_last_num'],
+  ));
 }
 
 /**
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.674
diff -u -p -r1.674 system.module
--- modules/system/system.module	20 Mar 2009 19:18:10 -0000	1.674
+++ modules/system/system.module	22 Mar 2009 10:58:21 -0000
@@ -929,8 +929,10 @@ function system_block_configure($delta =
  */
 function system_block_save($delta = '', $edit = NULL) {
   $image_path = 'misc/' . variable_get('drupal_badge_color', 'powered-blue') . '-' . variable_get('drupal_badge_size', '80x15') . '.png';
-  variable_set('drupal_badge_color', $edit['color']);
-  variable_set('drupal_badge_size', $edit['size']);
+  variable_set(array(
+    'drupal_badge_color'=>$edit['color'],
+    'drupal_badge_size'=>$edit['size'],
+  ));
 }
 
 /**
@@ -1401,6 +1403,7 @@ function system_settings_form_submit($fo
   // Exclude unnecessary elements.
   unset($form_state['values']['submit'], $form_state['values']['reset'], $form_state['values']['form_id'], $form_state['values']['op'], $form_state['values']['form_token'], $form_state['values']['form_build_id']);
 
+  $variables = array();
   foreach ($form_state['values'] as $key => $value) {
     if ($op == t('Reset to defaults')) {
       variable_del($key);
@@ -1409,9 +1412,12 @@ function system_settings_form_submit($fo
       if (is_array($value) && isset($form_state['values']['array_filter'])) {
         $value = array_keys(array_filter($value));
       }
-      variable_set($key, $value);
+      $variables[$key] = $value;
     }
   }
+  if ($variables) {
+    variable_set($variables);
+  }
   if ($op == t('Reset to defaults')) {
     drupal_set_message(t('The configuration options have been reset to their default values.'));
   }
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.971
diff -u -p -r1.971 user.module
--- modules/user/user.module	20 Mar 2009 19:18:10 -0000	1.971
+++ modules/user/user.module	22 Mar 2009 10:58:23 -0000
@@ -1058,8 +1058,10 @@ function user_block_save($delta = '', $e
       break;
 
     case 'online':
-      variable_set('user_block_seconds_online', $edit['user_block_seconds_online']);
-      variable_set('user_block_max_list_count', $edit['user_block_max_list_count']);
+      variable_set(array(
+        'user_block_seconds_online' => $edit['user_block_seconds_online'],
+        'user_block_max_list_count' => $edit['user_block_max_list_count'],
+      ));
       break;
   }
 }
