Problem/Motivation

On Drupal 10.x, facets_preprocess_facets_item_list() (in
facets.module) fatals with HTTP 500 on any page that renders a facet item
list (e.g. a Search API search page with a facet block). The hook calls a core service
that does not exist on Drupal 10.x:

\Drupal::service(ThemePreprocess::class)->preprocessItemList($variables);

Drupal\Core\Theme\ThemePreprocess was introduced by core's preprocess→OOP
refactor in Drupal 11.2.0 (see change record
#3504125 and
#3495943). It is not
present on any Drupal 10.x release. Because Facets still declares
core_version_requirement: ^10.1 || ^11, Drupal 10.x sites throw:

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
  You have requested a non-existent service "Drupal\Core\Theme\ThemePreprocess".
  in Drupal\Component\DependencyInjection\Container->get()
  (line 159 of core/lib/Drupal/Component/DependencyInjection/Container.php).

  #1 facets.module(233): Drupal::service('Drupal\\Core\\The...')
  #2 facets_preprocess_facets_item_list(Array, 'facets_item_lis...', Array)
  ...

This is a regression on the 3.0.x branch. The
ThemePreprocess import and the service call were both added in commit
99775089dbe158b2e80dc6f77f90af31ad690130 (2026-05-11) as part of
#3589162
“Support special hierarchy processors as exposed filters” — an unrelated
feature. It appears to be an incidental change rather than an intentional drop of
Drupal 10 support.

The 3.0.3 release does not have this problem; it uses the
backwards-compatible core function:

template_preprocess_item_list($variables);

So the breakage currently exists only in 3.0.x-dev (unreleased) and would
ship in the next 3.0.x tagged release unless fixed first.

Note the same file already handles version-conditional core changes correctly:
facets_entity_presave() wraps the deprecated $entity->original
access in DeprecationHelper::backwardsCompatibleCall(). The
ThemePreprocess call simply missed equivalent treatment.

Steps to reproduce

  1. Install Drupal core 10.x (reproduced on 10.6.x).
  2. Install Facets 3.0.x-dev (current branch HEAD — not the 3.0.3 release).
  3. Configure a Search API search page and place a facet block that renders an item list.
  4. Visit the search page, e.g. /search?search_api_fulltext=test.
  5. Result: HTTP 500 with a ServiceNotFoundException for
    Drupal\Core\Theme\ThemePreprocess.

Proposed resolution

Option A (minimal — matches 3.0.3): revert line 233 to the
backwards-compatible core function, which works on both Drupal 10.x and 11.x:

template_preprocess_item_list($variables);

Option B (forward- and backward-compatible): use
DeprecationHelper::backwardsCompatibleCall() — matching the existing pattern in
this file — so the new service is used where available and the deprecation notice is avoided
on 11.2+, while 10.x keeps working. Use a regular closure with use (&$variables)
so the by-reference modifications still propagate:

DeprecationHelper::backwardsCompatibleCall(
    \Drupal::VERSION,
    '11.2.0',
    currentCallable: function () use (&$variables) {
      \Drupal::service(ThemePreprocess::class)->preprocessItemList($variables);
    },
    deprecatedCallable: function () use (&$variables) {
      template_preprocess_item_list($variables);
    },
  );

Option A is the smallest, safest fix and restores parity with the 3.0.3 release;
Option B is preferable if the maintainers want to avoid the
template_preprocess_item_list() deprecation on Drupal 11.2+.

Remaining tasks

  • Apply the fix in facets_preprocess_facets_item_list() (Option A or B).
  • Audit the rest of 3.0.x for any other 11.2-only API calls introduced
    since 3.0.3 (the #3589162
    commit, in particular).
  • Add/confirm test coverage for facet item-list rendering against a Drupal 10.x target.
  • Review and commit to 3.0.x so the fix lands before the next release.

User interface changes

None.

API changes

None.

Data model changes

None.

Sources:
- Facets commit history / #3589162 (https://www.drupal.org/project/facets/issues/3589162)
- Change record #3504125 — template_preprocess_HOOK as theme-hook callbacks (https://www.drupal.org/node/3504125)
- #3495943 — Handle module preprocess functions as OOP hooks (https://www.drupal.org/project/drupal/issues/3495943)
- facets 3.0.3 release (https://www.drupal.org/project/facets/releases/3.0.3)
- ThemePreprocess::preprocessItemList — Drupal API (https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Theme%21T...)
Written with the help of AI

Comments

philltran created an issue. See original summary.

philltran’s picture

Assigned: philltran » Unassigned
Status: Active » Closed (duplicate)
Related issues: +#3567669: The template_preprocess_item_list() function is deprecated in Drupal 11.3

I missed that an issue was already open - https://www.drupal.org/project/facets/issues/3567669

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.