diff --git a/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php b/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php index 831aada832e..3321ff4ca79 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php +++ b/Neos.ContentRepository.Core/Classes/Feature/Common/ConstraintChecks.php @@ -77,7 +77,7 @@ protected function requireContentStream( WorkspaceName $workspaceName, ContentRepository $contentRepository ): ContentStreamId { - $contentStreamId = ContentStreamIdOverride::findContentStreamIdForWorkspace($contentRepository, $workspaceName); + $contentStreamId = ContentStreamIdOverride::resolveContentStreamIdForWorkspace($contentRepository, $workspaceName); if (!$contentRepository->getContentStreamFinder()->hasContentStream($contentStreamId)) { throw new ContentStreamDoesNotExistYet( 'Content stream "' . $contentStreamId->value . '" does not exist yet.', diff --git a/Neos.ContentRepository.Core/Classes/Feature/Common/ContentStreamIdOverride.php b/Neos.ContentRepository.Core/Classes/Feature/Common/ContentStreamIdOverride.php index 3944bb1f06e..96bf09b3a80 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/Common/ContentStreamIdOverride.php +++ b/Neos.ContentRepository.Core/Classes/Feature/Common/ContentStreamIdOverride.php @@ -15,6 +15,7 @@ namespace Neos\ContentRepository\Core\Feature\Common; use Neos\ContentRepository\Core\ContentRepository; +use Neos\ContentRepository\Core\Feature\WorkspaceCommandHandler; use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; @@ -25,14 +26,15 @@ class ContentStreamIdOverride { /** - * A content stream id that to use instead of the workspace one's {@see ConstraintChecks::requireContentStream()} + * A content stream id that is used instead of the workspace one's {@see ConstraintChecks::requireContentStream()} */ private static ?ContentStreamId $contentStreamIdToUse = null; /** + * Makes the given content stream id available to be used in the given function {@see WorkspaceCommandHandler::handleRebaseWorkspace()} * @internal */ - public static function withContentStreamIdToUse(ContentStreamId $contentStreamIdToUse, \Closure $fn): void + public static function applyContentStreamIdToClosure(ContentStreamId $contentStreamIdToUse, \Closure $fn): void { if (self::$contentStreamIdToUse !== null) { throw new \Exception('Recursive content stream override is not supported', 1710426945); @@ -40,17 +42,15 @@ public static function withContentStreamIdToUse(ContentStreamId $contentStreamId self::$contentStreamIdToUse = $contentStreamIdToUse; try { $fn(); - } catch (\Throwable $th) { + } finally { self::$contentStreamIdToUse = null; - throw $th; } - self::$contentStreamIdToUse = null; } /** * @internal */ - public static function findContentStreamIdForWorkspace(ContentRepository $contentRepository, WorkspaceName $workspaceName): ContentStreamId + public static function resolveContentStreamIdForWorkspace(ContentRepository $contentRepository, WorkspaceName $workspaceName): ContentStreamId { $contentStreamId = self::$contentStreamIdToUse ?: $contentRepository->getWorkspaceFinder()->findOneByName($workspaceName)?->currentContentStreamId; diff --git a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php index 8d1d649a78a..0e6c3fdd33f 100644 --- a/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php +++ b/Neos.ContentRepository.Core/Classes/Feature/WorkspaceCommandHandler.php @@ -383,7 +383,7 @@ private function handleRebaseWorkspace( // - extract the commands from the to-be-rebased content stream; and applies them on the new content stream $originalCommands = $this->extractCommandsFromContentStreamMetadata($workspaceContentStreamName); $rebaseStatistics = new WorkspaceRebaseStatistics(); - ContentStreamIdOverride::withContentStreamIdToUse( + ContentStreamIdOverride::applyContentStreamIdToClosure( $command->rebasedContentStreamId, function () use ($originalCommands, $contentRepository, $rebaseStatistics, $workspaceContentStreamName, $baseWorkspace): void { foreach ($originalCommands as $i => $originalCommand) { @@ -531,7 +531,7 @@ private function handlePublishIndividualNodesFromWorkspace( try { // 4) using the new content stream, apply the matching commands - ContentStreamIdOverride::withContentStreamIdToUse( + ContentStreamIdOverride::applyContentStreamIdToClosure( $command->contentStreamIdForMatchingPart, function () use ($matchingCommands, $contentRepository, $baseWorkspace, $command): void { foreach ($matchingCommands as $matchingCommand) { @@ -565,7 +565,7 @@ function () use ($matchingCommands, $contentRepository, $baseWorkspace, $command )->block(); // 7) apply REMAINING commands to the workspace's new content stream - ContentStreamIdOverride::withContentStreamIdToUse( + ContentStreamIdOverride::applyContentStreamIdToClosure( $command->contentStreamIdForRemainingPart, function () use ($contentRepository, $remainingCommands) { foreach ($remainingCommands as $remainingCommand) { @@ -668,7 +668,7 @@ private function handleDiscardIndividualNodesFromWorkspace( // 4) using the new content stream, apply the commands to keep try { - ContentStreamIdOverride::withContentStreamIdToUse( + ContentStreamIdOverride::applyContentStreamIdToClosure( $command->newContentStreamId, function () use ($commandsToKeep, $contentRepository, $baseWorkspace, $command): void { foreach ($commandsToKeep as $matchingCommand) { diff --git a/Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php b/Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php index f4fc1585484..3a566f628c2 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php +++ b/Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php @@ -90,7 +90,7 @@ public function migratePropertiesToUnset(\Closure $outputFn) $warnings = 0; $backupEventTableName = DoctrineEventStoreFactory::databaseTableName($this->contentRepositoryId) - . '_bak_' . date('Y_m_d_H_i_s'); + . '_bkp_' . date('Y_m_d_H_i_s'); $outputFn(sprintf('Backup: copying events table to %s', $backupEventTableName)); $this->copyEventTable($backupEventTableName); @@ -251,7 +251,7 @@ public function migrateMetaDataToWorkspaceName(\Closure $outputFn) $this->eventsModified = []; $backupEventTableName = DoctrineEventStoreFactory::databaseTableName($this->contentRepositoryId) - . '_bak_' . date('Y_m_d_H_i_s'); + . '_bkp_' . date('Y_m_d_H_i_s'); $outputFn('Backup: copying events table to %s', [$backupEventTableName]); $this->copyEventTable($backupEventTableName);