Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291379

entity_delete_multiple() bypasses Entity::delete()

$
0
0

entity_delete_multiple() calls $storage_controller->delete($entities) directly.

So any code present in the EntityClass::delete() method is never executed. Thus those two lines are not equivalent :

<?php
entity_delete_multiple
('my_entity_type', array(1));
entity_load('my_entity_type', 1)->delete();
?>

Problem : entity_delete_multiple() is marked deprecated, with the official recommendation being "use $storage_controller->delete($entities)", i.e we promote bypassing the $entity->delete() method, and deleting entities through the controller directly.

Right now, this means that entity-type-specific code for delete() should not be added in the entity type class, but in the storage controller.
However:
- nothing documents that, if that's how we want things to be, Entity::delete() should be final.
- there are definitely cases where the code would be storage-controller agnostic.

Note : The problem doesn't seem to arise for save, since we never added a generic entity_save() function.


Viewing all articles
Browse latest Browse all 291379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>