First off, thanks for this module. It really pushes Feeds and allows us to easily pull data from external systems that don't output a flat feed of all data.
Here is a description of my importers:
- One importer creates feed nodes from a list of users
- Second importer is a selfnode importer that populates these feed nodes
After running the importer which generates feed nodes from a list, it shows '600 nodes imported'. I can then use the 'Delete items' tab on the importer to mass delete and reimport them easily.
The problem I am running into is when these feed nodes self-import, they are no longer 'tracked' by the first importer I've created. If it originally imported 600 nodes, and 100 of those have self-imported, only 500 are shown on the first importer under '# imported items total'. If I choose to 'Delete items' (expecting to delete all 600 that it created), it only deletes the 500 that have not been self-imported. I then have to manually delete the other 100.
Comments
Comment #1
vinmassaro commentedIt seems like once feed nodes self-import, they are then 'owned' by that importer and not by their source importer. Any hints to where this happens in code would be great as I am more than willing to write a patch. Thanks.
Comment #2
twistor commentedThis is a tricky one. I think the current behavior is "correct" in that a the node does own itself. But, it can be a pain.
Comment #3
twistor commentedComment #4
vinmassaro commented@twistor: thanks for the patch, but still no luck. Still seeing the same behavior from the original post.
Comment #5
twistor commentedAhh, it won't switch the items back to being owned by the correct importer, but if you run the master importer they should switch and stay that way.
I realized the correct way to fix this is to create our own tracking table, real patch coming.
Comment #6
vinmassaro commentedHmm, I deleted all nodes, did a fresh import off 600 items, self-imported 50, and it showed 550 imported items when I went to delete. I ran the import again, it said no new items, but the number imported did not change. I then deleted and it only deleted the 550.
Comment #7
arh1 commentedI missed this issue before, but as I work through #2023735: Selfnode processing deleting feed_item db rows, leading to duplicates I'm pretty sure it's a duplicate.
The fundamental issue seems to be that Feeds and Feeds Self Node Processor are competing for the same primary key in feeds_item (entity_type+entity_id), so they'll always create two separate records. The patch in #3 doesn't address that.
@twistor, in #5 it sounds like you're suggesting a table something like feeds_self_node_processor_item . I'm happy to help with a patch, though you'd bang it out much more quickly than I :)
Comment #8
arh1 commentedHere's an initial, very rough pass at a patch. It creates the new feeds_selfnode_processor_feed_item table, and uses that to track self-processing feed node items.
As well as a general review of the approach, there are 3 todo's marked in the code. Let me know your thoughts!
Comment #9
arh1 commentedNew patch with a better approach to the process function (my first todo from #8).
Comment #10
vinmassaro commented@ arh1: thanks for your work on this. I will give your patch a test later this week.
Comment #11
arh1 commented@vinmassaro: sounds good -- let's get this working! I'm anxious to deploy it, too, as the dev version fixes other bugs in beta3 and I'd hate to revert. (Secretly hoping that when we get this issue tidied up we might see a new release soon :) )
I made the issue title more general as I believe is appropriate.
Comment #12
arh1 commentedThis patch gets the feeds item hash from the new tracking table so that it properly only updates the item when its source has changed.
Comment #13
arh1 commentedOops, and we need to override Feeds' hash function so we're comparing apples to apples here and not updating fsnp items unnecessarily. What else am I missing?
Comment #14
vinmassaro commented@arh1: I just tested your patch in #13 and it is working well. I was able to import 900 items, self-import them, then go back to the original importer and delete them all in one shot.
Comment #15
arh1 commented@vinmassaro -- great, glad to hear it. This is a big patch -- I hope we get more eyes on it, especially Twistor's! :)
I'm still poking and testing, but am planning to roll this out into production w/ our site's next release.
Comment #16
twistor commentedThis is looking really good.
What's the difference between this and the parent hash()?
I don't think it needs to stay the same. We can drop entity_type and entity_id.
Let's just make these methods on the processor, and not attach anything to the entity. That will disable the Feeds hook.
hook_entity_delete(), should change to hook_node_delete(). This is the only hook we need.
Moving the feed_item management to the processor is something I'm doing in the 3.x branch of Feeds anyway. It's silly to fire a hook when we know exactly what's happening on import anyway.
Comment #17
arh1 commentedThanks, twistor. Updated patch attached...
Oops -- nothing. :) I thought $this would refer to the FeedsSelfNodeProcessor object as opposed to the FeedsProcessor object such that $this->config['mappings'] would differ, but that's not the case, is it. Removed.
So this has also killed the table's primary key and altered most of the indexes as well. I've added a new primary key for feed_nid -- not sure if that's what we want, or if we want to tweak any other indexes.
Done.
Implemented.
Alright, how's this sitting now? :)
Comment #18
arh1 commentedOops, didn't mean to change Component.
Comment #19
vinmassaro commented@arh1: The patch did not apply for me cleanly since it was not created relative to the module directory. Once I fixed it manually and tested, it worked great. I rerolled the patch to apply against 7.x-1.x HEAD and gave you attribution. Thanks!
Comment #20
arh1 commented@vinmassaro -- Thanks for the re-roll and I'm glad it's working for you. I look forward to this getting committed (or any more feedback from twistor).
Comment #21
t_hall commentedWould this patch solve the issue of Feeds Self Node Processor creating duplicate items? Please correct me if I'm on the wrong path..
Comment #22
arh1 commented@t_hall -- it might... See my comment #7 and linked issue above. If that matches your scenario, you're in the right place (and you should try out the patch in this issue!). If not, you'll probably want to create a new issue and describe your situation in detail.
Comment #23
sjancich commentedThere's a bug in the patch from #19.
The getHash() method returns an object, not the hash value as a string, so therefore the hash check will always fail since we are comparing a string against an object. This caused a massive headache for me because I was mapping an image field in my feed importer. A new copy of the image got added on every update until my server ran out of disk space.
Here is a re-roll of the patch where the getHash() method returns the hash from the DB as a string.
Comment #24
twistor commentedThere's no reason to track the URL and GUID since we don't do unique fields.
Comment #26
twistor commented