Skip to content

Commit f3f7110

Browse files
committed
BUGFIX: Prevent creating a second content release with the same id
1 parent 4876ca0 commit f3f7110

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Classes/PrepareContentRelease/Infrastructure/RedisContentReleaseService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ class RedisContentReleaseService
4141
public function createContentRelease(ContentReleaseIdentifier $contentReleaseIdentifier, PrunnerJobId $prunnerJobId, ContentReleaseLogger $contentReleaseLogger, string $workspaceName = 'live'): void
4242
{
4343
$redis = $this->redisClientManager->getPrimaryRedis();
44+
45+
// Check there is no existing release with the same identifier
46+
$existingRelease = $redis->get($this->redisKeyService->getRedisKeyForPostfix($contentReleaseIdentifier, 'meta:info'));
47+
if ($existingRelease) {
48+
$contentReleaseLogger->error(sprintf('Content Release "%s" already exists', $contentReleaseIdentifier->getIdentifier()));
49+
throw new \RuntimeException(sprintf('Content Release "%s" already exists, cannot create a release with the same identifier', $contentReleaseIdentifier->getIdentifier()), 1689750292);
50+
}
51+
4452
$metadata = ContentReleaseMetadata::create($prunnerJobId, new \DateTimeImmutable(), $workspaceName);
4553
$redis->multi();
4654
try {

0 commit comments

Comments
 (0)