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

  1. Enable automatic children on a parent.
  2. Edit a published automatic child (content moderation on).
  3. Save (including as a draft / pending revision).
  4. 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

jmcerda created an issue. See original summary.

jmcerda’s picture

Version: 1.2.2 » 1.2.3
Status: Active » Fixed

Fixed 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

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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