You are here

function domain_update_zero_records in Domain Access 7.3

Turns a domain_id of 0 into the default domain.

Parameters

$tables: An array of database tables to update.

Return value

TRUE on success or FALSE on failure.

3 calls to domain_update_zero_records()
DomainUpdateTest::testDomainUpdate in tests/domain.test
domain_repair_form_submit in ./domain.admin.inc
Repairs references to domain_id 0.
drush_domain_repair in ./domain.drush.inc
Replaces domain_id 0 records with the default domain.

File

./domain.module, line 4053
Core module functions for the Domain Access suite.

Code

function domain_update_zero_records($tables) {
  $default_id = domain_default_id();
  $success = TRUE;
  foreach ($tables as $table) {
    $transaction = db_transaction();
    try {
      db_update($table)
        ->fields(array(
        'domain_id' => $default_id,
      ))
        ->condition('domain_id', 0)
        ->execute();
    } catch (Exception $e) {
      $transaction
        ->rollback();
      watchdog_exception('domain_repair', $e);
      drupal_set_message(t('The update failed due to a duplicate record. You must manually correct the {@table} table in your database.', array(
        '@table' => $table,
      )), 'error');
      $success = FALSE;
    }
  }
  return $success;
}