diff --git a/domain.admin.inc b/domain.admin.inc
index 1becf8d..1c6f06b 100644
--- a/domain.admin.inc
+++ b/domain.admin.inc
@@ -370,6 +370,7 @@ function domain_values_from_form_state($form_state) {
     'domain_id' => $form_state['values']['domain_id'],
     'weight' => $form_state['values']['weight'],
     'is_default' => $form_state['values']['is_default'],
+    'machine_name' => $form_state['values']['machine_name'],
   );
 }
 
@@ -424,7 +425,7 @@ function domain_form($form, $form_state, $domain = array(), $arguments = array()
   else {
     $description = t('Can contain lowercase alphanumeric and ASCII characters, dashes and a colon (if using alternative ports).');
   }
-  $form['domain']['subdomain'] = array(
+  $form['subdomain'] = array(
     '#type' => 'textfield',
     '#title' => t('Domain'),
     '#size' => 40,
@@ -433,7 +434,16 @@ function domain_form($form, $form_state, $domain = array(), $arguments = array()
     '#default_value' => $domain['subdomain'],
     '#description' => t('The allowed domain, using the full <em>path.example.com</em> format. Leave off the http:// and the trailing slash and do not include any paths.') . ' ' . $description
   );
-  $form['domain']['sitename'] = array(
+  $form['machine_name'] = array(
+    '#type' => 'machine_name',
+    '#machine_name' => array(
+      'source' => array('subdomain'),
+      'exists' => 'domain_check_machine_name',
+    ),
+    '#default_value' => $domain['machine_name'],
+    '#disabled' => !empty($domain['machine_name']),
+  );
+  $form['sitename'] = array(
     '#type' => 'textfield',
     '#title' => t('Site name'),
     '#size' => 40,
@@ -442,7 +452,7 @@ function domain_form($form, $form_state, $domain = array(), $arguments = array()
     '#default_value' => $domain['sitename'],
     '#description' => t('The human-readable name of this domain.')
   );
-  $form['domain']['scheme'] = array(
+  $form['scheme'] = array(
     '#type' => 'radios',
     '#title' => t('Domain URL scheme'),
     '#required' => TRUE,
@@ -450,7 +460,7 @@ function domain_form($form, $form_state, $domain = array(), $arguments = array()
     '#default_value' => !empty($domain['scheme']) ? $domain['scheme'] : 'http',
     '#description' => t('The URL scheme for accessing this domain.')
   );
-  $form['domain']['valid'] = array(
+  $form['valid'] = array(
     '#type' => 'radios',
     '#title' => t('Domain status'),
     '#required' => TRUE,
@@ -464,7 +474,7 @@ function domain_form($form, $form_state, $domain = array(), $arguments = array()
       $next_weight = $record['weight'];
     }
   }
-  $form['domain']['weight'] = array(
+  $form['weight'] = array(
     '#type' => 'weight',
     '#title' => t('Weight'),
     '#required' => TRUE,
@@ -472,7 +482,7 @@ function domain_form($form, $form_state, $domain = array(), $arguments = array()
     '#default_value' => isset($domain['weight']) ? $domain['weight'] : $next_weight + 1,
     '#description' => t('The sort order for this record. Lower values display first.'),
   );
-  $form['domain']['is_default'] = array(
+  $form['is_default'] = array(
     '#type' => 'checkbox',
     '#title' => t('Default domain'),
     '#default_value' => isset($domain['is_default']) ? $domain['is_default'] : 0,
@@ -481,8 +491,8 @@ function domain_form($form, $form_state, $domain = array(), $arguments = array()
   // If the server did not respond properly, do not allow this record to be set
   // as the default domain.
   if ($error) {
-    $form['domain']['is_default']['#description'] .= '<br />' . t('<strong>This domain did not respond correctly. It cannot be set as your primary domain unless you select <em>Ignore server response warning</em></strong>.');
-    $form['domain']['ignore'] = array(
+    $form['is_default']['#description'] .= '<br />' . t('<strong>This domain did not respond correctly. It cannot be set as your primary domain unless you select <em>Ignore server response warning</em></strong>.');
+    $form['ignore'] = array(
       '#type' => 'checkbox',
       '#title' => t('Ignore server response warning'),
       '#default_value' => 0,
@@ -500,7 +510,7 @@ function domain_form($form, $form_state, $domain = array(), $arguments = array()
 function domain_form_validate($form, &$form_state) {
   $subdomain = $form_state['values']['subdomain'];
   $error_list = array();
-  $domain_changed = (bool) strcmp($form_state['values']['subdomain'], $form['domain']['subdomain']['#default_value']);
+  $domain_changed = (bool) strcmp($form_state['values']['subdomain'], $form['subdomain']['#default_value']);
   if ($domain_changed && !domain_unique_domain($subdomain)) {
     $error_list[] = t('The domain value must be unique.');
   }
diff --git a/domain.install b/domain.install
index 1f79b66..661661e 100644
--- a/domain.install
+++ b/domain.install
@@ -19,19 +19,24 @@ function domain_schema() {
   $schema['domain'] = array(
     'description' => 'The base table for domain records',
     'fields' => array(
-      'domain_id' => array('type' => 'serial', 'not null' => TRUE, 'description' => 'Primary key'),
+      'domain_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Domain numeric id.'),
       'subdomain' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', 'description' => 'Registered DNS entry, will match HTTP_HOST requests'),
       'sitename' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '', 'description' => 'Site display name'),
       'scheme' => array('type' => 'varchar', 'length' => '8', 'not null' => TRUE, 'default' => 'http', 'description' => 'Protocol'),
       'valid' => array('type' => 'varchar', 'length' => '1', 'not null' => TRUE, 'default' => '1', 'description' => 'Active status'),
       'weight' => array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0, 'description' => 'Sort order'),
-      'is_default' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Indicates primary domain')),
+      'is_default' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Indicates primary domain'),
+      'machine_name' => array('type' => 'varchar', 'length' => '40', 'not null' => TRUE, 'default' => '', 'description' => 'The machine name for this domain.')),
     'primary key' => array('domain_id'),
     'indexes' => array(
       'subdomain' => array('subdomain'),
       'weight' => array('weight'),
       'is_default' => array('is_default'),
     ),
+    'foreign_keys' => array(
+      'domain_id' => array('domain_export' => 'domain_id'),
+      'machine_name' => array('domain_export' => 'machine_name'),
+    ),
   );
   $schema['domain_access'] = array(
     'description' => 'Stores domain information for each node',
@@ -58,6 +63,17 @@ function domain_schema() {
       'domain_id' => array('domain' => 'domain_id'),
     ),
   );
+  $schema['domain_export'] = array(
+    'description' => 'Stores canonical machine names for domains.',
+    'fields' => array(
+      'domain_id' => array('type' => 'serial', 'description' => 'Domain id. Automatic master key.'),
+      'machine_name' => array('type' => 'varchar', 'length' => '40', 'not null' => TRUE, 'default' => '', 'description' => 'The machine name for this domain.'),
+      'last_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The previous domain_id, referenced during updates.')),
+    'primary key' => array('machine_name'),
+    'indexes' => array(
+      'domain_id' => array('domain_id')
+    ),
+  );
   return $schema;
 }
 
@@ -105,7 +121,7 @@ function domain_uninstall() {
 /**
  * Update block deltas to Drupal 7.
  */
-function domain_update_7000() {
+function domain_update_7000(&$sandbox) {
   // Get an array of the renamed block deltas, organized by module.
   $renamed_deltas = array(
     'domain' => array(
@@ -120,7 +136,7 @@ function domain_update_7000() {
 /**
  * Change the edit and delete permissions.
  */
-function domain_update_7001() {
+function domain_update_7001(&$sandbox) {
   db_update('role_permission')
     ->condition('permission', 'edit domain nodes')
     ->fields(array('permission' => 'edit domain content'))
@@ -135,7 +151,7 @@ function domain_update_7001() {
 /**
  * Add sorting to domains.
  */
-function domain_update_7300() {
+function domain_update_7300(&$sandbox) {
   if (db_field_exists('domain', 'weight')) {
     return('No update required');
   }
@@ -148,7 +164,7 @@ function domain_update_7300() {
 /**
  * Add default domain flag and weight the default higher.
  */
-function domain_update_7301() {
+function domain_update_7301(&$sandbox) {
   if (db_field_exists('domain', 'is_default')) {
     return('No update required');
   }
@@ -164,7 +180,7 @@ function domain_update_7301() {
 /**
  * Add an index on {domain}.is_default.
  */
-function domain_update_7302() {
+function domain_update_7302(&$sandbox) {
   if (!db_index_exists('domain', 'is_default')) {
     db_add_index('domain', 'is_default', array('is_default'));
   }
@@ -173,7 +189,7 @@ function domain_update_7302() {
 /**
  * Remove the zero record from the database.
  */
-function domain_update_7303() {
+function domain_update_7303(&$sandbox) {
   // We grab the default domain, remove it from the database, and
   // then re-save it into the table, using the new value as the default domain.
   $default = db_query("SELECT * FROM {domain} WHERE domain_id = 0")->fetchAssoc();
@@ -214,3 +230,70 @@ function domain_update_7303() {
   // Update message.
   return t('Domain Access updated successfully');
 }
+
+/**
+ * Allow domains to be made exportable.
+ */
+function domain_update_7304(&$sandbox) {
+  if (db_table_exists('domain_export')) {
+    return t('{domain_export} table exists.');
+  }
+  $schema = array(
+    'description' => 'Stores canonical machine names for domains.',
+    'fields' => array(
+      'domain_id' => array('type' => 'serial', 'description' => 'Domain id. Automatic master key.'),
+      'machine_name' => array('type' => 'varchar', 'length' => '40', 'not null' => TRUE, 'default' => '', 'description' => 'The machine name for this domain.'),
+      'last_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The previous domain_id, referenced during updates.')),
+    'primary key' => array('machine_name'),
+    'indexes' => array(
+      'domain_id' => array('domain_id')
+    ),
+  );
+  db_create_table('domain_export', $schema);
+  return t('{domain_export} table created.');
+}
+
+/**
+ * Rebuild the {domain} table.
+ */
+function domain_update_7305(&$sandbox) {
+  // Reset the domain_id field as a plain integer.
+  db_drop_primary_key('domain');
+  $spec = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Domain numeric id.');
+  db_change_field('domain', 'domain_id', 'domain_id', $spec);
+
+  // Add the machine name column.
+  if (!db_field_exists('domain', 'machine_name')) {
+    $spec = array('type' => 'varchar', 'length' => '40', 'not null' => TRUE, 'default' => '', 'description' => 'The machine name for this domain.');
+    db_add_field('domain', 'machine_name', $spec);
+  }
+
+  // Now we can safely add the new primary key.
+  db_add_primary_key('domain', array('domain_id'));
+
+  return t('{domain} table updated.');
+}
+
+/**
+ * Insert existing domain records into {domain_export} and {domain}.
+ */
+function domain_update_7306(&$sandbox) {
+  $domains = db_query("SELECT domain_id, subdomain FROM {domain} ORDER BY domain_id")->fetchAll();
+  foreach ($domains as $domain) {
+    $query = db_insert('domain_export')
+      ->fields(array(
+        'domain_id' => $domain->domain_id,
+        'machine_name' => domain_machine_name($domain->subdomain),
+        'export_status' => DOMAIN_EXPORT_STATUS_DATABASE,
+      ));
+    $query->execute();
+    $query = db_update('domain')
+      ->condition('domain_id', $domain->domain_id)
+      ->fields(array(
+        'machine_name' => domain_machine_name($domain->subdomain),
+      ));
+    $query->execute();
+  }
+
+  return t('{domain_export} table populated.');
+}
diff --git a/domain.module b/domain.module
index 35f5054..6f1a13e 100644
--- a/domain.module
+++ b/domain.module
@@ -36,6 +36,12 @@ define('DOMAIN_ASSIGN_USERS', TRUE);
 define('DOMAIN_LIST_SIZE', 25);
 
 /**
+ * Defines the export statuses for a domain.
+ */
+define('DOMAIN_EXPORT_STATUS_DATABASE', 0);
+define('DOMAIN_EXPORT_STATUS_CODE', 1);
+
+/**
  * Module setup tasks.
  *
  * 1. Adds the domain user data to the $user object.
@@ -382,6 +388,9 @@ function domain_hook_info() {
   $hooks['domain_cron'] = array(
     'group' => 'domain',
   );
+  $hooks['domain_features_rebuild'] = array(
+    'group' => 'domain',
+  );
   $hooks['domain_install'] = array(
     'group' => 'domain',
   );
@@ -912,14 +921,22 @@ function domain_save($values, $form_values = array()) {
   if (!$count) {
     $values['is_default'] = 1;
   }
-  // Update or insert a record?
-  $update = (isset($values['domain_id']) && is_numeric($values['domain_id'])) ? array('domain_id') : array();
 
-  if (!empty($update)) {
+  // Ensure we have a machine name.
+  if (!isset($values['machine_name'])) {
+    $values['machine_name'] = domain_machine_name($values['subdomain']);
+  }
+  // Update or insert a record?
+  $check = domain_check_machine_name($values['machine_name']);
+  if ($check) {
     $action = 'domain_update';
+    $update = array('machine_name');
+    $update_id = array('domain_id');
   }
   else {
     $action = 'domain_insert';
+    $update = array();
+    $update_id = array();
   }
 
   // If this is the default domain, reset other domains.
@@ -929,7 +946,10 @@ function domain_save($values, $form_values = array()) {
       ->execute();
   }
 
-  drupal_write_record('domain', $values, $update);
+  // Store the data, using the machine_name to generate a numeric id.
+  // Note that we _must_ have a numeric key for {node_access}.
+  drupal_write_record('domain_export', $values, $update);
+  drupal_write_record('domain', $values, $update_id);
 
   // Let other modules act on a proper copy of the domain.
   $domain = domain_lookup(NULL, $values['subdomain'], TRUE);
@@ -975,6 +995,9 @@ function domain_delete($domain, $values = array()) {
   db_delete('domain')
     ->condition('domain_id', $domain['domain_id'])
     ->execute();
+  db_delete('domain_export')
+    ->condition('domain_id', $domain['domain_id'])
+    ->execute();
 
   // In all cases, we need to force a menu rebuild, which also clears the cache.
   menu_rebuild();
@@ -1012,7 +1035,13 @@ function domain_lookup($domain_id = NULL, $subdomain = NULL, $reset = FALSE) {
   }
   // Get the data from the database. Doing this prevents extra queries.
   if (!isset($result) || $reset) {
-    $result = db_query("SELECT domain_id, subdomain, sitename, scheme, valid, weight, is_default FROM {domain}", array(), array('fetch' => PDO::FETCH_ASSOC))->fetchAllAssoc('domain_id');
+    // Temporary hack for update to 7.x.3.
+    if (db_table_exists('domain_export')) {
+      $result = db_query("SELECT domain_id, subdomain, sitename, scheme, valid, weight, is_default, machine_name FROM {domain}", array(), array('fetch' => PDO::FETCH_ASSOC))->fetchAllAssoc('domain_id');
+    }
+    else {
+      $result = db_query("SELECT domain_id, subdomain, sitename, scheme, valid, weight, is_default FROM {domain}", array(), array('fetch' => PDO::FETCH_ASSOC))->fetchAllAssoc('domain_id');
+    }
   }
   // If both are NULL, no lookup can be run.
   if ((is_null($domain_id) && is_null($subdomain)) || $domain_id < 0) {
@@ -1121,18 +1150,19 @@ function domain_set_primary_domain() {
   }
   $check = (bool) db_query("SELECT COUNT(domain_id) FROM {domain} WHERE is_default = 1")->fetchField();
   if (empty($check)) {
-    db_insert('domain')
-      ->fields(array(
-          'subdomain' => $root,
-          'sitename' => $site,
-          'scheme' => $scheme,
-          'weight' => -1,
-          'valid' => 1,
-          'is_default' => 1,
-      ))
-      ->execute();
-    // Allow other modules to respond to changes.
-    module_invoke_all('domain_update', domain_default(TRUE));
+    $domain = array(
+      'subdomain' => $root,
+      'sitename' => $site,
+      'scheme' => $scheme,
+      'weight' => -1,
+      'valid' => 1,
+      'is_default' => 1,
+      'machine_name' => domain_machine_name($root),
+      'export_status' => DOMAIN_EXPORT_STATUS_DATABASE,
+    );
+    drupal_write_record('domain_export', $domain);
+    drupal_write_record('domain', $domain);
+    module_invoke_all('domain_insert', $domain, array());
   }
 }
 
@@ -3082,3 +3112,153 @@ function domain_reassign($old_domain, $new_domain, $table) {
   // Notify that node access needs to be rebuilt.
   node_access_needs_rebuild(TRUE);
 }
+
+/**
+ * Implements hook_features_api().
+ */
+function domain_features_api() {
+  $components = array(
+    'domain' => array(
+      'name' => t('Domains'),
+      'default_hook' => 'domain_default_domains',
+      'default_file' => FEATURES_DEFAULTS_CUSTOM,
+      'default_filename' => 'domains',
+      'features_source' => TRUE,
+      'file' => drupal_get_path('module', 'domain') .'/domain.features.inc',
+    ),
+  );
+  return $components;
+}
+
+/**
+ * Loads a domain from it's machine name.
+ *
+ * @param $machine_name
+ *  The machine name (subdomain) of the domain record.
+ * @param $full
+ *  Boolean indicator to run hook_domain_load() or not.
+ *
+ * @return
+ *  A Domain array or -1 on failure.
+ */
+function domain_machine_name_load($machine_name, $full = FALSE) {
+  if ($full) {
+    return domain_lookup(NULL, $machine_name);
+  }
+  return db_query('SELECT * FROM {domain} WHERE machine_name = :machine_name', array(':machine_name' => $machine_name))->fetchAssoc();
+}
+
+/**
+ * Create a machine name for a domain record.
+ *
+ * @param $subdomain
+ *  The subdomain string of the record, which should be unique.
+ *
+ * @return
+ *  A string with dot and colon transformed to underscore.
+ */
+function domain_machine_name($subdomain) {
+  return preg_replace('/[^a-z0-9_]+/', '_', $subdomain);
+}
+
+/**
+ * Checks for unique value of the machine name.
+ *
+ * @param $machine_name
+ *  The machine name (subdomain) of the domain record.
+ *
+ * @return
+ *  Boolean TRUE or FALSE.
+ */
+function domain_check_machine_name($machine_name) {
+  return (bool) db_query("SELECT COUNT(1) FROM {domain} WHERE machine_name = :machine_name", 
+    array(':machine_name' => $machine_name)
+    )->fetchField();
+}
+
+/**
+ * Loads a domain from its machine name.
+ *
+ * @param $machine_name
+ *  The machine name (subdomain) of the domain record.
+ *
+ * @return
+ *  A Domain id key.
+ */
+function domain_load_domain_id($machine_name) {
+  return db_query('SELECT domain_id FROM {domain_export} WHERE machine_name = :machine_name', array(':machine_name' => $machine_name))->fetchField();
+}
+
+
+/**
+ * Loads a machine name from its domain id.
+ *
+ * @param $domain_id
+ *  The id of the domain record.
+ *
+ * @return
+ *  A Domain machine name.
+ */
+function domain_load_machine_name($domain_id) {
+  return db_query('SELECT machine_name FROM {domain_export} WHERE domain_id = :domain_id', array(':domain_id' => $domain_id))->fetchField();
+}
+
+/**
+ * Features doesn't know how to load custom includes.
+ *
+ * @param $module
+ *  The name of the feature to load.
+ * @param $hook
+ *  The name of the domain hook.
+ * @param $return
+ *  Boolean indicator to return the results of the function.
+ *
+ * @return
+ *  The results of the $hook implemenation, if requested.
+ */
+function domain_features_load($module, $hook, $return = TRUE) {
+  // Features does not handle module loading of custom files.
+  module_load_include('inc', $module, $module . '.domains');
+  $function = $module . '_' . $hook;
+  if ($return && function_exists($function)) {
+    return $function();
+  }
+}
+
+/**
+ * Sets domain export options consistently.
+ *
+ * @return
+ *  An array of form options. Not that we cannot use _ in keys.
+ */
+function domain_features_get_options() {
+  $options = array('all-domains' => t('Export all domains'));
+  foreach (domain_domains() as $domain) {
+    $options[$domain['subdomain']] = $domain['subdomain'];
+  }
+  return $options;
+}
+
+/**
+ * Processes export data selections consistently.
+ *
+ * @param $data
+ *  Array of selections from the features component form.
+ *
+ * @return
+ *  An array of domains, keyed by domain_id.
+ */
+function domain_features_selection($data) {
+  $list = array();
+  if (!empty($data['all-domains'])) {
+    $list = domain_domains();
+  }
+  else {
+    foreach ($data as $subdomain) {
+      $record = domain_lookup(NULL, $subdomain);
+      $list[$record['domain_id']] = $record;
+    }
+  }
+  return $list;
+}
+
diff --git a/domain_alias/domain_alias.module b/domain_alias/domain_alias.module
index d7787a1..0447bf0 100755
--- a/domain_alias/domain_alias.module
+++ b/domain_alias/domain_alias.module
@@ -404,3 +404,20 @@ function _domain_alias_link($alias, $domain, $request, $active = 0) {
   }
   return $link;
 }
+
+/**
+ * Implements hook_features_api().
+ */
+function domain_alias_features_api() {
+  $components = array(
+    'domain_alias' => array(
+      'name' => t('Domain aliases'),
+      'default_hook' => 'domain_alias_default_aliases',
+      'default_file' => FEATURES_DEFAULTS_CUSTOM,
+      'default_filename' => 'domains',
+      'features_source' => TRUE,
+      'file' => drupal_get_path('module', 'domain_alias') .'/domain_alias.features.inc',
+    ),
+  );
+  return $components;
+}
diff --git a/tests/domain.test b/tests/domain.test
index 1e764ec..567cb89 100644
--- a/tests/domain.test
+++ b/tests/domain.test
@@ -27,6 +27,7 @@ class DomainTestCase extends DrupalWebTestCase {
     }
     // Build the {domain} table for this test run.
     db_query("TRUNCATE {domain}");
+    db_query("TRUNCATE {domain_export}");
     domain_set_primary_domain();
     db_query("UPDATE {domain} SET sitename = 'TestDomainSitename' WHERE is_default = 1");
 
@@ -130,8 +131,18 @@ class DomainInstallTest extends DomainTestCase {
 
   // If the default domain is not in the database, the sitename will be default sitename.
   public function testDomainInstall() {
-    $domain = db_query("SELECT sitename FROM {domain} WHERE is_default = 1")->fetch();
-    $this->assertTrue($domain->sitename == 'TestDomainSitename', t('Default domain created successfully'));
+    $domain = domain_default(TRUE, FALSE);
+    $this->assertTrue($domain['sitename'] == 'TestDomainSitename', t('Default domain created successfully'));
+    $records = db_query("SELECT COUNT(domain_id) FROM {domain_export}")->fetchField();
+    $this->assertTrue($records == 1, t('{domain_export} has one record.'));
+    $domains = db_query("SELECT COUNT(domain_id) FROM {domain}")->fetchField();
+    $this->assertTrue($domains == 1, t('{domain} has one record.'));
+    $join = db_query("SELECT COUNT(d.domain_id) FROM {domain} d INNER JOIN {domain_export} de ON d.domain_id = de.domain_id")->fetchField();
+    $this->assertTrue($join == 1, t('Database counts match.'));
+    $join2 = db_query("SELECT COUNT(d.domain_id) FROM {domain} d INNER JOIN {domain_export} de ON d.domain_id = de.domain_id WHERE d.domain_id = 1")->fetchField();
+    $this->assertTrue($join2 == 1, t('Database records match.'));
+    $join = db_query("SELECT COUNT(d.domain_id) FROM {domain} d INNER JOIN {domain_export} de ON d.machine_name = de.machine_name")->fetchField();
+    $this->assertTrue($join == 1, t('Machine names match.'));
   }
 
   // Check the existence of our default grant.
@@ -182,7 +193,7 @@ class DomainCreateTest extends DomainTestCase {
   function testDomainCreate() {
     $setup = $this->domainCreateDomains();
     $result = db_query("SELECT sitename, subdomain FROM {domain} WHERE is_default = 0 ORDER BY weight");
-
+    $domains = array();
     foreach ($result as $record) {
       $domains[$record->sitename] = array('sitename' => $record->sitename, 'subdomain' => $record->subdomain);
     }
