summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--feeds.module17
-rw-r--r--plugins/FeedsProcessor.inc4
2 files changed, 14 insertions, 7 deletions
diff --git a/feeds.module b/feeds.module
index 71e28f3..80a9f5a 100644
--- a/feeds.module
+++ b/feeds.module
@@ -495,7 +495,7 @@ function feeds_node_insert($node) {
*/
function feeds_node_update($node) {
// Node produced by source.
- feeds_item_info_update($node, $node->nid);
+ feeds_item_info_save($node, $node->nid);
// Source attached to node.
if ($importer_id = feeds_get_importer_id($node->type)) {
@@ -534,7 +534,7 @@ function feeds_taxonomy_term_insert($term) {
* Implements hook_taxonomy_term_update().
*/
function feeds_taxonomy_term_update($term) {
- feeds_item_info_update($term, $term->tid);
+ feeds_item_info_save($term, $term->tid);
}
/**
@@ -558,7 +558,7 @@ function feeds_user_insert(&$edit, $account, $category) {
* Implements hook_user_update().
*/
function feeds_user_update(&$edit, $account, $category) {
- feeds_item_info_update($account, $account->uid);
+ feeds_item_info_save($account, $account->uid);
}
/**
@@ -764,12 +764,17 @@ function feeds_item_info_insert($entity, $entity_id) {
}
/**
- * Updates an item info object in he feeds_item table.
+ * Inserts or updates an item info object in he feeds_item table.
*/
-function feeds_item_info_update($entity, $entity_id) {
+function feeds_item_info_save($entity, $entity_id) {
if (isset($entity->feeds_item)) {
$entity->feeds_item->entity_id = $entity_id;
- drupal_write_record('feeds_item', $entity->feeds_item, array('entity_type', 'entity_id'));
+ if (feeds_item_info_load($entity->feeds_item->entity_type, $entity_id)) {
+ drupal_write_record('feeds_item', $entity->feeds_item, array('entity_type', 'entity_id'));
+ }
+ else {
+ feeds_item_info_insert($entity, $entity_id);
+ }
}
}
diff --git a/plugins/FeedsProcessor.inc b/plugins/FeedsProcessor.inc
index f1a5e85..60662f9 100644
--- a/plugins/FeedsProcessor.inc
+++ b/plugins/FeedsProcessor.inc
@@ -120,8 +120,10 @@ abstract class FeedsProcessor extends FeedsPlugin {
}
else {
$entity = $this->entityLoad($source, $entity_id);
- if ($this->loadItemInfo($entity)) {
+ // If an existing item info can't be loaded, create one.
+ if (!$this->loadItemInfo($entity)) {
$this->newItemInfo($entity, $source->feed_nid, $hash);
+ $entity->feeds_item->entity_id = $entity_id;
}
}
$this->map($source, $parser_result, $entity);