diff --git a/src/lib/Repository/NameSchema/NameSchemaService.php b/src/lib/Repository/NameSchema/NameSchemaService.php index 4f1d384a33..51cd29c0b0 100644 --- a/src/lib/Repository/NameSchema/NameSchemaService.php +++ b/src/lib/Repository/NameSchema/NameSchemaService.php @@ -286,12 +286,16 @@ public function buildNames(array $tokenValues, string $nameSchema): array $names = []; foreach ($tokenValues as $languageCode => $tokenValue) { - $name = $filteredNameSchema; - foreach ($tokens as $token) { - $string = $this->resolveToken($token, $tokenValue, $groupLookupTable); - $name = str_replace($token, $string, $name); - } - $names[$languageCode] = $this->validateNameLength($name); + $names[$languageCode] = $this->validateNameLength( + str_replace( + $tokens, + array_map( + fn (string $token): string => $this->resolveToken($token, $tokenValue, $groupLookupTable), + $tokens + ), + $filteredNameSchema + ) + ); } return $names;