Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It is not guaranteed that save() or delete() are actually called when an entity is deleted. They're just a shortcut so that you don't have to get the storage controller manually. Especially for delete, it's common to call it directly on the storage controller, because that allows to delete multiple entities at once.
We need to document this, more than an entity type (e.g. Field) is currently implementing this incorrectly, other issues are trying to add stuff to save().
Comments
Comment #1
BerdirTagging.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedwow. that feels, so, so wrong.
i'd never guess right about this in a million years.
Comment #3
webchickSeems to me like we need to instead fix the API to conform to developers' expectations, not document that it's wonky and hope people catch it.
Comment #4
webchickTagging.
Comment #5
BerdirHowever wrong it feels, I don't see how it could possibly be different.
$storageController->save($entity);
$storageController->delete($array_of_entities);
*That* is the API. save() and delete() are just shortcuts for that. I don't see how we could technically prevent them from being called directly and especially for multi-delete, we don't want to.