Review main Ready for review Quiet

96348[FEATURE] Add identifiers for DocHeader buttons

Georg Ringer CR 0 V 0 Hard +522 −44 updated 11/03/26, 20:46

Commit message

Buttons of the document header button bar can now carry an identifier,
provided by the new IdentifiableButtonInterface and its trait.
Listeners of the ModifyButtonBarEvent use the new methods hasButton(),
getButton(), removeButton() and replaceButton() to find, replace or
remove a specific button, instead of relying on its array position or
on its CSS classes.

The record editing form sets identifiers on its buttons, and the
listeners of EXT:scheduler and EXT:redirects use them now.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/48/96348/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/48/96348/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 13

Issues 1

Files 16

Review log 57

  1. Georg Ringer uploaded patch set 1 10/03/26, 07:59

  2. Georg Ringer commented on patch set 1 10/03/26, 08:01

    This change is ready for review.
  3. core-ci voted on patch set 1 V +1 10/03/26, 08:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110033

  4. Oli Bartsch commented on patch set 1 10/05/26, 07:26

    Hey, thats a nice feature. I actually was annoyed of this array matching when I built the CompnentFactory. However, My main concern is that the array key serves as the button's identity. That changes the shape of the `getButtons()` payload, so listeners and overridden DocHeader partials that still read `[group][0]` now break silently, and the patch is currently not declared as breaking. What about putting the identifier on the button instead? That would mean an optional `IdentifiableButtonInterface` plus a trait with getIdentifier()/setIdentifier(), which is what #87694 originally asked for. The groups would stay list, the template change goes away, nothing breaks, and ComponentFactory::createSaveButton()/createCloseButton() could set save/close for every module that uses them. The cost is applying the trait to the five ButtonInterface implementations. If you keep the array-key approach, the commit needs [!!!] and a Breaking RST.

    ButtonBar.php:110

    The group type changes from list<ButtonInterface> to array<int|string, ButtonInterface>. That's a change to the public shape of the ModifyButtonBarEvent payload: a listener that does $buttons['left'][2][0] (save) or [4][0] (new) on the record edit form now silently does nothing. Core used that exact pattern in EXT:redirects, so extensions have probably copied it.

    ButtonBar.php:172

    Re-adding an existing identifier removes the button and appends it at the end of its group, so its position inside the group changes. ModifyButtonBarEvent::setButton() replaces in place instead. Should both "replace" paths behave the same?

    ButtonBar.php:235

    This duplicates the check in validateIdentifier().

    ModifyButtonBarEvent.php:56

    Identifiers are scoped per ButtonBar, but listeners run for every module. Once other modules register new or delete, a listener calling removeButton('delete') hits all of them. Please either namespace the identifiers (e.g. record_edit.new) or make the example check the route first, as the scheduler listener does.

    ModifyButtonBarEvent.php:123

    setButton() skips what addButton() guarantees: there's no isValid() check, no clone, and PositionInterface is ignored. Two ways of adding a button with different rules will surprise people.

    Feature-87694-IdentifiersForDocHeaderButtons.rst:56

    This replaces "new" in every module. Please add the route check (record_edit) so people don't copy the unsafe version.
  5. Georg Ringer uploaded patch set 2 V +1 11/03/26, 20:37

  6. Georg Ringer commented on patch set 2 11/03/26, 20:37

    Reply

    Done

    ButtonBar.php:110 Reply

    Done

    ButtonBar.php:172 Reply

    Done

    ButtonBar.php:235 Reply

    Done

    ModifyButtonBarEvent.php:56 Reply

    Done

    ModifyButtonBarEvent.php:123 Reply

    Done

    Feature-87694-IdentifiersForDocHeaderButtons.rst:56 Reply

    Done
  7. core-ci voted on patch set 2 V +1 11/03/26, 20:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113226