neos / neos-development-collection

The unified repository containing the Neos core packages, used for Neos development.
https://www.neos.io/
GNU General Public License v3.0
260 stars 221 forks source link

BUG: Adding dimension config to an existing CR does not work #4984

Open c4ll-m3-j4ck opened 5 months ago

c4ll-m3-j4ck commented 5 months ago

Is there an existing issue for this?

Current Behavior

When following the documentation at https://docs.neos.io/guide/content-repository/content-dimensions/migrating-dimension-config in order to add dimension-config to a neos-instance that didn't previously have a dimension config, the provided commands lead to an error and make it impossible to migrate the cr to the new dimensions.

After adding the configuration for the new dimensions, I ran ./flow content:refreshRootNodeDimensions. This worked fine and I can see the changes in the database as the dimensionspacepoints are created in db.cr_default_p_graph_dimensionspacepoints.

However, when I then run the next command ./flow content:moveDimensionSpacePoint '{}' '{"language": "en"}', the command fails with the error the content stream 0359b978-1f56-45b1-853e-078fa25c0a72 already contained nodes in dimension space point {"language":"en"} - this is not allowed.

Right not it seems like it is not possible to add dimensions to an already existing CR.

Expected Behavior

The nodes should be moved to the correct dimension.

Steps To Reproduce

No response

Environment

- Flow: 9.0.x-dev
- Neos: 9.0.x-dev
- PHP: 8.3

Anything else?

No response

c4ll-m3-j4ck commented 5 months ago

Some additional context:

It seems like that on running the first command, hierarchy-relations with the new dimensionspacepointhash are created.

In Neos\ContentRepository\Core\Feature\DimensionSpaceAdjustment\DimensionSpaceCommandHandler::requireDimensionSpacePointToBeEmptyInContentStream a check is run against the subgraph, which returns an existing node (Neos.Neos:Sites) in this case.

dlubitz commented 2 weeks ago

Thank you @c4ll-m3-j4ck for this bug report. We had a deeper look into this and figured out some issues in the documentation itself, as also in the code.

The naming of refreshRootNodeDimensions might be missleading and suggest that this operation is refreshing RootNodeDimensions at any time. Actually it creates new empty RootNodeDimensions for all configured but not existing RootNodeDimensions. So it is important, that you run this command AFTER you moved all dimensionSpacePoints.

So we will rename refreshRootNodeDimensions to createEmptyRootNodeDimensions to make this more clear.

Also we will remove the CLI command and convert this into a NodeMigration/Transformation, to prevent mixup of ways to change the content. Moreover the CLI command is operating on a global level instead on a workspace level as the NodeMigrations do. This could also lead to more issues if you combine the CLI command with some NodeMigration.

dlubitz commented 2 weeks ago

I've updated the documentation in a first step to provide a working guide for now: https://docs.neos.io/guide/content-repository/content-dimensions/migrating-dimension-config