From 8077b2dace72e2e306f4a8b07e64c9d3e9121d63 Mon Sep 17 00:00:00 2001 From: Jan Klan <5463371+janklan@users.noreply.github.com> Date: Thu, 31 Oct 2024 21:07:37 +1030 Subject: [PATCH] Strengthen type checking in AuditTrait (#228) * Strengthen type checking in AuditTrait Fixes #227 * PHP-CS-Fixer --------- Co-authored-by: Damien Harper --- src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php b/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php index b1aa624..5c5b7e4 100644 --- a/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php +++ b/src/Provider/Doctrine/Auditing/Transaction/AuditTrait.php @@ -202,7 +202,10 @@ private function diff(EntityManagerInterface $entityManager, object $entity, arr } if ($o !== $n) { - if (isset($type) && Type::getType(Types::JSON) === $type) { + if ( + isset($type) && Type::getType(Types::JSON) === $type + && (null === $o || \is_array($o)) && (null === $n || \is_array($n)) + ) { /** * @var ?array $o * @var ?array $n