public function MigrateDestinationNodeRevision::bulkRollback in Migrate 7.2
Rolls back any versions that have been created.
Parameters
array $vids: Version ids to roll back.
Overrides MigrateDestinationNode::bulkRollback
File
- plugins/
destinations/ node.inc, line 393 - Support for node destinations.
Class
- MigrateDestinationNodeRevision
- Allows you to import revisions.
Code
public function bulkRollback(array $vids) {
migrate_instrument_start('revision_delete_multiple');
$this
->prepareRollback($vids);
$nids = array();
foreach ($vids as $vid) {
if ($revision = node_load(NULL, $vid)) {
db_delete('node_revision')
->condition('vid', $revision->vid)
->execute();
module_invoke_all('node_revision_delete', $revision);
field_attach_delete_revision('node', $revision);
$nids[$revision->nid] = $revision->nid;
}
}
$this
->completeRollback($vids);
foreach ($nids as $nid) {
$vid = db_select('node_revision', 'nr')
->fields('nr', array(
'vid',
))
->condition('nid', $nid, '=')
->execute()
->fetchField();
if (!empty($vid)) {
db_update('node')
->fields(array(
'vid' => $vid,
))
->condition('nid', $nid, '=')
->execute();
}
}
migrate_instrument_stop('revision_delete_multiple');
}