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

aron novak’s picture

Status: Active » Postponed (maintainer needs more info)

I'd prefer the following code:

if (!isset($feed_item->nid)) {
  $node->created = (isset($settings['node_date']) && $settings['node_date'] == 'feed') ? $feed_item->options->timestamp : time();
}

Does it solve your problem?

aron novak’s picture

Status: Postponed (maintainer needs more info) » Fixed

it's committed for both braches.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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