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 220 forks source link

BUG: Node cannot be deleted in workspace if it has been removed in another dimension in the same workspace #5031

Open beromir opened 2 months ago

beromir commented 2 months ago

Is there an existing issue for this?

Current Behavior

If you delete a node in a workspace that has already been deleted in the workspace in another dimension, the node is not marked as removed in the database.

Expected Behavior

There should be two database entries for the two dimensions where the node is marked as removed.

Steps To Reproduce

  1. Configure a bilingual site
    
    Neos:
    ContentRepository:
    contentDimensions:
      language:
        label: 'Language'
        icon: 'icon-language'
        default: de
        defaultPreset: de
        presets:
          de:
            label: 'German'
            values:
              - de
            uriSegment: ''
          en:
            label: 'English'
            values:
              - en
              - de
            uriSegment: ''
2. Create content node in one dimension
3. Make changes to the node in another dimension
4. Publish changes
5. Create a new workspace
6. Delete node in one dimension in the new workspace
7. Publish changes
8. Delete node in the other dimension in the workspace
9. Changes cannot be published because there are no

### Environment

```markdown
- Flow: 8.3.8
- Neos: 8.3.12
- PHP: 8.2

Anything else?

If you delete the node in the two dimensions without publishing in between, two entries will be created in the database for the personal workspace. After publishing, the two nodes are marked as removed in the database for the workspace. So as it should be.

nezaniel commented 1 month ago

Hi there,

thanks for reporting! before diving in more deeply I have one question: Which is the one and which is the other language you create/delete the nodes in? Due to the fallback mechanism in place (en->de), the exact order of events is important.

beromir commented 1 month ago

Hi @nezaniel, this does not make a difference.

These are the database entries for the node identifier after the node was created in de and modified in en:

workspace identifier removed dimensionvalues
live 87f3f35d-f03e-4632-879a-d95b108d0005 0 de
live 87f3f35d-f03e-4632-879a-d95b108d0005 0 en

After switching to the new workspace, removing the node and publishing it:

workspace identifier removed dimensionvalues
live 87f3f35d-f03e-4632-879a-d95b108d0005 0 de
live 87f3f35d-f03e-4632-879a-d95b108d0005 0 en
staging-ggxco 87f3f35d-f03e-4632-879a-d95b108d0005 1 de

If you now try to remove the node in en, no new database entry will be created. The same thing happens, if you remove the node in en first.

I may have found the problem: https://github.com/neos/neos-development-collection/blob/b6236081d8be0344c13ac704acdbb0235fb45c8b/Neos.ContentRepository/Classes/Domain/Model/NodeData.php#L1078-L1085

If I add removedNodes: true to $this->nodeDataRepository->findOneByIdentifier the changes are applied and a new database entry is created: workspace identifier removed dimensionvalues
live 87f3f35d-f03e-4632-879a-d95b108d0005 0 de
live 87f3f35d-f03e-4632-879a-d95b108d0005 0 en
staging-ggxco 87f3f35d-f03e-4632-879a-d95b108d0005 1 de
staging-ggxco 87f3f35d-f03e-4632-879a-d95b108d0005 1 en

The problem is that it tries to find the node in the staging workspace, but as it is already marked as removed for the other dimension the method returns null. But as I understand from the method description, it should also search in another base workspace. So it should also search in live? But this does not seem to be happening.