Problem/Motivation

Drupal user_role_names() function is deprecated in Drupal 10.2.0 and will be removed in Drupal 11.

See the change log for more details.
https://www.drupal.org/node/3349759

At line 38 in RenderedItemProperty.php the deprecated function is called. See below,

https://git.drupalcode.org/project/search_api/-/blob/8.x-1.x/src/Plugin/...

Steps to reproduce

  1. Enable this module in a Drupal 10.2.0 installation.
  2. Config search api.
  3. Index search.
  4. Go to the search page.
  5. An php warning message occured in the log said user_role_names() function is deprecated.

Proposed resolution

Replaced with array_map() withing result of Role::loadMultiple().

Comments

Mingsong created an issue. See original summary.

mingsong’s picture

Issue summary: View changes
sidharth_soman’s picture

Status: Active » Needs review
StatusFileSize
new1.41 KB

Please review

Status: Needs review » Needs work

The last submitted patch, 3: 3412456.patch, failed testing. View results

sandipta’s picture

StatusFileSize
new1.02 KB

Adding patch as per requirement

avpaderno’s picture

Status: Needs work » Needs review
drunken monkey’s picture

StatusFileSize
new6.31 KB
new6.19 KB

Thanks for reporting this issue and already providing a patch!
However, as the same change record also deprecated user_roles(), I think we should fix those calls at the same time.
Patch attached, please review!

@sandipta: Thanks for fixing the problem with @sidharth_soman’s original patch!
However, when posting a patch that builds on someone else’s work, please remember to include an interdiff in the future. Thanks!

drunken monkey’s picture

Status: Needs review » Fixed

Merged. Thanks again!

Status: Fixed » Closed (fixed)

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