Trash Not Compatible With Feeds

Created on 21 April 2025, 3 months ago

Problem/Motivation

I installed Drupal CMS which came with Trash pre-installed. I was conducting some imports for nodes and when I was adjusting a few things and deleting all nodes from my imports, things started acting weird. I spent a few days debugging the issue as I was unfamiliar with the Trash module.

Steps to reproduce

Conducted several imports, deleted imported nodes when tweaks are made.

Proposed resolution

Unsure. Either Feeds needs to be able to tell nodes in the trash apart from "the usual" nodes (which there doesn't seem to be a solution) or we need a mass purge ability in Trash.

Remaining tasks

Cry.

User interface changes

A full purge would be amazing.

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada Shane Birley

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Shane Birley
  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA
  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

    I spent a few days debugging the issue and determined that the Trash module was causing mayhem with Feeds.

    What mayhem though? I think this needs more specific steps to reproduce. What exactly was the issue? (I know this is a couple months old and may not be fresh on your mind anymore!)

    Here's what I did:

    1. Tested on a site with Feeds and Trash enabled
    2. Created a feed type to import from an RSS feed on some other website to a content type that had Trash enabled
    3. Ran the importer which imported a bunch of nodes
    4. Deleted one of the nodes (moved it to trash)
    5. Re-ran the importer
    6. Observed that the importer imported the trashed node again

    This is what I expected would happen. When feeds went to check if the node already existed or not, it found that it did NOT exist because it was in the trash and the Trash module is "hiding" it from anything that goes looking for it.

  • πŸ‡ΊπŸ‡ΈUnited States partyka

    The problem is that Feeds needs to notify the Trash module to "ignore" the deleted flag. Thankfully, Trash provides just such a way by using this code:

        \Drupal::service('trash.manager')->setTrashContext('ignore');
        $query->addTag('ignore_trash');
    

    I added this to the method `\Drupal\feeds\Plugin\Type\Target\FieldTargetBase::getUniqueValue` near line 227, re-ran the import, and the deleted nodes were no longer included.

    --

    I'm not sure what the best course of action here is, since we're talking about two contrib modules.

  • πŸ‡ΊπŸ‡ΈUnited States bkosborne New Jersey, USA

    I discussed with partyka and we think this is actually not a problem and the issue can be closed. At the very least, this should have more clearly defined description of what the problem is.

    It sounds like what really is the problem is that the act of deleting and re-importing nodes created a ton of stuff in the trash with no clear way to purge the trash. Trash should have a purge all functionality or a multi-select for purging as was suggested in the issue summary.

    But the current behavior I think makes sense, as I outlined in #6. An alternative behavior would be if Feeds didn't re-import items that were already trashed, but I think that's even more confusing.

Production build 0.71.5 2024