From 92f3bb78cf6bf383853a220d1e863ce72ab1e32b Mon Sep 17 00:00:00 2001 From: Thorben Nissen Date: Sun, 27 Aug 2017 17:52:22 +0200 Subject: [PATCH 1/2] [BUGFIX] Link syntax migration stops after fourth match Use the right array of matches to iterate over to ensure every link in a field is migrated. --- Classes/Command/LinkMigrationCommandController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Command/LinkMigrationCommandController.php b/Classes/Command/LinkMigrationCommandController.php index 2fd7901..2e70ea4 100644 --- a/Classes/Command/LinkMigrationCommandController.php +++ b/Classes/Command/LinkMigrationCommandController.php @@ -151,7 +151,7 @@ protected function gatherRecordsToMigrate($table, $listOfFields) // The last string is optional. If it exists, it is already a 4-part record reference, // i.e. a reference using the new syntax and which does not need to be migrated. preg_match_all('/record:(\w+):(\w+)(:\w+)?/', $record[$field], $matches); - foreach ($matches as $index => $match) { + foreach ($matches[0] as $index => $match) { // Consider only matches that have 3 parts (i.e. 4th part is empty) // NOTE: although not captured, the first part is "record:" if ($matches[3][$index] === '') { From 1fcdf480919ceb04b1d4870fe538f56e8d801d41 Mon Sep 17 00:00:00 2001 From: Thorben Nissen Date: Sun, 27 Aug 2017 17:58:22 +0200 Subject: [PATCH 2/2] [BUGFIX] Link validation breaks with ":" in link title Use a regular expression to correctly determine `configurationKey`, `table` and `id` instead of exploding by ":". --- Classes/Domain/Model/RecordLink.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Classes/Domain/Model/RecordLink.php b/Classes/Domain/Model/RecordLink.php index 04693d5..edeec21 100644 --- a/Classes/Domain/Model/RecordLink.php +++ b/Classes/Domain/Model/RecordLink.php @@ -115,12 +115,11 @@ public function setRecordReference($recordReference) if (empty($recordReference)) { throw new \InvalidArgumentException('Record reference cannot be empty', 1457367830); } - $referenceParts = explode(':', $recordReference); - if (count($referenceParts) === 4) { - $this->recordReference = $recordReference; - $this->configurationKey = $referenceParts[1]; - $this->table = $referenceParts[2]; - $this->id = (int)$referenceParts[3]; + if (preg_match('/^record:(\w+):(\w+):(\d+)/', $recordReference, $matches)) { + $this->recordReference = $matches[0]; + $this->configurationKey = $matches[1]; + $this->table = $matches[2]; + $this->id = (int)$matches[3]; } else { throw new \InvalidArgumentException( 'Expected record reference structure is "record:key:table:id"',