Skip to content

fix(schema): keep nested array manager when it shares its parent name - #5658

Open
theluckystrike wants to merge 1 commit into
apostrophecms:mainfrom
theluckystrike:fix/4129-array-item-area-field
Open

theluckystrike wants to merge 1 commit into
apostrophecms:mainfrom
theluckystrike:fix/4129-array-item-area-field

Conversation

@theluckystrike

Copy link
Copy Markdown
Contributor

Fixes #4129

When an array field holds a nested array with the same name, both register under the same scopedArrayName. The nested one replaced the parent's entry in arrayManagers, so getManagerOf on an outer item no longer knew its area field and rendering threw "has no field named area".

The comment above that code says the stored name keeps its flat form. So I left it alone, and nothing needs a migration. When a second array registers under a name that's already there, its fields are added to the existing manager's schema, and on a name clash the first one wins. The merged schema is a copy, so the parent field's own schema isn't touched.

Every reader I found looks fields up by name (area rendering, {% field %}, the wysiwyg list, the area patch path), and none validates or sanitizes through it.

test/arrays-nested-same-name.js renders an area on an outer item whose nested array shares its name, and checks that a stored item with the flat name still resolves its manager. Both fail on main. Both pass with the fix. The full mocha suite on sqlite gives the same results as main, apart from one test in document-versions.js that fails on both runs but not always the same one.

Michael

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A3: Server error when nested array has a same slug as its parent array while there's also an area in the schema

1 participant