[LiveComponent] Fix issue with onUpdated not triggered on nested array proprety

by @TheDutchScorpion

Some issues have been detected in this pull request

0
Coding Standard

0
Common Typos

0
File Permissions

Issues that cannot be fixed automatically

in Commits list, a `git rebase` is needed to remove any merges
  • Merge branch 'symfony:2.x' into feature/nested-property-on-updated

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/ux/2013/6c46e0c284fdcd4edc65bb89e2adbd41dd91b1a2/exception_messages.diff | patch -p0
diff -ru src/LiveComponent/src/LiveComponentHydrator.php src/LiveComponent/src/LiveComponentHydrator.php
--- src/LiveComponent/src/LiveComponentHydrator.php	2024-08-03 18:09:42.387807150 +0000
+++ src/LiveComponent/src/LiveComponentHydrator.php	2024-08-03 18:09:43.898860794 +0000
@@ -101,7 +101,7 @@
                     } catch (NoSuchPropertyException $e) {
                         throw new \LogicException(\sprintf('The writable path "%s" does not exist on the "%s" property of the "%s" component.', $path, $propertyName, $component::class), 0, $e);
                     } catch (PropertyAccessExceptionInterface $e) {
-                        throw new \LogicException(\sprintf('The writable path "%s" on the "%s" property of the "%s" component could not be read: %s', $path, $propertyName, $component::class, $e->getMessage()), 0, $e);
+                        throw new \LogicException(\sprintf('The writable path "%s" on the "%s" property of the "%s" component could not be read: "%s"', $path, $propertyName, $component::class, $e->getMessage()), 0, $e);
                     }
 
                     // TODO: maybe we allow support the same types as LiveProps later
@@ -184,7 +184,7 @@
              */
             if ($dehydratedUpdatedProps->hasPropValue($frontendName)) {
                 if (!$propMetadata->isIdentityWritable()) {
-                    throw new HydrationException(\sprintf('The model "%s" was sent for update, but it is not writable. Try adding "writable: true" to the $%s property in %s.', $frontendName, $propMetadata->getName(), $component::class));
+                    throw new HydrationException(\sprintf('The model "%s" was sent for update, but it is not writable. Try adding "writable: true" to the $%s property in "%s".', $frontendName, $propMetadata->getName(), $component::class));
                 }
                 try {
                     $propertyValue = $this->hydrateValue(
@@ -355,7 +355,7 @@
     private function verifyChecksum(array $identifierPops, string $error = 'Invalid checksum sent when updating the live component.'): void
     {
         if (!\array_key_exists(self::CHECKSUM_KEY, $identifierPops)) {
-            throw new HydrationException(\sprintf('Missing %s. key', self::CHECKSUM_KEY));
+            throw new HydrationException(\sprintf('Missing "%s". key', self::CHECKSUM_KEY));
         }
         $sentChecksum = $identifierPops[self::CHECKSUM_KEY];
         unset($identifierPops[self::CHECKSUM_KEY]);
@@ -464,7 +464,7 @@
                 $collectionClass = $propMetadata->collectionValueType()->getClassName();
                 foreach ($value as $key => $objectItem) {
                     if (!$objectItem instanceof $collectionClass) {
-                        throw new \LogicException(\sprintf('The LiveProp "%s" on component "%s" is an array. We determined the array is full of %s objects, but at least one key had a different value of %s', $propMetadata->getName(), $parentObject::class, $collectionClass, get_debug_type($objectItem)));
+                        throw new \LogicException(\sprintf('The LiveProp "%s" on component "%s" is an array. We determined the array is full of "%s" objects, but at least one key had a different value of "%s"', $propMetadata->getName(), $parentObject::class, $collectionClass, get_debug_type($objectItem)));
                     }
 
                     $value[$key] = $this->dehydrateObjectValue($objectItem, $collectionClass, $propMetadata->getFormat(), $parentObject);
@@ -613,7 +613,7 @@
 
         if (\count($extraSentWritablePaths) > 0) {
             // we could show multiple fields here in the message
-            throw new HydrationException(\sprintf('The model "%s.%s" was sent for update, but it is not writable. Try adding "writable: [\'%s\']" to the $%s property in %s.', $frontendPropName, $extraSentWritablePaths[0], $extraSentWritablePaths[0], $propMetadata->getName(), $componentClass));
+            throw new HydrationException(\sprintf('The model "%s.%s" was sent for update, but it is not writable. Try adding "writable: [\'%s\']" to the $%s property in "%s".', $frontendPropName, $extraSentWritablePaths[0], $extraSentWritablePaths[0], $propMetadata->getName(), $componentClass));
         }
 
         return $writablePaths;

0
Usage of void in test files

0
Use ::class whenever possible

0
Deprecation Messages