diff --git a/src/LiveComponent/src/LiveComponentHydrator.php b/src/LiveComponent/src/LiveComponentHydrator.php index 7e79c87758e..a769b8e48f4 100644 --- a/src/LiveComponent/src/LiveComponentHydrator.php +++ b/src/LiveComponent/src/LiveComponentHydrator.php @@ -243,7 +243,7 @@ private static function coerceStringValue(string $value, string $type, bool $all private function calculateChecksum(array $dehydratedPropsData): ?string { // sort so it is always consistent (frontend could have re-ordered data) - ksort($dehydratedPropsData); + $this->recursiveKeySort($dehydratedPropsData); return base64_encode(hash_hmac('sha256', json_encode($dehydratedPropsData), $this->secret, true)); } @@ -549,4 +549,14 @@ private function combineAndValidateProps(array $props, array $updatedPropsFromPa return $dehydratedOriginalProps; } + + private function recursiveKeySort(array &$data): void + { + foreach ($data as &$value) { + if (\is_array($value)) { + $this->recursiveKeySort($value); + } + } + ksort($data); + } }