Problem: Implementors of hook_feeds_after_import() have no way of knowing if the import process of the Feeds source failed with an exception. This is a problem, because they cannot react if errors occur and will just execute what they are doing. In my case 1000 nodes got unpublished because the feed could not be fetched due to networking problems.

Solution: Store the exception on the feeds source object, so that subsequent implementors can check if something went wrong.

CommentFileSizeAuthor
#1 feeds-exceptions-2192851-1.patch1.68 KBklausi

Comments

klausi’s picture

Status: Active » Needs review
StatusFileSize
new1.68 KB

patch attached.

twistor’s picture

Status: Needs review » Fixed

Makes sense. I added a note that the exception should not be thrown from the hook.

http://drupalcode.org/project/feeds.git/commit/0ba4a84

No backport needed since hook_feeds_after_import doesn't get called if there was an exception in 6.x.

Now I wonder if I was premature in committing this. Does it even make sense to call the hook during an exception? I guess it gives the most flexibility, but it seems to me that 99% of hooks will only want to execute if there was no error.

klausi’s picture

I want some hook to be fired if exceptions occur, because I want to react in case of errors (notify an admin, disable the feed, whatever). In case we don't execute the hook what else could I use?

Status: Fixed » Closed (fixed)

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