The feed aggregator seems to mess up the (mySQL) database, when multiple catagories have been assigned to a rss feed.

When you run cron, following error will be displayed.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-281' for key 1: UPDATE {aggregator_category_item} SET cid=:db_update_placeholder_0 WHERE ( (iid = :db_condition_placeholder_0) ); Array ( [:db_update_placeholder_0] => 1 [:db_condition_placeholder_0] => 281 ) in aggregator_save_item() (line 170 of /***/aggregator/aggregator.processor.inc).

CommentFileSizeAuthor
#4 aggregator_fix_wrong_merge_query.patch789 bytesBerdir
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rodgey’s picture

Issue tags: +Feed Aggregator

reproducing the bug:

1 - create more than 1 catagory in the feed aggregator.
2 - add a feed item (you might use f.e. "http://online.wsj.com/xml/rss/3_7085.xml")
!important: check more than one catagory.
3 - run update for this feed

bug 1:

You will now find out that the items are just catagorized for one catagory instead of the multiple catagories that you've put with a checkbox while adding the feed.

4 - click on the feed name in the feed overview
5 - choose catagorize
6 - add the checkboxes (again) for multiple catagories

Bug 2

Now the rss feed will be shown in multiple catagories, but cron won't run anymore and produce the following error:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-281' for key 1: UPDATE {aggregator_category_item} SET cid=:db_update_placeholder_0 WHERE ( (iid = :db_condition_placeholder_0) ); Array ( [:db_update_placeholder_0] => 1 [:db_condition_placeholder_0] => 281 ) in aggregator_save_item() (line 170 of /***/aggregator/aggregator.processor.inc).

I've been experimenting a little and found that the index data from aggregator_feed_item in the db are blocking cron to run.

montesq’s picture

subscribe

Berdir’s picture

Component: database system » aggregator.module

This is a problem with how aggregator.module is using the database system, not in the database system itself.

Berdir’s picture

Title: aggregator mess-up » Wrong merge query in aggregator_save_item()
Status: Needs work » Needs review
FileSize
789 bytes

See changed title.

The function used db_merge() incorrectly but it did work anyway in the past because MergeQuery was implemented in the same wrong way :)

Later, MergeQuery was fixed but aggregator_save_item() wasn't, because there are no tests for this. This is now covered by the updated tests in #276493: Tests needed: aggregator.module

Berdir’s picture

Version: 7.0 » 7.x-dev
Berdir’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7

Moving to the 8.x queue and tagging for possible backport.

Berdir’s picture

njardim’s picture

hi Berdir: I have a similar problem in updating aggregator's categories in D7 which is:

I have more then 200 Feeds splited into arround 40 Categories. There are 20 main categories to which each of the Feeds belong to and then they are also splited into minor categories. All Feeds are being updated but some of the Categories are not being updated at all. They are still resting at 0 items.

I've tried with Linux and Windows versions of Drupal 7 with the same results.

Do you have a fix for this problem?

Thank you very much.
njardim

Berdir’s picture

Have you tried this patch? That's exactly that bug that should be fixed by this.

Note that you will have to re-import your feeds, the categorization is missing from the database and needs to be re-added.

njardim’s picture

hi Berdir: at the first cron run aggregator_fix_wrong_merge_query.patch fixed the problem.

Thank you very much.
njardim

Damien Tournoud’s picture

Issue tags: +Needs tests

Looks like a no-brainer, but it also means we have no test for this :(

Berdir’s picture

See #4, there are tests for this in a separate issue (which currently fail because this patch is missing).

bfroehle’s picture

Status: Needs review » Reviewed & tested by the community

Given:

I'd suggest going ahead and committing this simple fix to 8.x-dev and 7.x-dev.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

I committed this to 7.x and 8.x. Tests are in #276493: Tests needed: aggregator.module.

aspilicious’s picture

untagging

debo7debo’s picture

can someone explain how do i fix this problem in simple basic instructions? I do not know what you all mean by "cron" and such. My categories won't fill up, it stuck at 0 in D7.

debo7debo’s picture

Title: Wrong merge query in aggregator_save_item() » can you give me instructions how to fix this? I don't know what "cron" means.
Version: 8.x-dev » 7.0
Priority: Major » Critical
Status: Fixed » Active

can you give me instructions how to fix this? I don't know what "cron" means.

catch’s picture

Version: 7.0 » 8.x-dev
Priority: Critical » Major
Status: Active » Fixed

Go to admin/reports/status - somewhere in there is a report about cron.

This will only be fixed in the latest 7.x-dev - you need to download and use that (or wait for 7.1) to get the fix.

Please don't re-open fixed issues with support requests.

catch’s picture

Title: can you give me instructions how to fix this? I don't know what "cron" means. » Wrong merge query in aggregator_save_item()

Re-setting title.

Status: Fixed » Closed (fixed)

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