diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/AbstractDimensionSpacePoint.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/AbstractDimensionSpacePoint.php index 9f457b03576..f43baeb7c2a 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/AbstractDimensionSpacePoint.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/AbstractDimensionSpacePoint.php @@ -145,11 +145,12 @@ final public function jsonSerialize(): array return $this->coordinates; } - /** - * @throws \JsonException - */ final public function toJson(): string { - return json_encode($this, JSON_THROW_ON_ERROR); + try { + return json_encode($this, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1716575128, $e); + } } } diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/ContentSubgraphVariationWeight.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/ContentSubgraphVariationWeight.php index 29c34cfe7f4..20f4026fd05 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/ContentSubgraphVariationWeight.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/ContentSubgraphVariationWeight.php @@ -105,11 +105,12 @@ public function jsonSerialize(): array return $this->value; } - /** - * @throws \JsonException - */ public function toJson(): string { - return json_encode($this, JSON_THROW_ON_ERROR); + try { + return json_encode($this, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1716575135, $e); + } } } diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePoint.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePoint.php index 31532f5e148..5da1ad9117f 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePoint.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePoint.php @@ -56,7 +56,11 @@ public static function fromArray(array $data): self */ public static function fromJsonString(string $jsonString): self { - return self::instance(json_decode($jsonString, true)); + try { + return self::instance(json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574623, $e); + } } /** diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePointSet.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePointSet.php index 56179626e7d..d6f5132f3e9 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePointSet.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/DimensionSpacePointSet.php @@ -68,7 +68,11 @@ public static function fromArray(array $array): self public static function fromJsonString(string $jsonString): self { - return new self(\json_decode($jsonString, true)); + try { + return new self(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574647, $e); + } } /** @@ -156,11 +160,12 @@ public function getIterator(): \Traversable yield from $this->points; } - /** - * @throws \JsonException - */ public function toJson(): string { - return json_encode($this, JSON_THROW_ON_ERROR); + try { + return json_encode($this, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1716575140, $e); + } } } diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePoint.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePoint.php index 8a689481c0c..ff2049538a5 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePoint.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePoint.php @@ -69,7 +69,11 @@ public static function createWithoutDimensions(): self */ public static function fromJsonString(string $jsonString): self { - return self::instance(json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + try { + return self::instance(json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574660, $e); + } } public static function fromDimensionSpacePoint(DimensionSpacePoint $dimensionSpacePoint): self diff --git a/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePointSet.php b/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePointSet.php index 2979c42542c..bcd1b900bcf 100644 --- a/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePointSet.php +++ b/Neos.ContentRepository.Core/Classes/DimensionSpace/OriginDimensionSpacePointSet.php @@ -76,7 +76,11 @@ public static function fromArray(array $array): self public static function fromJsonString(string $jsonString): self { - return self::fromArray(json_decode($jsonString, true)); + try { + return self::fromArray(json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574670, $e); + } } public function toDimensionSpacePointSet(): DimensionSpacePointSet @@ -112,7 +116,11 @@ public function contains(OriginDimensionSpacePoint $point): bool public function toJson(): string { - return json_encode($this, JSON_THROW_ON_ERROR); + try { + return json_encode($this, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1716575147, $e); + } } /** diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeCreation/Dto/NodeAggregateIdsByNodePaths.php b/Neos.ContentRepository.Core/Classes/Feature/NodeCreation/Dto/NodeAggregateIdsByNodePaths.php index 083a4cfb607..72a4dbd19e3 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeCreation/Dto/NodeAggregateIdsByNodePaths.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeCreation/Dto/NodeAggregateIdsByNodePaths.php @@ -101,12 +101,13 @@ public static function fromArray(array $array): self return new self($nodeAggregateIds); } - /** - * @throws \JsonException - */ public static function fromJsonString(string $jsonString): self { - return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + try { + return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574683, $e); + } } public function merge(self $other): self diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/PropertyValuesToWrite.php b/Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/PropertyValuesToWrite.php index 8ab899ebdd7..d8108e06c67 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/PropertyValuesToWrite.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/PropertyValuesToWrite.php @@ -51,12 +51,13 @@ public static function fromArray(array $values): self return new self($values); } - /** - * @throws \JsonException - */ public static function fromJsonString(string $jsonString): self { - return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + try { + return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574701, $e); + } } /** diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValues.php b/Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValues.php index 7aa73103f95..ec5c6bafb02 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValues.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeModification/Dto/SerializedPropertyValues.php @@ -101,7 +101,11 @@ public static function defaultFromNodeType(NodeType $nodeType, PropertyConverter public static function fromJsonString(string $jsonString): self { - return self::fromArray(\json_decode($jsonString, true)); + try { + return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574712, $e); + } } public function merge(self $other): self diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Dto/NodeReferencesToWrite.php b/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Dto/NodeReferencesToWrite.php index 3fefefbde63..f5514ce96c5 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Dto/NodeReferencesToWrite.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Dto/NodeReferencesToWrite.php @@ -75,12 +75,13 @@ public static function fromNodeAggregateIds(NodeAggregateIds $nodeAggregateIds): )); } - /** - * @throws \JsonException - */ public static function fromJsonString(string $jsonString): self { - return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + try { + return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574722, $e); + } } /** diff --git a/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Dto/SerializedNodeReferences.php b/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Dto/SerializedNodeReferences.php index 4fbe1fb6737..8bd04136f00 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Dto/SerializedNodeReferences.php +++ b/Neos.ContentRepository.Core/Classes/Feature/NodeReferencing/Dto/SerializedNodeReferences.php @@ -72,7 +72,11 @@ public static function fromNodeAggregateIds(NodeAggregateIds $nodeAggregateIds): public static function fromJsonString(string $jsonString): self { - return self::fromArray(\json_decode($jsonString, true)); + try { + return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574730, $e); + } } public function merge(self $other): self diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/CoverageByOrigin.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/CoverageByOrigin.php index acbe9a2acd5..c0f68288422 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/CoverageByOrigin.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/CoverageByOrigin.php @@ -60,7 +60,11 @@ public static function fromArray(array $array): self public static function fromJsonString(string $jsonString): self { - return self::fromArray(json_decode($jsonString, true)); + try { + return self::fromArray(json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574740, $e); + } } public function getCoverage(OriginDimensionSpacePoint $originDimensionSpacePoint): ?DimensionSpacePointSet @@ -86,6 +90,10 @@ public function jsonSerialize(): array public function toJson(): string { - return json_encode($this, JSON_THROW_ON_ERROR); + try { + return json_encode($this, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1716575152, $e); + } } } diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/OriginByCoverage.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/OriginByCoverage.php index 4be4b97ca0d..676e22b2d2b 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/OriginByCoverage.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/OriginByCoverage.php @@ -68,7 +68,11 @@ public static function fromArray(array $array): self public static function fromJsonString(string $jsonString): self { - return self::fromArray(json_decode($jsonString, true)); + try { + return self::fromArray(json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574748, $e); + } } public function getOrigin(DimensionSpacePoint $coveredDimensionSpacePoint): ?OriginDimensionSpacePoint @@ -94,6 +98,10 @@ public function jsonSerialize(): array public function toJson(): string { - return json_encode($this, JSON_THROW_ON_ERROR); + try { + return json_encode($this, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1716575158, $e); + } } } diff --git a/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAddress.php b/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAddress.php index 4025758bd8d..e360e6c1fef 100644 --- a/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAddress.php +++ b/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAddress.php @@ -74,7 +74,11 @@ public static function fromArray(array $array): self public static function fromJsonString(string $jsonString): self { - return self::fromArray(\json_decode($jsonString, true, JSON_THROW_ON_ERROR)); + try { + return self::fromArray(\json_decode($jsonString, true, JSON_THROW_ON_ERROR, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574757, $e); + } } public function withAggregateId(NodeAggregateId $aggregateId): self @@ -95,7 +99,7 @@ public function toJson(): string try { return json_encode($this, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { - throw new \RuntimeException(sprintf('Failed to JSON-encode NodeAddress: %s', $e->getMessage()), 1715608338, $e); + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1715608338, $e); } } diff --git a/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php b/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php index f8abbbcc3d7..48358c7315c 100644 --- a/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php +++ b/Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php @@ -65,7 +65,11 @@ public static function fromArray(array $array): self public static function fromJsonString(string $jsonString): self { - return self::fromArray(\json_decode($jsonString, true)); + try { + return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574767, $e); + } } public static function fromNodes(Nodes $nodes): self @@ -98,7 +102,11 @@ public function jsonSerialize(): array public function toJson(): string { - return \json_encode($this, JSON_THROW_ON_ERROR); + try { + return \json_encode($this, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1716575179, $e); + } } /** diff --git a/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedAsset.php b/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedAsset.php index fb828596caf..159e88b7407 100644 --- a/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedAsset.php +++ b/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedAsset.php @@ -48,13 +48,13 @@ public static function fromAsset(Asset $asset): self ); } - public static function fromJson(string $json): self + public static function fromJsonString(string $jsonString): self { try { /** @var array{identifier: string, type: string, title: string, copyrightNotice: string, caption: string, assetSourceIdentifier: string, resource: array{filename: string, collectionName: string, mediaType: string, sha1: string}} $data */ - $data = json_decode($json, true, 512, JSON_THROW_ON_ERROR); + $data = json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { - throw new \InvalidArgumentException(sprintf('Failed to decode JSON: %s', $e->getMessage()), 1646992457); + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1646992457, $e); } return self::fromArray($data); } @@ -115,7 +115,7 @@ public function toJson(): string try { return json_encode($this, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT); } catch (\JsonException $e) { - throw new \RuntimeException(sprintf('Failed to JSON encode asset "%s": %s', $this->identifier, $e->getMessage()), 1646314000); + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1646314000, $e); } } diff --git a/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedImageVariant.php b/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedImageVariant.php index 529d1bc0ac6..7528a3a961d 100644 --- a/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedImageVariant.php +++ b/Neos.ContentRepository.Export/src/Asset/ValueObject/SerializedImageVariant.php @@ -31,13 +31,13 @@ public static function fromImageVariant(ImageVariant $imageVariant): self ); } - public static function fromJson(string $json): self + public static function fromJsonString(string $jsonString): self { try { /** @var array{identifier: string, originalAssetIdentifier: string, name: string, width: int, height: int, presetIdentifier: ?string, presetVariantName: ?string, imageAdjustments: array}>} $data */ - $data = json_decode($json, true, 512, JSON_THROW_ON_ERROR); + $data = json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { - throw new \InvalidArgumentException(sprintf('Failed to decode JSON: %s', $e->getMessage()), 1646992457); + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1646992457, $e); } return self::fromArray($data); } @@ -79,7 +79,7 @@ public function toJson(): string try { return json_encode($this, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT); } catch (\JsonException $e) { - throw new \RuntimeException(sprintf('Failed to JSON encode asset "%s": %s', $this->identifier, $e->getMessage()), 1646314000); + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1646314000, $e); } } diff --git a/Neos.ContentRepository.Export/src/Event/ValueObject/ExportedEvent.php b/Neos.ContentRepository.Export/src/Event/ValueObject/ExportedEvent.php index 8c50097a96e..121372dce4f 100644 --- a/Neos.ContentRepository.Export/src/Event/ValueObject/ExportedEvent.php +++ b/Neos.ContentRepository.Export/src/Event/ValueObject/ExportedEvent.php @@ -32,13 +32,13 @@ public static function fromRawEvent(Event $event): self ); } - public static function fromJson(string $json): self + public static function fromJsonString(string $jsonString): self { try { /** @var array{identifier: string, type: string, payload: array, metadata: array} $data */ - $data = json_decode($json, true, 512, JSON_THROW_ON_ERROR); + $data = json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { - throw new \InvalidArgumentException(sprintf('Failed to decode JSON "%s": %s', $json, $e->getMessage()), 1638432979, $e); + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574888, $e); } return new self( $data['identifier'], @@ -76,7 +76,7 @@ public function toJson(): string try { return json_encode($this, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { - throw new \RuntimeException(sprintf('Failed to encode exported event to JSON: %s', $e->getMessage()), 1638432972, $e); + throw new \RuntimeException(sprintf('Failed to JSON-encode instance of %s: %s', self::class, $e->getMessage()), 1638432972, $e); } } diff --git a/Neos.ContentRepository.Export/src/Event/ValueObject/ExportedEvents.php b/Neos.ContentRepository.Export/src/Event/ValueObject/ExportedEvents.php index 25736270f0a..6cb1357801f 100644 --- a/Neos.ContentRepository.Export/src/Event/ValueObject/ExportedEvents.php +++ b/Neos.ContentRepository.Export/src/Event/ValueObject/ExportedEvents.php @@ -31,7 +31,7 @@ function() use ($jsonl) { if ($json === '') { continue; } - yield ExportedEvent::fromJson($json); + yield ExportedEvent::fromJsonString($json); } } ); diff --git a/Neos.ContentRepository.Export/src/Processors/AssetRepositoryImportProcessor.php b/Neos.ContentRepository.Export/src/Processors/AssetRepositoryImportProcessor.php index b389adababa..209fe74dae0 100644 --- a/Neos.ContentRepository.Export/src/Processors/AssetRepositoryImportProcessor.php +++ b/Neos.ContentRepository.Export/src/Processors/AssetRepositoryImportProcessor.php @@ -88,7 +88,7 @@ public function run(): ProcessorResult private function importAsset(StorageAttributes $file): void { $fileContents = $this->files->read($file->path()); - $serializedAsset = SerializedAsset::fromJson($fileContents); + $serializedAsset = SerializedAsset::fromJsonString($fileContents); /** @var Asset|null $existingAsset */ $existingAsset = $this->assetRepository->findByIdentifier($serializedAsset->identifier); if ($existingAsset !== null) { @@ -123,7 +123,7 @@ private function importAsset(StorageAttributes $file): void private function importImageVariant(StorageAttributes $file): void { $fileContents = $this->files->read($file->path()); - $serializedImageVariant = SerializedImageVariant::fromJson($fileContents); + $serializedImageVariant = SerializedImageVariant::fromJsonString($fileContents); $existingImageVariant = $this->assetRepository->findByIdentifier($serializedImageVariant->identifier); assert($existingImageVariant === null || $existingImageVariant instanceof ImageVariant); if ($existingImageVariant !== null) { diff --git a/Neos.ContentRepository.Export/src/Processors/EventStoreImportProcessor.php b/Neos.ContentRepository.Export/src/Processors/EventStoreImportProcessor.php index df2101f2dc5..d3f51f70a6d 100644 --- a/Neos.ContentRepository.Export/src/Processors/EventStoreImportProcessor.php +++ b/Neos.ContentRepository.Export/src/Processors/EventStoreImportProcessor.php @@ -69,7 +69,7 @@ public function run(): ProcessorResult $keepStreamName = false; while (($line = fgets($eventFileResource)) !== false) { - $event = ExportedEvent::fromJson(trim($line)); + $event = ExportedEvent::fromJsonString(trim($line)); if ($this->contentStreamId === null) { $this->contentStreamId = self::extractContentStreamId($event->payload); $keepStreamName = true; diff --git a/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php b/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php index ff601dc7ab4..2b6914fb486 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Classes/NodeDataToEventsProcessor.php @@ -245,7 +245,6 @@ private function processNodeData(array $nodeDataRow): void * @param NodeAggregateId $nodeAggregateId * @param array $nodeDataRow * @return NodeName[]|void - * @throws \JsonException */ public function processNodeDataWithoutFallbackToEmptyDimension(NodeAggregateId $nodeAggregateId, OriginDimensionSpacePoint $originDimensionSpacePoint, array $nodeDataRow) { diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/NodeDiscriminators.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/NodeDiscriminators.php index 2bedcbce70e..e7e3680eb66 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/NodeDiscriminators.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/NodeDiscriminators.php @@ -37,9 +37,11 @@ private function __construct(NodeDiscriminator ...$iterable) public static function fromJsonString(string $jsonString): self { - $discriminators = \json_decode($jsonString, true); - - return self::fromArray($discriminators); + try { + return self::fromArray(\json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR)); + } catch (\JsonException $e) { + throw new \InvalidArgumentException(sprintf('Failed to JSON-decode "%s" for %s instance: %s', $jsonString, self::class, $e->getMessage()), 1716574902, $e); + } } /** diff --git a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php index 92f7fded383..bff60bff0d0 100644 --- a/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php +++ b/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php @@ -713,7 +713,6 @@ public function discardWorkspaceAction(WorkspaceName $workspace): void * Computes the number of added, changed and removed nodes for the given workspace * * @return array - * @throws \JsonException */ protected function computeChangesCount(Workspace $selectedWorkspace, ContentRepository $contentRepository): array { @@ -739,7 +738,6 @@ protected function computeChangesCount(Workspace $selectedWorkspace, ContentRepo /** * Builds an array of changes for sites in the given workspace * @return array - * @throws \JsonException */ protected function computeSiteChanges(Workspace $selectedWorkspace, ContentRepository $contentRepository): array { diff --git a/Neos.Neos/Classes/FrontendRouting/NodeAddress.php b/Neos.Neos/Classes/FrontendRouting/NodeAddress.php index 1126c00babe..a5386749c3c 100644 --- a/Neos.Neos/Classes/FrontendRouting/NodeAddress.php +++ b/Neos.Neos/Classes/FrontendRouting/NodeAddress.php @@ -64,7 +64,7 @@ public function serializeForUri(): string // the reverse method is {@link NodeAddressFactory::createFromUriString} - ensure to adjust it // when changing the serialization here return $this->workspaceName->value - . '__' . base64_encode(json_encode($this->dimensionSpacePoint->coordinates, JSON_THROW_ON_ERROR)) + . '__' . base64_encode($this->dimensionSpacePoint->toJson()) . '__' . $this->nodeAggregateId->value; }