Problem/Motivation
When the user who owns a proc entity is deleted, Proc::getOwner() throws:
TypeError: Drupal\proc\Entity\Proc::getOwner(): Return value must be of type Drupal\user\UserInterface, null returned
The method is declared : UserInterface, but $this->get('user_id')->entity is NULL once the account is gone. EntityOwnerInterface doesn't declare a return type, and ProcListBuilder already expects NULL (getOwner() ? … : 'Anonymous'), but that check can never run.
Ciphers from deleted users are still referenced by content (e.g. attachments other users received), so deleting them is not an option.
Steps to reproduce
- As user A, generate keys and encrypt something (e.g. a file for user B).
- Delete user A.
- Visit
/admin/content/procs: fatal error.
The same call is used in ProcMetadataMessageTrait ("Encrypted by %author") and StandardProcRelabelling::relabel(), so viewing or relabelling those ciphers is likely affected too (not yet confirmed).
Proposed resolution
- Change the return type to
?UserInterface. - Fall back to "Anonymous" in
ProcMetadataMessageTraitandStandardProcRelabelling, asProcListBuilderalready does. - Add a kernel test: delete the owner, assert
getOwner()returns NULL and the metadata message renders.
Follow-up (separate issue): decide what proc should do with a user's keyrings and ciphers on account deletion/cancellation.
Remaining tasks
- MR + test
- Review
User interface changes
Ciphers of deleted users show "Encrypted by Anonymous" instead of a fatal error.
API changes
Proc::getOwner() may now return NULL. Callers that chain on it (->label(), etc.) must handle NULL.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| Captura de ecrã 2026-11-06 162729.png | 7.34 KB | duartebriz |
Comments
Comment #2
duartebriz commentedComment #3
rodrigo panchiniak fernandes commented