Deleting a content type with content in Trash broke the site with "Undefined array key"

Created on 2 June 2025, 5 days ago

Problem/Motivation

I deleted a content type 'programme' which had two nodes in Trash. I didn't purge the nodes before deleting the content type. After a few days I wanted to edit the homepage which is using 'page' content type and not the 'programme' content type I deleted, but when I clicked on 'Layout' tab to edit the layout of the homepage I got a 'page not found' error. I clicked on the 'Edit' tab and got the error, Symfony\Component\Routing\Exception\RouteNotFoundException: Route "layout_builder.overrides.node.view" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 211 of /home/public_html/core/lib/Drupal/Core/Routing/RouteProvider.php).

At this point I wondered what happened to the page, I thought perhaps someone in the team mistakenly deleted the homepage. But it was loading fine. In any case, I tried to look for the node in Trash to see if someone deleted it. So I clicked on the Trash icon and got the error,

Warning: Undefined array key "programme" in Drupal\trash\Controller\TrashController->buildRow() (line 194 of /home/public_html/modules/contrib/trash/src/Controller/TrashController.php)

This now gave me the clue as to what was happening being that I deleted 'programme' content type. So I recreated the content type and the issue went away. I then purged the two nodes in Trash, and deleted the content type again.

Steps to reproduce

1. Create a content type
2. Create nodes of the content type
3. Delete the nodes to move them to trash
4. Delete the content type without purging the nodes in trash
5. Click on Trash
6. See the error

Proposed resolution

Maybe to automatically purge nodes in Trash when a content type is deleted or prevent the deletion until existing nodes are purged.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇳🇬Nigeria chike Nigeria

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024