- Issue created by @mdolnik
- Status changed to Needs review
10 months ago 12:11am 15 January 2024 - Open on Drupal.org →Core: 9.5.x + Environment: PHP 7.4 & MySQL 8last update
10 months ago Waiting for branch to pass
When the icons module is configured with a very large amount of icons to choose from, the IconSelect widget/element takes an extremely long amount of time to load all icons server-side.
Add Menu Link
form (eg: /admin/structure/menu/manage/main/add
)Enable static caching for the IconSet config entity.
The reason it is taking so long is because unlike content entities, config entities are not statically cached by default. This results in the logic in Icon::preRenderIcon()
converting the string version of '#icon_set'
to IconSet
entities by loading the entity from the database for EVERY SINGLE ICON regardless of whether the icon set has previously been loaded from the DB.
Simply adding static_cache = TRUE
to the annotations of IconSet
will result in my 1.5 minutes above be reduced to 6 seconds, which still not great but exponentially improved.
This will not only help situations where the IconSelect element is used, but also improve performance for loading icons wherever they're displayed by not reloading the entity from the DB for every icon.
There shouldn't be any downsides to statically caching the configuration as they will never be altered within a single request.
Related issues:
Needs review
2.0
Code