You are here

public function MigrationBase::endProcess in Migrate 7.2

Same name and namespace in other branches
  1. 6.2 includes/base.inc \MigrationBase::endProcess()

End a rollback or import process, releasing the semaphore. Note that it must be public to be callable as the shutdown function.

3 calls to MigrationBase::endProcess()
Migration::endProcess in includes/migration.inc
Override MigrationBase::endProcess, to call post hooks. Note that it must be public to be callable as the shutdown function.
MigrationBase::processImport in includes/base.inc
Perform an operation during the import phase
MigrationBase::processRollback in includes/base.inc
Perform an operation during the rollback phase.
1 method overrides MigrationBase::endProcess()
Migration::endProcess in includes/migration.inc
Override MigrationBase::endProcess, to call post hooks. Note that it must be public to be callable as the shutdown function.

File

includes/base.inc, line 1014
Defines the base class for migration processes.

Class

MigrationBase
The base class for all objects representing distinct steps in a migration process. Most commonly these will be Migration objects which actually import data from a source into a Drupal destination, but by deriving classes directly from MigrationBase…

Code

public function endProcess() {
  if ($this->previousErrorHandler) {
    set_error_handler($this->previousErrorHandler);
    $this->previousErrorHandler = NULL;
  }
  if ($this->processing) {
    $this->status = MigrationBase::STATUS_IDLE;

    // Restore the previous mail handler.
    $this
      ->restoreMailSystem();
    $fields = array(
      'class_name' => get_class($this),
      'status' => MigrationBase::STATUS_IDLE,
    );
    db_merge('migrate_status')
      ->key(array(
      'machine_name' => $this->machineName,
    ))
      ->fields($fields)
      ->execute();

    // Complete the log record
    if ($this->logHistory) {
      try {
        db_merge('migrate_log')
          ->key(array(
          'mlid' => $this->logID,
        ))
          ->fields(array(
          'endtime' => round(microtime(TRUE) * 1000),
          'finalhighwater' => $this
            ->getHighwater(),
          'numprocessed' => $this->total_processed,
        ))
          ->execute();
      } catch (PDOException $e) {
        Migration::displayMessage(t('Could not log operation on migration !name - possibly MigrationBase::beginProcess() was not called', array(
          '!name' => $this->machineName,
        )));
      }
    }
    $this->processing = FALSE;
  }
  self::$currentMigration = NULL;

  // If we're disabling any hooks, reset the static module_implements cache so
  // it is rebuilt again and the specified hooks removed by our
  // hook_module_implements_alter() is recollected. By setting #write_cache to
  // FALSE, we ensure that our munged version of the hooks array does not get
  // written to the persistent cache and interfere with other Drupal processes.
  if (!empty($this->disableHooks)) {
    $implementations =& drupal_static('module_implements');
    $implementations = array();
    $implementations['#write_cache'] = FALSE;
  }
}