I was setting $node->created in my prepare hook and was banging my head trying to see why it was not getting saved. It turns out that node_migrate_prepare_node() unconditionally sets it to time() unless you set a magic $node->date property. There is no need for this setting to time() in migrate.module - node_save() does this for you already. Also, $node->should be namespaced as $node->migrate_date IMO.

While I was there, I noticed similar handling for node.changed but AFAICT, core does not let the caller specify node.changed at all. This looks like dead code to me, or it requires a core patch that we should make available.

Comments

moshe weitzman’s picture

Title: Don't default node.created to time() » Don't default $node->created to time()
mikeryan’s picture

On the changed issue, node_migrate_import_node gets around that by setting it after node_save(). Although, looking now at the code it should make sure it only does that if a changed value was provided in migration...

mikeryan’s picture

Assigned: Unassigned » mikeryan
Status: Active » Fixed

Fixed. No more 'date' pseudo-field, created and changed are left empty if not explicitly set, and changed is only overridden after node_save if it had been explicitly set.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.