Problem/Motivation
Saving a node that is an automatic child prints two PHP warnings and the save does not complete, so Autopilot never rewrites the menu title:
- Undefined array key "#parents" in FormState::getError()
- foreach() argument must be of type array|object, null given (same function)
The owned-child notice is injected in #after_build after the form is processed, so it has no #parents. FormErrorHandler then calls getError() on it whenever any validation error exists. Hiding menu_ui also leaves enabled=0 and drops weight/parent, so a pending revision hits MenuSettingsConstraint. That error sits on the inaccessible menu widget, so the editor only sees the PHP warnings. Because the form does not submit, hook_entity_update never runs and escaped titles from the 1.2.2 token fix are not rewritten.
Steps to reproduce
- Enable automatic children on a parent.
- Edit a published automatic child (content moderation on).
- Save (including as a draft / pending revision).
- The warnings appear and the node is not saved. The menu title is unchanged.
Proposed resolution
Stamp #parents and #array_parents on the notice. Restore the live link title, weight, and parent onto form state so a draft save does not look like a menu-settings change. Keep menu_ui from writing the managed child.
Remaining tasks
- Kernel tests
- Patch
- 1.2.3 release
User interface changes
None. The same notice still appears in Advanced.
API changes
None.
Data model changes
None.
Comments
Comment #2
jmcerdaFixed in 1.2.3. Saving an automatic child no longer warns on #parents or fail the hidden menu constraint, so Autopilot can rewrite titles on the next successful save.
https://www.drupal.org/project/menu_autopilot/releases/1.2.3