The RedirectTrashHandler assumes that the deleted field always exists on redirect entities.
However, starting from Drupal ~11.3.0, changes in entity definitions or contrib overrides may cause the field to be missing, resulting in:
- PHP notices or fatal errors when calling
$entity->get('deleted')
- Incompatibility with customized redirect entity types
- Breakage during entity deletion or trash handling
To maintain forward compatibility and prevent runtime errors, the handler must check that the field exists with hasField() before accessing it.
Steps to reproduce
- Use Redirect module with Drupal ~11.3.0.
- Trigger redirect entity deletion or trash handling.
- If the
deleted field is missing, observe PHP warnings/errors.
Proposed resolution
Add a hasField() check before attempting to access the deleted field.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #3
salvatoren 🇮🇹 commentedSame for me.
ATM, disabled module .
Comment #4
rajab natshahComment #5
robbt commentedThis bug results in DrupalCMS not being able to edit the titles of pages based upon it's inclusion of the trash module - https://www.drupal.org/project/drupal_cms/issues/3564582
Comment #6
phenaproximaIt's a stable blocker for us, I'm afraid!
Comment #7
pameeela commentedNo workaround so bumping this to critical since you are unable to save changes to content in many cases.
Comment #8
pameeela commentedJust tested the MR manually, confirmed it fixes the issue with saving.
Comment #12
amateescu commentedThe problem with Drupal 11.3 is that #3506930: Separate hooks from events broke the way we "disabled" trash handlers for entity types that are not trash-enabled. Previously, it was enough to remove their service from the container, but now the hook callable is stored in a different place that we can't easily override :/
I've committed a change that determines whether the entity type is trash-enabled rather just looking for a
deletedfield, fixed this for nodes as well, and removed the code mentioned above because it's useless at this point.Comment #15
rajab natshahThank you :) for the committed fix.
Hopping for a release
Comment #16
amateescu commentedThis fix is already included in 3.0.23.