Skip to content

BUG: Transformation "ChangeNodeType" does not work on documents in Neos 9, because it believes that ContentCollection is not an allowed child node for Documents #5731

@theDex

Description

@theDex

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When executing a node migration with the transformation "ChangeNodeType" on a Document-NodeType it throws an error that ContentCollections are not an allowed child node for the new document, even if they specify a child node 'main' with that type.

If you set the option forceDeleteNonMatchingChildren: true it works as intended and does not delete the ContentCollection, but it would be preferable to not have to set that for every node migration that includes Document-NodeTypes.

It seems the process of transforming correctly checks for named child nodes (like 'main'), but the check beforehand only checks if a NodeType is generally allowed as a childNode of the NodeType you're migrating to.

Expected Behavior

The check before the ChangeNodeType-Transformation should correctly check for named child nodes when it tries to determine if a child node is allowed in the new NodeType.

Steps To Reproduce

I guess it is also reproducable in other ways, but the easiest for me was to install an fresh Neos (ddev) with the neos/demo SitePackage.

Then I added a new NodeType:

'Neos.Demo:Document.Page2':
  superTypes:
    'Neos.Demo:Document.Page': true
  ui:
    label: 'Page 2'
prototype(Neos.Demo:Document.Page2) < prototype(Neos.Demo:Document.Page)

And a simple NodeMigration:

comments: 'Test Migration'
migration:
  - filters:
      - type: 'NodeType'
        settings:
          nodeType: 'Neos.Demo:Document.Page'

    transformations:
      - type: 'ChangeNodeType'
        settings:
          newType: 'Neos.Demo:Document.Page2'

If you try to run the migration the following error is thrown:

Comments
  Test Migration
Node type "Neos.Demo:Collection.Content.Main" is not allowed for child nodes of type Neos.Demo:Document.Page2

  Type: Neos\ContentRepository\Core\SharedModel\Exception\NodeConstraintException
  Code: 1707561400
  File: Packages/Libraries/neos/contentrepository-core/Classes/Feature/Common/Const
        raintChecks.php
  Line: 340

Environment

- Flow: 9.1.0
- Neos: 9.1.1
- PHP: 8.3.27

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions