Closed (won't fix)
Project:
Migrate
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Reporter:
Created:
28 Nov 2010 at 00:25 UTC
Updated:
28 Nov 2010 at 01:19 UTC
I noticed that every time I did drush mi the nodes had their menu links removed. Not my favorite feature of Migrate :)
What's causing it is MigrateDestinationNode->import() which calls node_save() with a faux node object which in turn calls menu_node_save(). Because $node->menu['enabled'] hasn't been set (I assume it's the "Provide a menu link" checkbox from the node edit form) menu_node_save() will delete the node's menu link.
To me this seems like a shortcoming in core, maybe affecting other modules like Deploy and Feeds as well? It's not a problem if you first do node_load($node), but you don't always want to do that for performance reasons.
Anyway, the patch solves the problem for now.
| Comment | File | Size | Author |
|---|---|---|---|
| migrate_node_menu_trick.patch | 522 bytes | ximo |
Comments
Comment #1
mikeryanYou had manually changed the node to provide a menu link, correct? The default operation of migration is to treat the source data as the system-of-record - it is intentional and correct that remigration of a node will wipe any manual changes. The alternative is setting the migration systemOfRecord to DESTINATION, which will do a node_load() and only change those fields which are present in the source, maintaining all other data on the destination side. These two alternatives are all that Migrate can reasonably handle automatically - if you need more complex handling, you can attain this by overriding the behavior with an appropriate handler or method. For example, in this case you can override the Migration class prepare() method (don't forget to call the parent!):
Comment #2
ximo commentedThank you for taking the time to explain. Yes, I had manually added menu links for nodes, and wrongly assumed Migrate to be fine with that. I'll go with setting systemOfRecord to DESTINATION – that's exactly what I want.
Thanks also for the quick answer and a great module :)