Issue #221081 by David_Rothstein, fago, schwern, Berdir: Entity cache out of sync and inconsistent when saving/deleting entities.
parent
4a808340cb
commit
4b7da9abff
|
@ -611,13 +611,16 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
->execute();
|
||||
}
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
$this->invokeFieldMethod('delete', $entity);
|
||||
$this->deleteFieldItems($entity);
|
||||
}
|
||||
|
||||
// Reset the cache as soon as the changes have been applied.
|
||||
$this->resetCache($ids);
|
||||
|
||||
$entity_class::postDelete($this, $entities);
|
||||
foreach ($entities as $entity) {
|
||||
$this->invokeFieldMethod('delete', $entity);
|
||||
$this->deleteFieldItems($entity);
|
||||
$this->invokeHook('delete', $entity);
|
||||
}
|
||||
// Ignore slave server temporarily.
|
||||
|
@ -669,11 +672,11 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
if ($this->revisionDataTable) {
|
||||
$this->savePropertyData($entity, 'revision_data_table');
|
||||
}
|
||||
$this->resetCache(array($entity->id()));
|
||||
$entity->setNewRevision(FALSE);
|
||||
$entity->postSave($this, TRUE);
|
||||
$this->invokeFieldMethod('update', $entity);
|
||||
$this->saveFieldItems($entity, TRUE);
|
||||
$this->resetCache(array($entity->id()));
|
||||
$entity->postSave($this, TRUE);
|
||||
$this->invokeHook('update', $entity);
|
||||
if ($this->dataTable) {
|
||||
$this->invokeTranslationHooks($entity);
|
||||
|
@ -696,13 +699,13 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
$this->savePropertyData($entity, 'revision_data_table');
|
||||
}
|
||||
|
||||
// Reset general caches, but keep caches specific to certain entities.
|
||||
$this->resetCache(array());
|
||||
|
||||
$entity->enforceIsNew(FALSE);
|
||||
$entity->postSave($this, FALSE);
|
||||
$this->invokeFieldMethod('insert', $entity);
|
||||
$this->saveFieldItems($entity, FALSE);
|
||||
// Reset general caches, but keep caches specific to certain entities.
|
||||
$this->resetCache(array());
|
||||
$entity->postSave($this, FALSE);
|
||||
$this->invokeHook('insert', $entity);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,10 @@ function hook_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Act on entities when inserted.
|
||||
* Respond to creation of a new entity.
|
||||
*
|
||||
* This hook runs once the entity has been stored. Note that hook
|
||||
* implementations may not alter the stored entity data.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object.
|
||||
|
@ -305,7 +308,10 @@ function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Act on entities when updated.
|
||||
* Respond to updates to an entity.
|
||||
*
|
||||
* This hook runs once the entity storage has been updated. Note that hook
|
||||
* implementations may not alter the stored entity data.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object.
|
||||
|
@ -322,7 +328,10 @@ function hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Acts after storing a new entity translation.
|
||||
* Respond to creation of a new entity translation.
|
||||
*
|
||||
* This hook runs once the entity translation has been stored. Note that hook
|
||||
* implementations may not alter the stored entity translation data.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $translation
|
||||
* The entity object of the translation just stored.
|
||||
|
@ -336,7 +345,9 @@ function hook_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $tra
|
|||
}
|
||||
|
||||
/**
|
||||
* Acts after deleting an entity translation from the storage.
|
||||
* Respond to entity translation deletion.
|
||||
*
|
||||
* This hook runs once the entity translation has been deleted from storage.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The original entity object.
|
||||
|
@ -353,8 +364,6 @@ function hook_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $tra
|
|||
/**
|
||||
* Act before entity deletion.
|
||||
*
|
||||
* This hook runs after the entity type-specific predelete hook.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object for the entity that is about to be deleted.
|
||||
*/
|
||||
|
@ -382,7 +391,7 @@ function hook_entity_predelete(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
/**
|
||||
* Respond to entity deletion.
|
||||
*
|
||||
* This hook runs after the entity type-specific delete hook.
|
||||
* This hook runs once the entity has been deleted from the storage.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object for the entity that has been deleted.
|
||||
|
@ -398,7 +407,7 @@ function hook_entity_delete(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
/**
|
||||
* Respond to entity revision deletion.
|
||||
*
|
||||
* This hook runs after the entity type-specific revision delete hook.
|
||||
* This hook runs once the entity revision has been deleted from the storage.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object for the entity revision that has been deleted.
|
||||
|
|
Loading…
Reference in New Issue