Add option to delete removed items

Created on 29 September 2011, about 13 years ago
Updated 7 December 2023, about 1 year ago

G'Day all,
Apologies if this is already covered: the aggregator issues number into the hundreds and I could not find a useful way to filter.
The problem seems quite straightforward: aggregator seems to create its own version of an external feed, and then doggedly maintains it regardless of what the external feed is saying.
For example, I have set up a feed from this source:
https://rss.eventarc.com/rss/user/riel/current
It is a list of *current* events (ie, events that have not yet taken place).
The feed updates itself to reflect new events being added and *crucially* when old events have taken place.
This feed has been popped into Aggregator and we've watched it over the past 8 weeks. Instead of harvesting from the feed every 30 minutes and *reflecting exactly what the feed says*, Aggregator brings in new items, and keeps the old ones.
This is bad enough under normal circumstances, but when an existing (current) event gets a content edit (eg, adjustment to the title), Aggregator creates a *new event* and keeps the previous version as if it were a totally different event!!
I see a fair bit of comment about setting aggregator to expire items after XX period of time, but of course that's totally inappropriate here. We might put in an event that is a year away, and we'd expect that event to stay in Aggregator's feed because it will be staying in the EventArc feed.
It al seems to boil down to the simple matter of asking Aggregator to please simply read the external feed and update precisely what it finds.
Is that not the concept?

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia boabjohn

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States joewhitsitt Iowa

    Our group invested in a solution for this, but because we think it goes against the nature of what this module is doing, we didn't write a patch for this module. In our situation, our customer had a jobs feed in addition to news feeds. Unlike storing a aggregate of news items, the customer wanted the expired job postings to no longer display.

    Instead we created a boolean "purge items" field on the aggregator feed entity (admin/config/services/aggregator/fields) and then used a service decorator to plug into the aggregator.items.importer service. That way each feed source can be configured to use this feature or not.

    Using a service decorator, hopefully the code footprint is smaller and we don't have to recreate the rest of what the importer is doing. Hope this can be of help to others.

    in mymodule.services.yml:

    mymodule.custom_items_import:
        class: Drupal\mymodule\ItemsImporterOverride
        decorates: aggregator.items.importer
        decoration_priority: 9
        public: false
        arguments: ['@mymodule.custom_items_import.inner', '@config.factory', '@plugin.manager.aggregator.fetcher', '@plugin.manager.aggregator.parser', '@plugin.manager.aggregator.processor', '@logger.channel.aggregator', '@keyvalue.aggregator']

    in mymodule/src/ItemsImporterOverride:

    <?php
    
    namespace Drupal\mymodule;
    
    use Drupal\aggregator\FeedInterface;
    use Drupal\aggregator\ItemsImporter;
    use Drupal\aggregator\Plugin\AggregatorPluginManager;
    use Drupal\Core\Config\ConfigFactoryInterface;
    use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
    use Psr\Log\LoggerInterface;
    
    /**
     * Modify the Aggregator ItemsImporter with a custom refresh.
     */
    class ItemsImporterOverride extends ItemsImporter {
    
      /**
       * Original service object.
       *
       * @var \Drupal\aggregator\ItemsImporter
       */
      protected $itemsImporter;
    
      /**
       * {@inheritdoc}
       */
      public function __construct(
        ItemsImporter $itemsImporter,
        ConfigFactoryInterface $configFactory,
        AggregatorPluginManager $fetcherManager,
        AggregatorPluginManager $parserManager,
        AggregatorPluginManager $processorManager,
        LoggerInterface $logger,
        KeyValueFactoryInterface $keyValue,
      ) {
        $this->itemsImporter = $itemsImporter;
        parent::__construct($configFactory, $fetcherManager, $parserManager, $processorManager, $logger, $keyValue);
      }
    
      /**
       * {@inheritdoc}
       */
      public function refresh(FeedInterface $feed) {
        $purgeItems = $feed->get('field_aggregator_purge_items')?->value;
    
        if ($purgeItems) {
          $feed->deleteItems();
        }
        parent::refresh($feed);
      }
    
    }
Production build 0.71.5 2024