? 469856-domain-conf-variable-get.patch
? 469856_contributions-modules-domain-HEAD_0.patch
? 486370-lang.patch
Index: domain_conf/domain_conf.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_conf/domain_conf.module,v
retrieving revision 1.46
diff -u -p -r1.46 domain_conf.module
--- domain_conf/domain_conf.module	14 Jun 2009 19:29:49 -0000	1.46
+++ domain_conf/domain_conf.module	27 Jun 2009 14:48:35 -0000
@@ -600,25 +600,26 @@ function domain_conf_language_options() 
  *   Otherwise, return the settings data for the primary domain.
  */
 function _domain_conf_load_primary($unset = FALSE) {
-  global $db_prefix;
   static $settings;
 
-  if (empty($settings)) {
-    $cache = 'cache';
+  if (!isset($settings)) {
     // Account for table prefixing.
-    if (empty($db_prefix)) {
-      $cache_table = $cache;
-    }
-    else if (is_string($db_prefix)) {
-      $cache_table = $db_prefix . $cache;
+    $cache_table = _domain_conf_table_prefix('cache');
+    // Load the query.
+    $data = db_result(db_query("SELECT data FROM $cache_table WHERE cid = 'variables'"));
+    if (!empty($data)) {
+      $settings = unserialize($data);
     }
+    // If the cache has been cleared, this data will be empty.
+    // In this case, grab the data directly from the base {variable} table.
     else {
-      $cache_table = $db_prefix['default'] . $cache;
+      $variable_table = _domain_conf_table_prefix('variable');    
+      $result = db_query("SELECT name, value FROM $variable_table");
+      while ($vars = db_fetch_array($result)) {
+        $data[$vars['name']] = unserialize($vars['value']);
+      }
+      $settings = $data;
     }
-    $cache_table = db_escape_table($cache_table);
-    // Load the query.
-    $data = db_result(db_query("SELECT data FROM $cache_table WHERE cid = 'variables'"));
-    $settings = unserialize($data);
   }
   // Do we reset the global or just return data?
   if ($unset) {
@@ -628,3 +629,22 @@ function _domain_conf_load_primary($unse
   }
   return $settings;
 }
+
+/**
+ * Escape the names of the default tables for variable lookups.
+ *
+ * @param $table
+ *   The name of the base table to lookup.
+ * @return
+ *   A query-safe table name poiting to the primary domain.
+ */
+function _domain_conf_table_prefix($table) {
+  global $db_prefix;
+  if (is_string($db_prefix)) {
+    $table = $db_prefix . $table;
+  }
+  else if (is_array($db_prefix)) {
+    $table = $db_prefix['default'] . $table;
+  }
+  return db_escape_table($table);
+}
