Skip to content

[6.x] Fix ensuring config on fields from imported fieldsets - #15187

Open
duncanmcclean wants to merge 1 commit into
6.xfrom
ensure-imported-field-config
Open

[6.x] Fix ensuring config on fields from imported fieldsets#15187
duncanmcclean wants to merge 1 commit into
6.xfrom
ensure-imported-field-config

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where a user without the "edit other authors entries" permission would get an Undefined array key "author" error when creating or editing an entry, if the blueprint's author field came from an imported fieldset.

This was happening because getTabFields built its lookup from the raw blueprint contents using keyBy('handle'). An import: row has no handle, so the fields inside an imported fieldset were invisible to the lookup, while hasFieldInTab resolves imports and reported them as present. ensureFieldHasConfig trusted the latter, then indexed into the former.

This PR fixes it by resolving import: rows into their fields, and writing the override into the import's config array, keyed by the field's handle within the fieldset. That's the same shape ensureField already produces for imports.

This PR also stops removeField erroring on a field from an imported fieldset. It can't be removed on its own, since the only entry in the contents is the whole fieldset, so it's left in place.

Fixes #8805
Related: #8803

`getTabFields` built its lookup from the raw blueprint contents using
`keyBy('handle')`. An `import:` row has no `handle`, so the fields inside
an imported fieldset were invisible to the lookup, while `hasFieldInTab`
resolves imports and reported them as present. That mismatch made
`ensureFieldHasConfig` throw `Undefined array key`.

It now resolves `import:` rows into their fields and writes the override
into the import's `config` array, keyed by the field's handle within the
fieldset, which is the same shape `ensureField` already produces.

`removeField` no longer errors on an imported field either. It can't be
removed on its own, since the only entry in the contents is the whole
fieldset, so it's left in place.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

Importing Author Fieldset breaks Permissions

1 participant