Problem/Motivation

AuthCodeFunctionalTest fails on Drupal 11.4+ because user_pass_reset_url() is deprecated but there is no working compatibility shim in place.

Proposed resolution

Use DeprecationHelper::backwardsCompatibleCall() to call the new OneTimeAuthentication service on 11.4+ and fall back to user_pass_reset_url() on older versions:

use Drupal\Component\Utility\DeprecationHelper;
use Drupal\user\OneTimeAuthentication;

$reset_url = DeprecationHelper::backwardsCompatibleCall(
  \Drupal::VERSION,
  '11.4.0',
  fn () => \Drupal::service(OneTimeAuthentication::class)->generateOneTimeLoginUrl($new_user)->toString(),
  fn () => user_pass_reset_url($new_user),
);

Remaining tasks

  • Apply the fix in tests/src/Functional/AuthCodeFunctionalTest.php
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

attilatilman created an issue. See original summary.

attilatilman’s picture

Assigned: attilatilman » Unassigned
Status: Active » Needs review

pfrilling made their first commit to this issue’s fork.

pfrilling’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3620858: Fix deprecation message strings in Oauth2ScopePluginManagerLegacyTest

The code looks good to me and fixes the deprecation message flagged in the tests.

One note, the CI pipeline will _not_ go green because #3620858: Fix deprecation message strings in Oauth2ScopePluginManagerLegacyTest also needs to merge.

bojan_dev’s picture

Status: Reviewed & tested by the community » Fixed

Thank you!

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.