Feeds not respecting 'trashed' nodes

Created on 24 June 2025, 18 days ago

Problem/Motivation

The feeds module is unaware that if the Trash module is installed, it needs to tell the Trash module to not alter the SQL query to ignore "trashed"/"deleted" nodes. Otherwise, Feeds will re-create the trashed node.

Steps to reproduce

Conducted several imports, deleted imported nodes, made tweaks, re-imported. Feeds was unable to delete imported nodes because they were being thrown in the Trash. (copied from #3520382)

and (from this comment ✨ Trash Not Compatible With Feeds Active )

Tested on a site with Feeds and Trash enabled
Created a feed type to import from an RSS feed on some other website to a content type that had Trash enabled
Ran the importer which imported a bunch of nodes
Deleted one of the nodes (moved it to trash)
Re-ran the importer
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.

Proposed resolution

Have the feeds module check to see if the Trash module is installed and enabled. If it is, then instruct trash to not alter SQL during feed import.

Remaining tasks

Code and test

User interface changes

N/A

API changes

N/A

Data model changes

N/A

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States partyka

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

Merge Requests

Comments & Activities

  • Issue created by @partyka
  • Merge request !215Added check for trash module service. β†’ (Open) created by partyka
  • Pipeline finished with Success
    18 days ago
    Total: 664s
    #530481
  • πŸ‡³πŸ‡±Netherlands megachriz

    Interesting issue. As I'm not familiar with the Trash module yet, I'm not sure what the best way is to solve this problem. If possible, I would like to avoid the soft dependency on the Trash module, because making sure the Trash specific code keeps working would require tests and a dev dependency on the Trash module. Also, I'm aiming for a pass on PHPStan. With the current implementation, I think that will mean that eventually all child classes of FieldTargetBase would need to pass the Trash service instance to the parent. See πŸ“Œ (PHPStan) Add dependency injection for FieldTargetBase and add deprecation warnings Active for other services I've planned to inject in FieldTargetBase in the future (and require them in Feeds 4.x).

    One thing we could do instead, but I'm not sure if that's enough, is add a query tag to the query that Feeds executes, for example:

    $query->addTag('feeds_unique_query');
    

    This tag would then always be added.

    In theory, you could then implement hook_query_TAG_alter() to perform the Trash specific code, though I don't know if adding another query tag in such implementation has the desired effect.

Production build 0.71.5 2024