I'm using working with cck fields, one of them has a to_date. In the field properties is set that it has to be as the value (date_from) if no value is provided fro the user BUT when i do the import with migrate module and i re-edit the nodes to check values imported, i get all value2 (date_to) witn no value set, empty...
Right now i solved with a "bulk operations" view and this php script:
if (!$object->field_date[0]['value2']) $object->field_date[0]['value2']= $object->field_date[0]['value']
node_save($object);
i would like to know id it's a bug, or something i'm doing wrong.
Comments
Comment #1
amolinari commentedComment #2
mikeryanCCK support has been moved to the migrate_extras module.
Comment #3
nauthiz693 commentedThis is a bug, as far as I can tell. The bug is in content.migrate.inc on line 164:
$node->$field_name += array($delta => array($column => $value));The date fields that include a 'to' date are listed as one 'field' in the node - so what this code ends up trying to do is to add two arrays that look like this:
1. array(0 => (value => SOME_VALUE))
2. array(0 => (value2 => SOME_OTHER_VALUE))
With the goal to get an array that looks like this:
array(0 => (value => SOME_VALUE, value2 => SOME_OTHER_VALUE))
But php doesn't let you add arrays like this (at least in a couple a tests I did in PHP 5.2.12 - this might have been written for and work in PHP 5.3, but I don't know).
Anyway, if you replace the code (in content.migrate.inc line 164) with:
Alternately, you can implement the method hook_migrate_prepare_node and set the 'to date' there.
Also note, if the 'to date' is required and it doesn't find one (which it won't, because of this bug) migrate won't set the from date properly either.
Comment #4
stella commentedHere's a patch which implements a similar, but slightly different, solution. Note, this doesn't just affect date fields. For example a CCK textarea field also has the same problem as the 'format' value is never migrated.
Comment #5
stella commentedComment #6
nauthiz693 commentedHah, yay. I spent like an hour trying to do it that way, but I didn't know and couldn't figure out the syntax for telling php which variable to apply the array index to (putting the brackets around the variable). Thanks, good thing to learn!
Comment #7
frankcarey commentedcommitted to dev
Comment #8
frankcarey commented