Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The preserve_files argument is supposed to keep files from being deleted upon rollback if set to true like so:
$this->addFieldMapping('field_my_field:preserve_files')
->defaultValue(TRUE);
But this isn't working if you're using the MigrateFileUriAsIs destination.
$this->addFieldMapping('field_my_field:file_class')
->defaultValue('MigrateFileUriAsIs');
I'm following up with a patch.
Comment | File | Size | Author |
---|---|---|---|
#1 | migrate-preserve_as_is_files-2172825-1.patch | 500 bytes | mariacha1 |
Comments
Comment #1
mariacha1 CreditAttribution: mariacha1 commentedHere's the patch
Comment #2
jcandan CreditAttribution: jcandan commentedthis patch works. tested locally, and very pleased. please commit to 7.x-2.6-rc1.
Comment #3
mikeryanThe patch looks harmless enough - but can you explain the use case? The MigrateFileUriAsIs class simply copies URIs (which I would expect to be remote - http://example.com/foobar etc.), it does not copy/create any files on the destination side so I would not expect there to be any files to be accidentally deleted. Are you manually copying files into the Drupal files directory and copying relative references directly with MigrateFileUriAsIs? In that case I would use MigrateFileUri with preserve_files set to TRUE and file_replace set to MigrateFile::FILE_EXISTS_REUSE.
Comment #4
pifagor