diff --git a/src/Service/LogEntityOperationsManager.php b/src/Service/LogEntityOperationsManager.php index 599739d323604a192f33e40a5f738488bae24092..f7ce8c712018a8c44ca96778ed6cadf6713f3704 100644 --- a/src/Service/LogEntityOperationsManager.php +++ b/src/Service/LogEntityOperationsManager.php @@ -5,6 +5,7 @@ namespace Drupal\log_entity_operations\Service; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\log_entity_operations\Logger\DrupalLogger; use Drupal\log_entity_operations\ArrayDiff; @@ -102,7 +103,8 @@ class LogEntityOperationsManager { $diff = ''; if ($operation == 'update' && isset($entity->original) && $this->getConfig('log_diff')) { $array1 = $this->filterRecursive($entity->original->toArray()); - $updated_entity = $this->entityTypeManager->getStorage($type)->load($entity->id()); + $updated_entity = $entity instanceof RevisionableInterface && $entity->getEntityType()->hasKey('revision_table') ? $this->entityTypeManager->getStorage($type)->loadRevision($entity->getRevisionId()) + : $this->entityTypeManager->getStorage($type)->load($entity->id()); $array2 = $this->filterRecursive($updated_entity->toArray()); $differ = new ArrayDiff(); $diff = json_encode($this->filterRecursive($differ->diff($array1, $array2)));