Problem/Motivation

In Drupal 11.4, the node.search_index and node.search_result view modes were moved from the node module into the optional search_node submodule as part of #3590298.

The view modes are currently provided only in:

core/modules/search/modules/search_node/config/optional/

Existing sites are covered by search_update_11402(), which deletes the existing view modes and installs search_node.

However, fresh installations behave differently.

A contributed or custom module may ship configuration in its own config/install directory that depends on one of these view modes, for example:

core.entity_view_display.node.article.search_result

with:

dependencies:
  config:
    - core.entity_view_mode.node.search_result

Even when that module correctly declares a dependency on drupal:search_node, installation fails with an UnmetDependenciesException.

The root cause appears to be the install sequence in ModuleInstaller::install():

  1. ConfigInstaller::checkConfigurationToInstall() validates configuration dependencies before any configuration is imported.
  2. A configuration dependency is considered satisfiable only when:
    • the configuration already exists,
    • it is contained in the same module's config/install, or
    • it is contained in a previously processed module's config/install.
  3. Optional configuration is processed later and therefore does not satisfy dependency validation.

As a result, the view modes provided by search_node cannot satisfy another module's config/install dependency on a fresh site, regardless of install order.

This impacts any module that provides search-related displays or Search API configuration in config/install. Prior to Drupal 11.4, those view modes were supplied by node, so these configurations installed successfully.

Steps to reproduce

  1. Create a module example_article that depends on:
    dependencies:
      - drupal:node
      - drupal:search_node
    
  2. Add:
    config/install/core.entity_view_display.node.article.search_result.yml
    
  3. Include the following dependency:
    dependencies:
      config:
        - core.entity_view_mode.node.search_result
    
  4. Install the module on a fresh Drupal 11.4.x site (or install it during a functional/kernel test).
  5. Observe that installation fails with an UnmetDependenciesException because core.entity_view_mode.node.search_result is not yet available.

Note: At the time of writing, this has been reproduced in a project environment but has not yet been verified in a minimal standalone reproduction. I plan to confirm on simplytest.me before posting.

Proposed resolution

Move the following configuration files from:

search_node/config/optional/

to:

search_node/config/install/

Files:

core.entity_view_mode.node.search_index.yml
core.entity_view_mode.node.search_result.yml

Since search_node already depends on node, these view modes can be installed unconditionally.

With the files in config/install, any module that depends on search_node would be processed after search_node, allowing ConfigInstaller::checkConfigurationToInstall() to recognize the view modes as valid dependencies.

search_update_11402() should continue to work because it removes the existing view modes before installing search_node.

Remaining tasks

  • Confirm the minimal reproduction.
  • Add a kernel test covering a module whose config/install depends on core.entity_view_mode.node.search_result.
  • Decide whether the preferred solution is:
    • moving the view-mode configuration to config/install, or
    • documenting that dependent configuration must also be optional.
  • Update the change record for issue #3590298 if necessary.

Comments

maheshv created an issue. See original summary.

maheshv’s picture

Issue summary: View changes