From cbc1ea43ed3e400412d6886ee6fb16caa7466c75 Mon Sep 17 00:00:00 2001 From: Oliver Hader Date: Sat, 28 Sep 2019 18:57:51 +0200 Subject: [PATCH] [BUGFIX] Correctly unpack CorrelationId version Resolves: #89299 Releases: master Change-Id: Ib4e63b7baadb604ca77469e66af5bc060f79a8f6 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61856 Tested-by: Oliver Hader Tested-by: TYPO3com Reviewed-by: Oliver Hader --- .../Classes/DataHandling/Model/CorrelationId.php | 2 +- .../Unit/DataHandling/Model/CorrelationIdTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/typo3/sysext/core/Classes/DataHandling/Model/CorrelationId.php b/typo3/sysext/core/Classes/DataHandling/Model/CorrelationId.php index 9d9908b3b727..7bb9387dbecc 100644 --- a/typo3/sysext/core/Classes/DataHandling/Model/CorrelationId.php +++ b/typo3/sysext/core/Classes/DataHandling/Model/CorrelationId.php @@ -81,7 +81,7 @@ public static function fromString(string $correlationId): self throw new \InvalidArgumentException('Unknown format', 1569620858); } - $flags = (int)unpack('n', $matches['flags']); + $flags = hexdec($matches['flags'] ?? 0); $aspects = !empty($matches['aspects']) ? explode('/', ltrim($matches['aspects'] ?? '', '/')) : []; $target = static::create() ->withSubject($matches['subject']) diff --git a/typo3/sysext/core/Tests/Unit/DataHandling/Model/CorrelationIdTest.php b/typo3/sysext/core/Tests/Unit/DataHandling/Model/CorrelationIdTest.php index 43ccc598cf3d..39ecd228d4db 100644 --- a/typo3/sysext/core/Tests/Unit/DataHandling/Model/CorrelationIdTest.php +++ b/typo3/sysext/core/Tests/Unit/DataHandling/Model/CorrelationIdTest.php @@ -83,4 +83,16 @@ public function scopeIsConsidered(): void ->withAspects('aspect-a'); static::assertSame('0400$scope:subject/aspect-a', (string)$correlationId); } + + /** + * @test + */ + public function doesNotVary(): void + { + $correlationId = '0400$scope:subject/aspect-a/aspect-b'; + static::assertSame( + $correlationId, + (string)CorrelationId::fromString($correlationId) + ); + } }