Deleting a restored node bypasses trash due to stale in_trash query parameter

Created on 12 May 2025, 9 days ago

Problem/Motivation

After restoring a node from the trash, if the `in_trash` query parameter remains in the URL, subsequent delete actions bypass the trash and permanently delete the node. This happens because the trash context is incorrectly set to `ignore`, likely due to the lingering `in_trash` query parameter from the restore route.

Steps to reproduce

  1. Trash a node.
  2. Restore the node.
  3. Notice that the `in_trash` query parameter is still present in the URL after restoring.
  4. Delete the node again without navigating away.
  5. The node is permanently deleted, bypassing the trash.

Proposed resolution

Update `TrashRouteProcessor::processOutbound()` to remove the `in_trash` query parameter from the URL when generating links for the restore route.

if (str_ends_with($request->getPathInfo(), '/restore')) {
  unset($parameters['in_trash']);
}

This prevents an incorrect trash context, which causes the bypass in:

trait TrashStorageTrait {

  /**
   * {@inheritdoc}
   */
  public function delete(array $entities) {
    if ($this->getTrashManager()->getTrashContext() !== 'active') {
      parent::delete($entities);
      return;
    }

Remaining tasks

  • Add logic to remove in_trash parameter on restore routes.
  • Optionally, add test coverage to confirm restored nodes are correctly moved back to trash if deleted again.

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States ian.ssu

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

Comments & Activities

Production build 0.71.5 2024