Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: improve performance for publish / discard workspaces #3494

Open
wants to merge 1 commit into
base: 9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Exception\NodeAggregateCurrentlyDoesNotExist;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\CatchUpTriggerWithSynchronousOption;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
Expand Down Expand Up @@ -235,12 +236,16 @@ public function publishAction(array $nodeContextPaths, string $targetWorkspaceNa
);
}
try {
$contentRepository->handle(
PublishIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToPublish)
)
)->block();
// performance speedup
CatchUpTriggerWithSynchronousOption::synchronously(fn() =>
$contentRepository->handle(
PublishIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToPublish)
)
)->block()
);

} catch (NodeAggregateCurrentlyDoesNotExist $e) {
throw new NodeAggregateCurrentlyDoesNotExist(
'Node could not be published, probably because of a missing parentNode. Please check that the parentNode has been published.',
Expand Down Expand Up @@ -294,12 +299,16 @@ public function discardAction(array $nodeContextPaths): void
$nodeAddress->dimensionSpacePoint
);
}
$contentRepository->handle(
DiscardIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToDiscard)
)
)->block();

// performance speedup
CatchUpTriggerWithSynchronousOption::synchronously(fn() =>
$contentRepository->handle(
DiscardIndividualNodesFromWorkspace::create(
$workspaceName,
NodeIdsToPublishOrDiscard::create(...$nodeIdentifiersToDiscard)
)
)->block()
);

$success = new Success();
$success->setMessage(sprintf('Discarded %d node(s).', count($nodeContextPaths)));
Expand Down
27 changes: 17 additions & 10 deletions Classes/Service/PublishingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\PublishWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Command\RebaseWorkspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\CatchUpTriggerWithSynchronousOption;
use Neos\Flow\Annotations as Flow;

/**
Expand All @@ -31,16 +32,22 @@ class PublishingService
public function publishWorkspace(ContentRepository $contentRepository, WorkspaceName $workspaceName): void
{
// TODO: only rebase if necessary!
$contentRepository->handle(
RebaseWorkspace::create(
$workspaceName
)
)->block();
// performance speedup
CatchUpTriggerWithSynchronousOption::synchronously(fn() =>
$contentRepository->handle(
RebaseWorkspace::create(
$workspaceName
)
)->block()
);

$contentRepository->handle(
new PublishWorkspace(
$workspaceName
)
)->block();
// performance speedup
CatchUpTriggerWithSynchronousOption::synchronously(fn() =>
$contentRepository->handle(
new PublishWorkspace(
$workspaceName
)
)->block()
);
}
}