Skip to content

Commit

Permalink
TASK: Apply review suggestions
Browse files Browse the repository at this point in the history
- Update Neos.ContentRepository.Core/Classes/Feature/Common/ContentStreamIdOverride.php
- Update Neos.ContentRepositoryRegistry/Classes/Service/EventMigrationService.php

Co-authored-by: Bastian Waidelich <b.waidelich@wwwision.de>
  • Loading branch information
2 people authored and ahaeslich committed Mar 15, 2024
1 parent 43827ba commit 416017a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,11 +26,12 @@
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
Expand All @@ -40,17 +42,16 @@ 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 416017a

Please sign in to comment.