Closed (won't fix)
Project:
Migrate
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
26 Apr 2015 at 19:07 UTC
Updated:
15 May 2015 at 17:57 UTC
Jump to comment: Most recent
Comments
Comment #1
osopolarComment #2
mikeryanNo, I don't think so. At the prepare() stage, if an application is messing around with the node object that has already been constructed, it's on that application to make sure the result is self-consistent. It's simply not practical to take the node object after prepare() and figure out what might have changed that would have implications elsewhere.
May I ask, why are you doing this in prepare() rather than filtering the files you want to keep in prepareRow()? That seems much cleaner (and performant, given that files are being copied unnecessarily) than deleting field instances in prepare()...
Comment #3
osopolar@mikeryan: Thanks for asking. I am using the class
MigrateDestinationMediafrom the migrate_extras project where the functionrewriteImgTags()is invoked byprepare(). In some cases this will lead to duplicate files as these images are also part of a file attachment (drupal 5 file upload) migrated to a file field. So I remove files that are already handled by the media module from the file field inprepare(). As there are less than 100 nodes with these attachments the performance aspect is not that important here.Comment #4
mikeryanDon't forget to reset the status from "Postponed (maintainer needs more info)" to Active for greater visibility.
Comment #5
mikeryanIf you're removing duplicates, you would still want to keep the file_managed entry, right? Whichever of the dupes you're keeping will still need to point at it...
Regardless, I'm afraid I just don't see where Migrate can clean this up for you...
Comment #6
osopolarI had in mind that setting
$entity->field_attachment[LANGUAGE_NONE][$delta] = 0would trigger the same mechanism as removing a file from a entity (for example on a node edit form submit). There the usage will be set to 0 an if I remember well it gets removed from the files_managed table too, isn't it. But maybe it is not important, I found a workaround: deleting all unused files with a drush script, see sandbox project file deleteComment #7
mikeryanThe update hooks are able to compare to the original node and see something's been removed, when things are being added and later removed in the prepare() process Migrate has no insight into that.