Problem/Motivation

The search_api_db_defaults_requirements() function in the search_api_db_defaults module uses the deprecated REQUIREMENT_ERROR constant:

'requirements' => [
  'severity' => REQUIREMENT_ERROR,
]

As of Drupal 11.2.0, this constant is deprecated and will be removed in Drupal 12.0.0:

REQUIREMENT_ERROR is deprecated in drupal:11.2.0 and removed in drupal:12.0.0. Use \Drupal\Core\Extension\Requirement\RequirementSeverity::Error instead.

When running the functional test \Drupal\Tests\search_api_db_defaults\Functional\IntegrationTest::testInstallAndDefaultSetupWorking,
the test fails because the severity level is not correctly interpreted in newer Drupal versions — no error message is printed as expected.
This is due to the conditional check using:
if ($requirement['severity'] === RequirementSeverity::Error)
…which will not match REQUIREMENT_ERROR (int 2 vs. \RequirementSeverity::Error enum), leading to a silent failure.

Steps to reproduce

Run the test:
--filter=testInstallAndDefaultSetupWorking

Proposed resolution

Update the severity key to use the enum class:

use Drupal\Core\Extension\Requirement\RequirementSeverity;

...

'requirements' => [
  'severity' => RequirementSeverity::Error,
]

This ensures forward compatibility and fixes the test behavior under Drupal 11+.

Remaining tasks

Issue fork search_api-3536089

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tuwebo created an issue. See original summary.

tuwebo’s picture

Status: Active » Needs review

All tests passed (PHPUnit, PHPCS, PHPStan), but the pipeline shows as failed due to a post-job exit code 1.
The patch simply replaces the deprecated REQUIREMENT_ERROR with RequirementSeverity::Error, ensuring compatibility with Drupal 11.2+ and 12.x. I think it should be safe to merge it. Moving to Needs review.

drunken monkey made their first commit to this issue’s fork.

drunken monkey’s picture

Thanks a lot for reporting this problem and already providing a working MR!

I rewrote the code to use DeprecationHelper, which I think is the “proper” way to do this. I also temporarily enabled testing against other Drupal versions to make sure this is compatible with all versions we want to support.
However, tests are still failing and I have no idea, why.

drunken monkey’s picture

Status: Needs review » Closed (duplicate)

Since this is part of fixing the pipelines, I’m integrating this fix into #3523808: Fix failing pipelines. Maybe an MR with all fixes will help resolve the failure in the MR?

tuwebo’s picture

Thanks a lot for reviewing it. Honestly I don't know either why test are failing. Summary shows that the test are passing:
https://git.drupalcode.org/project/search_api/-/pipelines/563625/test_re...

But job is failing, I am looking into SYMFONY_DEPRECATIONS_HELPER and these two issues (I am not familiar with it)
#3400218: [GitlabCI] run-tests.sh does not pass on SYMFONY_DEPRECATIONS_HELPER environment variable value to spawned processes
#3400979: Is SYMFONY_DEPRECATIONS_HELPER: weak correct for contrib deprecation testing needs?
Maybe deprecation warnings are making the job to fail?