Issue Bug Accepted Stale

#106200IconFactory returns modified icons

Daniel Siepmann 02/18/25, 13:28 updated 08/06/26, 15:46

Description

I as an API user would expect a proper Icon instance from the IconFactory.
But the IconFactory does not return the pure icon. It keeps an internal cache with references. The returned icons can be modified later through their setter. This might be useful if one would add an title or re use an icon but make it spinning.
The issue is that those are setters. Instead, a clone should be returned. Maybe `with` instead of `set` methods should exist.

This can also happen when using <core:icon title="Open actions menu" identifier="actions-menu" />. That way also integrators might run into those issues. As it is not clear that the `title` attribute will modify the system state of the used icon.

Steps to reproduce:

  1. Fetch an icon by its identifier in context a and render it
  2. Fetch an icon by the same identifier as in step 1, modify the returned icon, e.g. make it spinning or set a title and render it
  3. Fetch an icon by the same identifier as in step 1. It will be rendered with modifications from 2nd step.

The issue occurs in v12 and v13.

Reviews 1

History 6

  1. Daniel Siepmann commented <span data-processor="relativetime" data-value="2025-02-25T14:23:22+00:00" > 02/25/25, 14:23 </span>

    TYPO3 uses the ->setTitle() within the Page Module for the header of each grid column item: https://github.com/TYPO3/typo3/blob/4cd98f3fa5ca9b2f5bc48c1acb74faacaf583c7f/typo3/sysext/backend/Classes/View/BackendLayout/Grid/GridColumnItem.php#L192

    That way using the same icons in a preview will result in unexpected output.

  2. Georg Ringer commented and changed status New Accepted <span data-processor="relativetime" data-value="2025-04-25T09:51:47+00:00" > 04/25/25, 09:51 </span>

    for the one who is interested in working on it:

    \TYPO3\CMS\Core\Imaging\IconFactory::getIcon => uses a cache which includes the rendering set in $iconProvider->prepareIconMarkup($icon, $iconConfiguration['options']); so this shouldn’t be allowed to be cached