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
264 stars 222 forks source link

BUG: Auto-created (document) child nodes are not published alongside the parent #3926

Open bwaidelich opened 2 years ago

bwaidelich commented 2 years ago

Is there an existing issue for this?

Current Behavior

When creating a NodeType with an auto-created (aka tethered) child node that extends Neos.Neos:Document, one can partially publish only the parent node leading to inconsistencies:

https://user-images.githubusercontent.com/307571/196664534-f9a25a67-8022-4797-a303-10471598e4bf.mov

Expected Behavior

The publishing of a document node should publish auto-created child nodes (including document nodes) too

Steps To Reproduce

  1. Create two node types:
'Some.Package:Document.ParentPage':
  ui:
    label: 'Parent'
  superTypes:
    'Neos.Neos:Document': true
  childNodes:
    'child':
      type: 'Some.Package:Document.ChildPage'
'Some.Package:Document.ChildPage':
  ui:
    label: 'Child'
  superTypes:
    'Neos.Demo:Document.Page': true
  1. Create an instance of the parent page
  2. Publish just the parent page
  3. Discard any pending changes

=> the child page will be removed

Environment

- Neos: all (5.3+)

Anything else?

Fixing this will probably affect the workspaces modul as well because you should not be able to publish the auto-created child nodes individually:

image

Update: The workspace module already disallows to publish only the parent page no matter whether the child documents are auto-created.

Note: This is slightly related to https://github.com/neos/neos-ui/issues/2282 but in this case I consider this a bug because it allows the editor to overrule the behavior. Allowing auto-created child nodes to be disabled is a decision of the integrator – furthermore in this case the child nodes are not just disabled but non-existent after publishing

bwaidelich commented 2 years ago

Fixing this behavior could be as easy as removing the Neos.Neos:Document-filter from https://github.com/neos/neos-development-collection/blob/3b4ad5fe32f57c29bb9fd09547b8c848fc1ec0d4/Neos.Neos/Classes/Service/PublishingService.php#L103

But that would mean that all changes are always published even if the nodes already existed. Instead we should only publish auto-created child document nodes only if they don't exist yet in the target workspace..