After deleted one of two categories from admin/content/aggregator/ which has some feeds assigned,
category was not deleted from the feeds.
And contain invalid html listing:

<div class="feed-item-categories">
    Categories: <a href="/aggregator/categories/"/>, <a class="active" href="/second_category">second_category</a>  </div>

Comments

promes’s picture

There is a missing delete statement in function aggregator_save_category($edit).
After deleting: db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']);
the statement: db_query('DELETE FROM {aggregator_category_feed} WHERE cid = %d', $edit['cid']);
is missing.

twistor’s picture

Title: when category has been deleted, feeds contain invisible category » Remove category from feed when category is deleted
Version: 6.8 » 8.x-dev
Status: Active » Needs review
Issue tags: +Needs backport to D6, +Needs backport to D7
StatusFileSize
new2.29 KB
new1.68 KB

Here's a test that illustrates the issue.

And the fix.

twistor’s picture

Title: Remove category from feed when category is deleted » Remove category from feed and feed items when category is deleted
StatusFileSize
new3.1 KB
new2.37 KB

On second thought we should do the same thing for feed items.

promes’s picture

I only can speak about the D6 implementation and my use of feeds. So my remark maybe not-valid for D8.
In D6 the table aggregator_category_item consist only of the category-id (cid) and item-id (iid). So you don't have any clue of which items belong to which feed. Or which items belong to the feed being removed from the category.

In #3 you delete all category-items of a category when one feed is deleted from a category. This will remove all category-items from other feeds in the same category as well.

In D6 I created a copy of the aggregator module for another type of feeds (I hope to publish this module later this year). There I found the bug #1. To solve the problem with the superfluous (or missing) items in aggregator_category_item I modified function media_aggregator_save_feed() to rebuild this table when deleting a feed from a category and / or adding a feed to a category.

twistor’s picture

@promes, This issue is in regard to when categories are deleted, not when feeds are deleted.

In #3 I delete all category-items of a specific category when it is deleted, not when a feed is deleted.

promes’s picture

@twistor, I overlooked you already do delete the category-items as well. This is indeed as simple as you do it. Thanks for pointing this out.

xjm’s picture

StatusFileSize
new3.14 KB

Rerolled for core/.

kscheirer’s picture

Status: Needs review » Needs work

The last submitted patch, aggregator-remove-category-348815-7.patch, failed testing.

ParisLiakos’s picture

Version: 8.0.x-dev » 7.x-dev
Issue summary: View changes

No categories in d8

dcam’s picture

Issue tags: +Novice

Tagging this as a Novice issue. Anyone working on this can use #3 as a starting point for a patch. At the point that patch was written, Drupal 8 hadn't diverged from Drupal 7 very much yet. I thought #3 might even apply to 7.x, but unfortunately it doesn't. Still, you'll practically just be rerolling the patches.

Jill L’s picture

I tested the patch from #3 in Drupal 7, and it worked correctly. However, it failed the simpletest "update feed item category".
If that's ok, please use the patch from #3 for Drupal 7.

ottlik’s picture

Downloaded patches from comment #3 by twistor.
Following https://www.drupal.org/patch/reroll step 3, I moved to drupal/core in 8.0.x branch and ran
"git apply --check aggregator-remove-category-from-feed-348815-3.patch", then
"git apply --check aggregator-remove-category-from-feed-348815-3.patch".
I received no output, suggesting that there is no longer a need for re-roll.

ottlik’s picture

Correction: Second command was
" git apply --check aggregator-remove-category-from-feed-test-348815-3.patch"

dcam’s picture

@ottlik
The changes introduced in #3 need to be applied to D7. Aggregator categories no longer exist in D8.

stefan.r’s picture

Tagging Novice for the reroll and issue summary update

danylevskyi’s picture

We are on DrupalCon Dublin and we are going to work on this issue.

billywardrop’s picture

I am now working on this at DrupalCon

aerozeppelin’s picture

Status: Needs work » Needs review
StatusFileSize
new2.71 KB
new3.5 KB

Re rolled patch from #7.

The last submitted patch, 19: test-only-fail-348815-19.patch, failed testing.

nileema.jadhav’s picture

Issue tags: -Needs reroll

Applied 348815-19.patch, it is working as expected in latest 7.x branch.

nileema.jadhav’s picture

Status: Needs review » Reviewed & tested by the community
David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x - thanks!

I fixed a number of small problems on commit:

diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index ebd7f01..02c9ec4 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -457,12 +457,12 @@ function aggregator_save_category($edit) {
         ->execute();
       // Remove category from feeds.
       db_delete('aggregator_category_feed')
-          ->condition('cid', $edit['cid'])
-          ->execute();
+        ->condition('cid', $edit['cid'])
+        ->execute();
       // Remove category from feed items.
       db_delete('aggregator_category_item')
-          ->condition('cid', $edit['cid'])
-          ->execute();
+        ->condition('cid', $edit['cid'])
+        ->execute();
       // Make sure there is no active block for this category.
       if (module_exists('block')) {
         db_delete('block')
diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test
index af33e26..afa791d 100644
--- a/modules/aggregator/aggregator.test
+++ b/modules/aggregator/aggregator.test
@@ -455,12 +455,14 @@ class CategorizeFeedTestCase extends AggregatorTestCase {
 
     // Assert that category is deleted.
     $db_category = db_query("SELECT COUNT(*) FROM {aggregator_category} WHERE cid = :cid", array(':cid' => $category->cid))->fetchField();
-    $this->assertFalse($db_category, t('The category %title has been deleted.', array('%title' => $category->title)));
+    $this->assertFalse($db_category, format_string('The category %title has been deleted.', array('%title' => $category->title)));
 
     // Assert that category has been removed from feed.
     $categorized_feeds = db_query("SELECT COUNT(*) FROM {aggregator_category_feed} WHERE cid = :cid", array(':cid' => $category->cid))->fetchField();
-    $this->assertFalse($categorized_feeds, t('The category %title has removed from feed %feed_title.', array('%title' => $category->title, '%feed_title' => $feed['title'])));
+    $this->assertFalse($categorized_feeds, format_string('The category %title has been removed from feed %feed_title.', array('%title' => $category->title, '%feed_title' => $feed['title'])));
 
+    // Assert that no broken links (associated with the deleted category)
+    // appear on one of the other category pages.
     $this->createSampleNodes();
     $this->drupalGet('admin/config/services/aggregator');
     $this->clickLink('update items');
@@ -717,7 +719,7 @@ class CategorizeFeedItemTestCase extends AggregatorTestCase {
 
     // Assert category has been removed from feed items.
     $categorized_count = db_query("SELECT COUNT(*) FROM {aggregator_category_item} WHERE cid = :cid", array(':cid' => $cid))->fetchField();
-    $this->assertFalse($categorized_count, t('The category %title has been removed from feed items.', array('%title' => $category_title)));
+    $this->assertFalse($categorized_count, format_string('The category %title has been removed from feed items.', array('%title' => $category_title)));
     // Delete feed.
     $this->deleteFeed($feed);
   }

  • David_Rothstein committed 694c9fe on 7.x
    Issue #348815 by twistor, aerozeppelin, xjm, PROMES, nileema.jadhav,...

Status: Fixed » Closed (fixed)

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