protected function MigrationBase::beginProcess in Migrate 7.2
Same name and namespace in other branches
- 6.2 includes/base.inc \MigrationBase::beginProcess()
Begin a process, ensuring only one process can be active at once on a given migration.
Parameters
int $newStatus: MigrationBase::STATUS_IMPORTING or MigrationBase::STATUS_ROLLING_BACK
3 calls to MigrationBase::beginProcess()
- Migration::beginProcess in includes/
migration.inc - Override MigrationBase::beginProcess, to make sure the map/message tables are present.
- 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::beginProcess()
- Migration::beginProcess in includes/
migration.inc - Override MigrationBase::beginProcess, to make sure the map/message tables are present.
File
- includes/
base.inc, line 949 - 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
protected function beginProcess($newStatus) {
// So hook_watchdog() knows what migration (if any) is running
self::$currentMigration = $this;
// Try to make the semaphore handling atomic (depends on DB support)
$transaction = db_transaction();
// Save the current mail system, prior to disabling emails.
$this
->saveMailSystem();
// Prevent emails from being sent out during migrations.
$this
->disableMailSystem();
$this->starttime = microtime(TRUE);
// Check to make sure there's no process already running for this migration
$status = $this
->getStatus();
if ($status != MigrationBase::STATUS_IDLE) {
throw new MigrateException(t('There is already an active process on !machine_name', array(
'!machine_name' => $this->machineName,
)));
}
$this->processing = TRUE;
$this->status = $newStatus;
db_merge('migrate_status')
->key(array(
'machine_name' => $this->machineName,
))
->fields(array(
'class_name' => get_class($this),
'status' => $newStatus,
))
->execute();
// Set an error handler for imports
if ($newStatus == MigrationBase::STATUS_IMPORTING) {
$this->previousErrorHandler = set_error_handler(array(
$this,
'errorHandler',
));
}
// Save the initial history record
if ($this->logHistory) {
$this->logID = db_insert('migrate_log')
->fields(array(
'machine_name' => $this->machineName,
'process_type' => $newStatus,
'starttime' => round(microtime(TRUE) * 1000),
'initialHighwater' => $this
->getHighwater(),
))
->execute();
}
// If we're disabling any hooks, reset the static module_implements cache so
// it is rebuilt with the specified hooks removed by our
// hook_module_implements_alter(). 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;
}
}