Issue #3606353: Fix fatal error on sites without Search API by moving the filter into an optional submodule

Problem

After updating to 2.0.0-beta6, sites that do not have Search API installed get a 500 error.

Root cause

The EntityReferenceFilterViewResultSearchApi plugin uses SearchApiFilterTrait from the search_api module. A missing trait is an unrecoverable error in PHP, and core only guards against it (via the AttributeClassDiscovery skip) from Drupal 11.4 onwards. On earlier supported cores (10.3–11.3) the plugin file is autoloaded during plugin discovery and fatals when Search API is absent. This is not related to declare(strict_types=1).

Fix

  • Move the Search API filter plugin and its config schema into a new optional submodule, entityreference_filter_search_api, which hard-depends on search_api. The trait is now only ever loaded when Search API is installed, so
    the main module can no longer fatal on the missing trait.
  • In viewsDataAlter(), skip adding the Search API filter when the variant plugin is unavailable (checked via the views filter plugin manager), instead of assigning a plugin id that does not resolve.
  • Add a post_update hook that enables the submodule automatically on sites where Search API is already installed, so existing Search API filters keep working after the update.

Upgrade note

Search API support now requires the entityreference_filter_search_api submodule. On existing sites with Search API installed it is enabled automatically by the update hook; new setups should enable it manually.

Merge request reports

Loading