You are here

protected function MigrateFileBase::markForPreservation in Migrate 7.2

If asked to preserve files from deletion on rollback, add a file_usage entry.

Parameters

$fid:

2 calls to MigrateFileBase::markForPreservation()
MigrateFile::processFile in plugins/destinations/file.inc
Default implementation of MigrateFileInterface::processFiles().
MigrateFileFid::processFile in plugins/destinations/file.inc
Implementation of MigrateFileInterface::processFile().

File

plugins/destinations/file.inc, line 153
Support for file entity as destination. Note that File Fields have their own destination in fields.inc

Class

MigrateFileBase

Code

protected function markForPreservation($fid) {
  if (!empty($this->preserveFiles)) {

    // We do this directly instead of calling file_usage_add, to force the
    // count to 1 - otherwise, updates will increment the counter and the file
    // will never be deletable
    db_merge('file_usage')
      ->key(array(
      'fid' => $fid,
      'module' => 'migrate',
      'type' => 'file',
      'id' => $fid,
    ))
      ->fields(array(
      'count' => 1,
    ))
      ->execute();
  }
}