Icons from iconify_icon_provider are able to return NULL, breaking API usage in

Created on 13 March 2025, 24 days ago

Problem/Motivation

The icon provider works with the Icon API, however, Icons are allowed to come back as NULL, which breaks some API implementations, as the API is not engineered for NULL results.

Steps to reproduce

1. On Drupal 11.1, Install iconify_icons_provider, ui_icons, and ui_icons_library modules
2. Enable "Material Symbols" category in the in the Iconify Icons Provider module.
3. Attempt to view available libraries at /admin/appearance/ui/icons

You will receive the following:

The website encountered an unexpected error. Try again later.

TypeError: Drupal\ui_icons\IconPreview::getPreview(): Argument #1 ($icon) must be of type Drupal\Core\Theme\Icon\IconDefinitionInterface, null given, called in /var/www/html/web/modules/contrib/ui_icons/modules/ui_icons_library/src/Controller/LibraryIndex.php on line 159 in Drupal\ui_icons\IconPreview::getPreview() (line 34 of modules/contrib/ui_icons/src/IconPreview.php).
Drupal\ui_icons_library\Controller\LibraryIndex->buildCard() (Line: 108)
Drupal\ui_icons_library\Controller\LibraryIndex->index()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

In testing, this is being caused by the collection id not matching the pack_id in cases there the collection id has a dash. For instance, the 'Material Line Icons" pack has a collection id of line-id, however the machinename pack_id is line_id, which causes a mismatch in Drupal/Core/Theme/Icon/IconCollector.php:86. This is derived from the passed icon_full_id via a simple explode in Drupal/Core/Theme/Icon/IconDefinition.php:88, and so does not match.

Proposed resolution

Align these to match.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States R_H-L

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024