Figure out why we need to delete related comments from NodeStorage::delete(). The core NodeStorage handler doesn't seem to need this (it's probably done via some hook somewhere). But for some reason that hook (or whatever other mechanism) doesn't seem to fire when using Multiversion's NodeStorage handler.
/**
* {@inheritdoc}
*
* @todo: {@link https://www.drupal.org/node/2597534 Figure out why we need
* this}, core seems to solve it some other way.
*/
public function delete(array $entities) {
// Delete all comments before deleting the nodes.
$comment_storage = \Drupal::entityManager()->getStorage('comment');
foreach ($entities as $entity) {
if ($entity->comment) {
$comments = $comment_storage->loadThread($entity, 'comment', 1);
$comment_storage->delete($comments);
}
}
$this->deleteEntities($entities);
}
Once this is figured out we should be able to remove the NodeStorage handler for good, since this is the last method we override in NodeStorage.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 2597534-10.patch | 4.02 KB | benjy |
| #6 | 2597534-6.patch | 1.8 KB | benjy |
Comments
Comment #2
dixon_Comment #3
dixon_Comment #4
dixon_Comment #5
benjy commentedI think this happens in
comment_entity_predeletewhich is never fired becauseEntityStorageBase::delete()is never called.I wonder if it would be better for the storage to override
doDeleteso all the hooks still fire?Comment #6
benjy commentedHeres a patch, see what the tests say.
Comment #10
benjy commentedComment #17
dpovshed commentedRelated: #2819073: Delete hook stopped working after enabling multiversion