From 8c74ff9a62618d0993718b23c6318bcd63e41806 Mon Sep 17 00:00:00 2001 From: Omar Mohamad - El Hassan Lopesino <27703-mistermoper@users.noreply.drupalcode.org> Date: Tue, 22 Apr 2025 14:16:08 +0000 Subject: [PATCH] Issue #3264740 by omarlopesino: The diff does not appear when a moderated entity is set to draft --- src/Service/LogEntityOperationsManager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Service/LogEntityOperationsManager.php b/src/Service/LogEntityOperationsManager.php index 599739d..f7ce8c7 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))); -- GitLab