I propose to add the entity type label and entity id to \Drupal\entity_reference_integrity_enforce\EntityPredelete::entityDelete exception text.
I have seen this message in my watchdog/dblog and have no way of finding out why it happened. In my case, I can only tell it happened in a batch process.
Short version of my proposal:
Before: throw new ProtectedEntityException('Cannot delete entity that has references pointing to it.');
After: throw new ProtectedEntityException(sprintf('Cannot delete entity %s with id %d that has references pointing to it.', ...));
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3016389-6.patch | 4.06 KB | sam152 |
| #2 | entityDelete-exception-text-lacks-context_3016389.patch | 886 bytes | rogerpfaff |
Comments
Comment #2
rogerpfaffHere is a patch that replaces the message like said in opening. I can't test because I have no clue how to reproduce the error.
Comment #3
jepster_Successful code review.
Comment #4
gogowitsch commented+1 from me: this patch has been in production for a while now, and works as intended.
From my perspective: ok to get commited.
Comment #5
sam152 commentedI have never seen the pattern of
sprintf('..', [arg, arg]), lets go('..', arg, arg). Also, maybe worth some quotes around the arguments, so it's clear which part is coming from the entity. We are also missing bits of context such as the entity type and bundle, which seem like they would also be useful.What about:
Comment #6
sam152 commentedComment #7
sam152 commentedComment #9
sam152 commentedTagged a new release with this feature: https://www.drupal.org/project/entity_reference_integrity/releases/8.x-1...
Comment #10
sam152 commented