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

Task/centralise rebaseable command enrich with command #5356

Conversation

mhsdesign
Copy link
Member

@mhsdesign mhsdesign commented Nov 8, 2024

FYI the essence is in 76a975d

<?php

declare(strict_types=1);

namespace Neos\ContentRepository\Core\CommandHandler;

use Neos\ContentRepository\Core\Feature\Common\RebasableToOtherWorkspaceInterface;

/**
 * Optional interface for all content repository command serializer
 *
 * See {@see RebasableToOtherWorkspaceInterface} for more details regarding serialized commands.
 *
 * @internal no public API, because commands are no extension points of the CR
 */
interface CommandSerializerInterface
{
    public function canSerialize(CommandInterface $command): bool;

    public function serialize(CommandInterface $command, CommandHandlingDependencies $commandHandlingDependencies): RebasableToOtherWorkspaceInterface;
}

#5301 (comment)

Alright, at least according to the tests this works now. I also went through all Rebasable commands to check if the events get enriched. the Dimension ones were the only missing. IMHO we should centralize this behavior, I opted against doing it here though as I think we need to consider if there would have to be any more logic involved to decide what gets enriched with commands, in what way, when we override the command if there is already metadata and finally what the causation ids are. I guess we could ignore all these questions and centralize it, but it warrants a closer look and is therefore out of scope of this change.

Upgrade instructions

Review instructions

Checklist

  • Code follows the PSR-2 coding style
  • Tests have been created, run and adjusted as needed
  • The PR is created against the lowest maintained branch
  • Reviewer - PR Title is brief but complete and starts with FEATURE|TASK|BUGFIX
  • Reviewer - The first section explains the change briefly for change-logs
  • Reviewer - Breaking Changes are marked with !!! and have upgrade-instructions

bwaidelich and others added 12 commits November 7, 2024 18:57
by only using "official" commands
…ion and get hold of the `$serializedCommand`
neos#5301 (comment)

> Alright, at least according to the tests this works now. I also went through all Rebasable commands to check if the events get enriched. the Dimension ones were the only missing. IMHO we should centralize this behavior, I opted against doing it here though as I think we need to consider if there would have to be any more logic involved to decide what gets enriched with commands, in what way, when we override the command if there is already metadata and finally what the causation ids are. I guess we could ignore all these questions and centralize it, but it warrants a closer look and is therefore out of scope of this change.
@mhsdesign
Copy link
Member Author

mhsdesign commented Nov 8, 2024

I found a flaw with CreateRootNodeAggregateWithNode and ChangeNodeAggregateType, as they dont have serialized counterparts, but still require their TetheredDescendantNodeAggregateIds to be precalculated, so we would have to pass them too through the CommandSerializerInterface:

// Write the auto-created descendant node aggregate ids back to the command;
// so that when rebasing the command, it stays fully deterministic.
$command = $command->withTetheredDescendantNodeAggregateIds($descendantNodeAggregateIds);

That would make the API in

public function canSerialize(CommandInterface $command): bool;

public function serialize(CommandInterface $command, CommandHandlingDependencies $commandHandlingDependencies): RebasableToOtherWorkspaceInterface;

less tidy because we need to allow CommandInterface|RebasableToOtherWorkspaceInterface everywhere.

@mhsdesign
Copy link
Member Author

We discussed that centralising the enrichment would be cool, but its also just making "wrong" things pretty :D
Instead we should strive in the long run to possibly reconstruct the commands from the events or just apply the events with constraint checks and let those fail.
For that reason ill dump my CommandSerializerInterface idea!

(see #5348)

@mhsdesign mhsdesign closed this Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants