Issue fork feeds-2306305

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Drupa1ish’s picture

Status: Active » Closed (won't fix)
Drupa1ish’s picture

Title: Mutiple feeds impoter on the same entity should not override each other’s hashes » Mutiple feeds importer on the same entity should not override each other’s hashes
Status: Closed (won't fix) » Needs review
FileSize
3.74 KB

The following patch assumes that patch from #2305751-1: Skip hash check should not update hash column in feeds item table is already applied.
This works for fresh install, with new the primary key in feed_item , we didn't write the update.

- 'primary key' => array('entity_type', 'entity_id'),
+ 'primary key' => array('entity_type', 'entity_id', 'id'),

Status: Needs review » Needs work

The last submitted patch, 2: feeds_importers_separate_hash-2306305-1.patch, failed testing.

Drupa1ish’s picture

Title: Mutiple feeds importer on the same entity should not override each other’s hashes » Multiple feeds importer on the same entity should not override each other’s hashes
lmeurs’s picture

Crosslinking #1539224-63: Add support for unique fields to be unique site wide.

I have not tested the patch, but it seems to create entries in the feeds_item table for each imported or updated entity per importer. This could solve problems with importer ID's and hashes being overwritten when multiple importers update the same entities.

Right now I am swamped with work, but hopefully I will have some time soon to reroll and test your patch with the latest dev release.

Drupa1ish’s picture

Status: Needs work » Needs review
FileSize
3.94 KB

Re-roll for 7.x-2.0-alpha8+84-dev. No need to run #2305751: Skip hash check should not update hash column in feeds item table, is already included.
This works for fresh install, with new the primary key in feed_item , we didn't write the update.

- 'primary key' => array('entity_type', 'entity_id'),
+ 'primary key' => array('entity_type', 'entity_id', 'id'),

Status: Needs review » Needs work

The last submitted patch, 6: feeds_importers_separate_hash-2306305-2.patch, failed testing.

Drupa1ish’s picture

Status: Needs work » Needs review
FileSize
4.02 KB
adrien.felipe’s picture

I have re-rolled patch from #8 against last dev version and added the update function in feeds.install
Be aware this patch will therefore slightly modify your feeds_item table structure:

/**
 * Add id as a primary key of {feeds_item}.
 */
function feeds_update_7213() {
  db_drop_primary_key('feeds_item');
  db_add_primary_key('feeds_item', array('entity_type', 'entity_id', 'id'));
}

Attached patch in conjunction with patch #69 from #1539224-69: Add support for unique fields to be unique site wide works great for me with Commerce product entities, taxonomy terms and nodes.

MegaChriz’s picture

Priority: Minor » Normal
Status: Needs review » Needs work
  1. +++ b/plugins/FeedsProcessor.inc
    @@ -266,7 +266,14 @@ abstract class FeedsProcessor extends FeedsPlugin {
    +        $force_update = $this->config['skip_hash_check'];
             $hash = $this->hash($item);
    +        if ($force_update) {
    +          $feeds_item_info = feeds_item_info_load($this->entityType(), $entity_id, $this->id);
    +          if (is_object($feeds_item_info) && isset($feeds_item_info->hash)) {
    +            $hash = $feeds_item_info->hash;
    +          }
    +        }
    

    This comes from #2305751: Skip hash check should not update hash column in feeds item table and as said there it was not clear why that change is needed for this issue.
    If it is not needed to fix this issue, we should leave it out here.

  2. This could use an automated test. The test should do something like the following:
    1. Create two importers that both have the "update existing nodes" option enabled.
    2. With importer 1, import source file 1. This should create a node.
    3. With importer 2, import source file 2. This should update the node created by importer 1.
    4. Import source file 1 again with importer 1. No nodes should be updated because the hash created during the first import should not have been overwritten.
    5. Import source file 2 again with importer 2. Again no nodes should be updated.
MegaChriz’s picture

Issue tags: +Needs tests
jrusse27’s picture

I've added an updated patch without the the extra code for skipping hash checks, as pointed out it's a separate issue.

MegaChriz’s picture

@jrusse27
Great. Do you want to write a test for this issue as well? See #10 for what should be covered by the test.

Devaraj johnson’s picture

Devaraj johnson’s picture

Patch fix for beta 4 allow unique hash for individual feed. patch reroll

mikran’s picture

Version: 7.x-2.x-dev » 8.x-3.x-dev

This is a problem in D8 version as well.

MegaChriz’s picture

Version: 8.x-3.x-dev » 7.x-2.x-dev

This has been fixed in the 8.x-3.x version in #3105322: Support multiple values for Feeds item so entities can be updated by multiple feeds, so we can move this back to 7.x-2.x if there is still interest to fix it there.

Xperd made their first commit to this issue’s fork.

Xperd’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
7.19 KB

Test from #10 added.