Quantcast
Channel: FeedBunch:34cac4333624170fed210ff2d113469c380d7398 commits
Viewing all articles
Browse latest Browse all 39

Fix to validation errors when fetching feeds

$
0
0
When processing entries in a just fetched feed, we build new entries with ```feed.entries.build``` before knowing if we actually are going to save the entry in the database. It's possible that the entry won't actually be saved (e.g. we have fetched an entry with the same guid as another entry for the same feed already in the db). In this case we MUST ensure that this new entry, which won't be saved in the db, doesn't stay in the feed.entries association. Otherwise any attempt to save the feed afterwards (e.g. feed.save or feed.update) will fail because it also attempts to save the associated entries and the feed.entries association in this case contains an invalid entry. The fix is: - if the entry is actually saved in the db, invoke feed.save!. This also saves the entry we created with feed.entries.build. - if the entry is not saved because one of the validations in EntryManager fails, reload the feed (feed.reload) so that the entries association is reloaded from the db, discarding the invalid entry - if any exception is raised during processing entries, reload the feed (feed.reload) just in case, to make doubly sure that when EntryManager.save_new_entries returns the feed object and its feed.entries association is in a valid state and can be saved in the db.

Viewing all articles
Browse latest Browse all 39

Trending Articles