Skip to content
Snippets Groups Projects
Commit d0dc5e50 authored by Chris Leppanen's avatar Chris Leppanen
Browse files

Fix replace existing behavior.

parent 5f113600
No related branches found
No related tags found
No related merge requests found
...@@ -137,6 +137,8 @@ abstract class FeedsProcessor extends FeedsPlugin { ...@@ -137,6 +137,8 @@ abstract class FeedsProcessor extends FeedsPlugin {
*/ */
public function process(FeedsSource $source, FeedsParserResult $parser_result) { public function process(FeedsSource $source, FeedsParserResult $parser_result) {
$state = $source->state(FEEDS_PROCESS); $state = $source->state(FEEDS_PROCESS);
$entity_info = $this->entityInfo();
$id_key = $entity_info['entity keys']['id'];
while ($item = $parser_result->shiftItem()) { while ($item = $parser_result->shiftItem()) {
...@@ -161,8 +163,10 @@ abstract class FeedsProcessor extends FeedsPlugin { ...@@ -161,8 +163,10 @@ abstract class FeedsProcessor extends FeedsPlugin {
try { try {
$replace_existing = $this->config['update_existing'] == FEEDS_REPLACE_EXISTING;
// Build a new entity. // Build a new entity.
if (empty($entity_id)) { if (!$entity_id || $replace_existing) {
$entity = $this->newEntity($source); $entity = $this->newEntity($source);
$this->newItemInfo($entity, $source->feed_nid, $hash); $this->newItemInfo($entity, $source->feed_nid, $hash);
} }
...@@ -171,12 +175,17 @@ abstract class FeedsProcessor extends FeedsPlugin { ...@@ -171,12 +175,17 @@ abstract class FeedsProcessor extends FeedsPlugin {
else { else {
$entity = $this->entityLoad($source, $entity_id); $entity = $this->entityLoad($source, $entity_id);
// The feeds_item table is always updated with the info for the most recently processed entity. // The feeds_item table is always updated with the info for the most
// The only carryover is the entity_id. // recently processed entity. The only carryover is the entity_id.
$this->newItemInfo($entity, $source->feed_nid, $hash); $this->newItemInfo($entity, $source->feed_nid, $hash);
$entity->feeds_item->entity_id = $entity_id; $entity->feeds_item->entity_id = $entity_id;
} }
if ($entity_id && $replace_existing) {
$entity->is_new = FALSE;
$entity->$id_key = $entity_id;
}
// Set property and field values. // Set property and field values.
$this->map($source, $parser_result, $entity); $this->map($source, $parser_result, $entity);
$this->entityValidate($entity); $this->entityValidate($entity);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment