Problem/Motivation

This entity node cannot be referenced as it is either a child or the same entity.

Steps to reproduce

Setup a simple workflow with Draft, Needs Review, Published, Archived.
In Basic page node type enable "Create new revision" in publishing option and add field_parent as an Entity reference hierarchy field.

Step 1. Create 'Page Test' then save daft.
Step 2. Create 'Page Test 1' and in field_parent select 'Page Test' then save daft.
Step 3. Create 'Page Test 2' and in field_parent select 'Page Test' then save daft.
Step 4. Edit 'Page Test 2' and in field_parent remove 'Page Test' then save draft.
Step 5. Edit 'Page Test' and in field_parent select 'Page Test 2' then try to save the node => The error show up in field_parent field with message "This entity node cannot be referenced as it is either a child or the same entity."

Proposed resolution

We may need to update validate method in ValidHierarchyReferenceConstraintValidator to exclude non default revisions of children.
Same what we did with loadEntitiesForTreeNodesWithoutAccessChecks in EntityTreeNodeMapper.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

tannguyenhn created an issue. See original summary.

tannguyenhn’s picture

tannguyenhn’s picture

Issue summary: View changes
jibran’s picture

Title: Validate in ValidHierarchyReferenceConstraintValidator should by pass non default entity revisions » Validate in ValidHierarchyReferenceConstraintValidator should bypass non default entity revisions
Issue tags: +Need tests

Can we add tests for this?

tannguyenhn’s picture

A patch with test.

tannguyenhn’s picture

Update the test

jibran’s picture

Can you please upload the test only patch?

tannguyenhn’s picture

StatusFileSize
new1.26 KB

Here @jibran
The test only patch.

  • larowlan committed 52f85e5c on 3.x
    Issue #3333675 by tannguyenhn, jibran: Validate in...
larowlan’s picture

Status: Active » Fixed
Issue tags: -Need tests

Thanks, cutting a 3.3.4 release

larowlan’s picture

jibran’s picture

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.