diff --git a/Neos.ContentRepository.Core/Classes/SharedModel/Workspace/WorkspaceName.php b/Neos.ContentRepository.Core/Classes/SharedModel/Workspace/WorkspaceName.php index 512c52aa368..e6d9e4a87e2 100644 --- a/Neos.ContentRepository.Core/Classes/SharedModel/Workspace/WorkspaceName.php +++ b/Neos.ContentRepository.Core/Classes/SharedModel/Workspace/WorkspaceName.php @@ -23,9 +23,9 @@ */ final class WorkspaceName implements \JsonSerializable { - public const MAX_LENGTH = 30; + public const MAX_LENGTH = 36; - private const PATTERN = '/^[a-z][a-z0-9\-]{0,' . (self::MAX_LENGTH - 1) . '}$/'; + private const PATTERN = '/^[a-z0-9][a-z0-9\-]{0,' . (self::MAX_LENGTH - 1) . '}$/'; public const WORKSPACE_NAME_LIVE = 'live'; @@ -89,8 +89,7 @@ public static function transliterateFromString(string $name): self // If the name is still invalid at this point, we fall back to md5 if (!self::hasValidFormat($name)) { - $prefix = 'workspace-'; - $name = $prefix . substr(md5($originalName), 0, self::MAX_LENGTH - strlen($prefix)); + $name = substr(md5($originalName), 0, self::MAX_LENGTH); } return self::fromString($name); diff --git a/Neos.ContentRepository.Core/Tests/Unit/SharedModel/Workspace/WorkspaceNameTest.php b/Neos.ContentRepository.Core/Tests/Unit/SharedModel/Workspace/WorkspaceNameTest.php index 6d01e897715..d31cd4e7cad 100644 --- a/Neos.ContentRepository.Core/Tests/Unit/SharedModel/Workspace/WorkspaceNameTest.php +++ b/Neos.ContentRepository.Core/Tests/Unit/SharedModel/Workspace/WorkspaceNameTest.php @@ -58,11 +58,10 @@ public function tryFromStringReturnsInstanceForValidValues(string $value): void private static function invalidWorkspaceNames(): iterable { yield 'empty string' => ['']; - yield 'only digits' => ['123']; yield 'leading dash' => ['-invalid']; yield 'upper case characters' => ['thisIsNotAllowed']; yield 'whitespace' => ['this neither']; - yield 'exceeding max length' => ['this-is-just-a-little-too-long-']; + yield 'exceeding max length' => ['this-is-just-a-little-little-bit-too-long-']; } /** @@ -99,8 +98,8 @@ private static function transliterateFromStringDataProvider(): iterable yield 'chinese characters' => ['value' => '北京', 'expectedResult' => 'bei-jing']; yield 'german umlauts' => ['value' => 'ümläute', 'expectedResult' => 'umlaute']; yield 'white space' => ['value' => ' Contains spaces ', 'expectedResult' => 'contains-spaces']; - yield 'exceeding max length' => ['value' => 'This name is just a little too long', 'expectedResult' => 'this-name-is-just-a-little-too']; - yield 'only special characters' => ['value' => '-', 'expectedResult' => 'workspace-336d5ebc5436534e61d1']; + yield 'exceeding max length' => ['value' => 'This name is just a little little bit too long', 'expectedResult' => 'this-name-is-just-a-little-little-bi']; + yield 'only special characters' => ['value' => '-', 'expectedResult' => '336d5ebc5436534e61d16e63ddfca327']; } /** diff --git a/Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php b/Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php index 011e7b589ee..ba739111f89 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php +++ b/Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php @@ -388,20 +388,34 @@ public function migratePayloadToValidWorkspaceNames(\Closure $outputFn): void $statementWorkspaceName = <<connection->executeStatement($statementWorkspaceName); $statementBaseWorkspaceName = <<connection->executeStatement($statementBaseWorkspaceName); $this->connection->commit(); diff --git a/Neos.Neos/Classes/Domain/Service/WorkspaceNameBuilder.php b/Neos.Neos/Classes/Domain/Service/WorkspaceNameBuilder.php index 44d75e72086..fc08f99cb26 100644 --- a/Neos.Neos/Classes/Domain/Service/WorkspaceNameBuilder.php +++ b/Neos.Neos/Classes/Domain/Service/WorkspaceNameBuilder.php @@ -30,6 +30,6 @@ public static function fromAccountIdentifier(string $accountIdentifier): Workspa 1645656253 ); } - return WorkspaceName::fromString($name); + return WorkspaceName::transliterateFromString($name); } }