I am use FeedAPI with FeedAPI Node to create nodes using RSS feeds, with "Update existing feed items" and "Use time of download" ticked.
I found that after FeedAPI refreshes the feed, changed time and the updated time on these nodes become the same, which is not the expected behaviour. For example, here's the $node object for an item that has been updated:
[nid] => 202
[vid] => 202
[type] => story
[title] => Bomb at Algerian Police Academy Kills 43
[uid] => 54
[status] => 1
[created] => 1219202464
[changed] => 1219202464
[comment] => 2
[promote] => 1
[moderate] => 0 [sticky] => 0
After going through the source, I found the culprit, the function _feedapi_node_save at feedapi_node/feedapi_node.module, line 231.
The following line is wrong, IMHO
$node->created = (isset($settings['node_date']) && $settings['node_date'] == 'feed') ? $feed_item->options->timestamp : time();
For cases as mine, this will always use the most recent update time as the created time. I suggest replacing that line with the following:
if (isset($feed_item->nid)) {
$created_time = $feed_item->arrived;
} else {
$created_time = time();
}
$node->created = (isset($settings['node_date']) && $settings['node_date'] == 'feed') ? $feed_item->options->timestamp : $created_time;
Comments
Comment #1
aron novakI'd prefer the following code:
Does it solve your problem?
Comment #2
aron novakit's committed for both braches.
Comment #3
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.