Review main Merged

90205[TASK] Add iterable types to toolbar item cache actions array

Elias Häußler CR +2 V +2 Easy +44 −1 updated 08/15/25, 11:23

Commit message

This patch adds iterable types to arrays in `ClearCacheToolbarItem`,
affecting the list of cache actions as well as the list of option values
(= cache action identifiers). In addition, the dropdown template is
modified to reflect the optional behavior of the `severity` option
within a single cache action.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Oliver Klee +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Oliver Klee +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1923

  1. Elias Häußler uploaded patch set 1 07/31/25, 10:19

  2. core-ci voted on patch set 1 V +1 07/31/25, 10:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82581

  3. Oliver Klee commented on patch set 1 07/31/25, 12:25

    ModifyClearCacheActionsEvent.php:25

    I personally am perfectly fine with this. However, IIRC, some other people had reservations about custom PHPStan types that were imported from other classes (due to its possibly increased complexity or additional maintenance burden). I don't have an elegant, perfect solution for this, either. :-)

    ModifyClearCacheActionsEvent.php:36

    This looks like there's an `array` or `list` missing.

    ClearCacheToolbarItem.php:41

    Can/should any of these be of type `non-empty-string`?
  4. Elias Häußler uploaded patch set 2 V +1 07/31/25, 12:36

  5. Elias Häußler commented on patch set 1 07/31/25, 12:36

    ModifyClearCacheActionsEvent.php:25 Reply

    Let's see what others say :) I did something similar in https://review.typo3.org/c/Packages/TYPO3.CMS/+/89732, which was also accepted.

    ModifyClearCacheActionsEvent.php:36 Reply

    This method is about adding a single cache action, hence the `CacheAction` type (which in turn is described as array in https://review.typo3.org/c/Packages/TYPO3.CMS/+/90205/1/typo3/sysext/backend/Classes/Backend/Event/ModifyClearCacheActionsEvent.php#25).

    ClearCacheToolbarItem.php:41 Reply

    Good catch, thanks! Reading the appropriate template (https://github.com/TYPO3/typo3/blob/v13.4.15/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ClearCacheToolbarItemDropDown.html), it looks like everything – except `description` – should be non-empty.
  6. Elias Häußler uploaded patch set 3 07/31/25, 12:39

  7. Elias Häußler commented on patch set 2 07/31/25, 12:40

    ClearCacheToolbarItem.php:41 Reply

    I decided to make `description` optional and, if set, to enforce a non-empty string. I think that's the most common scenario here.
  8. core-ci voted on patch set 2 V +1 07/31/25, 12:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82586

  9. core-ci voted on patch set 3 V +1 07/31/25, 12:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82587

  10. Oliver Klee commented on patch set 3 07/31/25, 13:05

    ModifyClearCacheActionsEvent.php:36 Reply

    Ah, my bad, you're right, I misread the method.

    ClearCacheToolbarItem.php:41 Reply

    Done
  11. Oliver Klee commented on patch set 3 07/31/25, 13:05

    ModifyClearCacheActionsEvent.php:25 Reply

    Done
  12. Oliver Klee voted on patch set 3 CR +1 V +1 07/31/25, 13:06

  13. Benjamin Franzke commented on patch set 3 08/01/25, 10:54

    ClearCacheToolbarItem.php:38

    While our code assumes that `severity` is given (but also works without) – https://github.com/TYPO3/typo3/blob/v13.4.15/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ClearCacheToolbarItemDropDown.html#L8 – github code search (https://github.com/search?q=ModifyClearCacheActionsEvent&type=code) reveals quite some extensions that do not provide this value: https://github.com/MaxServ/t3ext-fal_s3/blob/master/Classes/Resource/Event/FlushCacheActionEvent.php#L55-L61 https://github.com/cobwebch/flush_language_cache/blob/46c1bb400ec14872c0b4e97d2fbab64cab937761/Classes/EventListener/ClearCacheListener.php#L45-L53 https://github.com/nitsan-technologies/ns_cloudflare/blob/6655847a1006fdf46a9440853e9d29707e135c13/Classes/Backend/Event/CloudflareClearCacheActionsEventListener.php#L39-L45 Looking into the documentation it became clear why: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Events/Events/Backend/ModifyClearCacheActionsEvent.html It's currently not documented (not a blaming, that's simply because the option was added for internal styling with https://review.typo3.org/c/Packages/TYPO3.CMS/+/75658/13/typo3/sysext/backend/Resources/Private/Templates/ToolbarItems/ClearCacheToolbarItemDropDown.html#8 later on). Therefore I think we should make this an optional value like `description` and ideally list valid strings (notice,info,succcess,warning,error) while we're at it. (and cc @garvin@hick.ing maybe we can pick this up in the documentation)
  14. Elias Häußler commented on patch set 3 08/01/25, 11:29

    ClearCacheToolbarItem.php:38 Reply

    Thank you for this detailed answer and the additional insights! When making `severity` optional, should we adapt the template as well to avoid classes like `text-` (in case no severity is given)? Or does that go beyond the scope of this patch?
  15. Benjamin Franzke commented on patch set 3 08/01/25, 11:45

    ClearCacheToolbarItem.php:38 Reply

    yea, good idea, we can do that as a drive-by within this patch.
  16. Garvin Hicking commented on patch set 3 08/01/25, 12:06

    ClearCacheToolbarItem.php:38 Reply

    I'll take care of adopting docs, thanks for the ping.
  17. Elias Häußler uploaded patch set 4 CR +1 V +1 08/01/25, 12:29

  18. Elias Häußler commented on patch set 4 08/01/25, 12:29

    ClearCacheToolbarItem.php:38 Reply

    Done
  19. core-ci voted on patch set 4 V +1 08/01/25, 12:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82634

  20. Oliver Klee voted on patch set 4 CR +1 V +1 08/01/25, 13:27

  21. Benjamin Franzke voted on patch set 4 CR +2 V +2 08/01/25, 13:56

  22. Benjamin Franzke merged patch set 5 08/04/25, 06:21

  23. Moritz Ngo commented on patch set 5 08/15/25, 11:23

    ClearCacheToolbarItem.php:41 Unresolved

    It seems, that `'danger'` is missing in the list of possible severity entries ```suggestion * severity?: 'notice'|'info'|'succcess'|'warning'|'error'|'danger', ``` I mean `'danger'` will be used in line 91. or is this intentional, that `'danger'` was omitted?