Index: includes/bootstrap.inc
===================================================================
--- includes/bootstrap.inc	(revision 486)
+++ includes/bootstrap.inc	(working copy)
@@ -237,7 +245,7 @@
   global $base_url, $base_path, $base_root;
 
   // Export the following settings.php variables to the global namespace
-  global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile;
+  global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $multisite_variable;
   $conf = array();
 
   include_once './'. conf_path() .'/settings.php';
@@ -410,8 +418,21 @@
  *   The value of the variable.
  */
 function variable_get($name, $default) {
-  global $conf;
+  global $conf, $multisite_variable;
 
+  // get the multisite variables only once.
+  if (isset($multisite_variable[$name])) {
+    static $fetched;
+    if (!isset($fetched)) {
+      global $conf;
+      $result = db_query('SELECT * FROM {multisite_variable}');
+      while ($variable = db_fetch_object($result)) {
+        $conf[$variable->name] = unserialize($variable->value);
+      }
+      $fetched = 1;
+    }
+  }
+
   return isset($conf[$name]) ? $conf[$name] : $default;
 }
 
@@ -425,14 +446,17 @@
  *   of serialization as necessary.
  */
 function variable_set($name, $value) {
-  global $conf;
+  global $conf, $multisite_variable;
 
-  db_lock_table('variable');
-  db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
-  db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
+  $table = isset($multisite_variable[$name]) ? 'multisite_variable' : 'variable';
+  db_lock_table($table);
+  db_query("DELETE FROM {". $table ."} WHERE name = '%s'", $name);
+  db_query("INSERT INTO {". $table ."} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
   db_unlock_tables();
 
-  cache_clear_all('variables', 'cache');
+  if ($table == 'variable') {
+    cache_clear_all('variables', 'cache');
+  }
 
   $conf[$name] = $value;
 }
@@ -444,10 +468,13 @@
  *   The name of the variable to undefine.
  */
 function variable_del($name) {
-  global $conf;
+  global $conf, $multisite_variable;
 
-  db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
-  cache_clear_all('variables', 'cache');
+  $table = isset($multisite_variable[$name]) ? 'multisite_variable' : 'variable';
+  db_query("DELETE FROM {". $table ."} WHERE name = '%s'", $name);
+  if ($table == 'variable') {
+    cache_clear_all('variables', 'cache');
+  }
 
   unset($conf[$name]);
 }
