Issue #3586657: Allow Field Widget Actions to target a specific automator 2.x

Description

Changes:

  • AiAutomatorEntityModifier::saveEntity() gains an optional $specificAutomatorId parameter. When set, processing is filtered to the matching automator config entity ID before any processor runs.
  • Unlike 1.x, 2.x's entityHasAutomators() already returns automators keyed by config entity ID and sorts them with a key-preserving uasort(), so the filter here operates directly on that keyed array instead of 1.x's array_filter() placed before a key-destroying usort().
  • Added testSaveEntityFiltersBySpecificAutomatorId() and testSaveEntityReturnsNullForUnmatchedAutomatorId() to TextToImageMediaFieldWidgetProcessingTest.

Out of scope for this MR — needs reviewer input:

1.x's fix also touched AutomatorFieldWidgetActionTrait::populateAutomatorValues() (passing $automator_id through to saveEntity(), plus a NULL guard) and AutomatorRefinableBaseAction::generateContent() (same fix, for the "refine" feature). Neither file exists on 2.x yet — both are introduced by the not-yet-merged !1966 (merged) (#3586655 (closed)), which will have the exact same "runs every automator on the field" bug in its generateContent() path once it merges, since it's built on the pre-fix saveEntity() signature.

Current caller of saveEntity() on 2.x (AutomatorBaseAction::populateAutomatorValues()) still calls it without the new parameter, so this MR alone does not yet close the user-facing bug for the default Field Widget Actions button path on 2.x — it only adds the capability the caller needs.

Needs a maintainer decision on sequencing:

  • (a) add the $automator_id/NULL-guard fix as a follow-up commit directly on !1966 (merged)'s branch, so it merges together with (or as part of) that MR, or
  • (b) merge this MR first, then add that fix here (or in a fast-follow) once !1966 (merged) lands on 2.x and the trait/AutomatorRefinableBaseAction exist to update.

Either way, AutomatorBaseAction::populateAutomatorValues() needs the same two changes once its target file stabilizes post-!1966.

Testing instructions

Checklist

  • I have linked the related issue in the MR title or description
  • I have performed a self-review of my own code
  • I have added or updated tests, or explained in the description why this change is not covered by tests
  • I have updated documentation for any new or changed functionality
  • I have written testing instructions and verified them locally
  • I have noted any required post-merge steps (config imports, cache rebuilds, manual changes)
  • This MR contains no breaking API or hook changes, or they are explicitly documented in the description

AI Compliance

Note

Check the one that best describes your usage, or leave all unchecked if AI was not significantly used.

  • AI Assisted Code
    Mainly written by a human; AI used for autocomplete or partial generation under full human supervision.
  • AI Generated Code
    Mainly generated by AI, reviewed and approved by a human before this MR was created.
  • Vibe Coded
    Generated by AI and only functionally reviewed before this MR was created.

Closes #3586657

Edited by Juan Correa

Merge request reports

Loading