Problem/Motivation
upgrade status reports:
File name Line Error
web/modules/contrib/show_email/src/Plugin/Field/FieldFormatter/ShowEmailAddress.php 72 Call to deprecated function user_role_names(). Deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use Drupal\user\Entity\Role::loadMultiple() and, if necessary, an inline implementation instead.
File name Line Error
web/modules/contrib/show_email/show_email.info.yml 5 Value of core_version_requirement: ^8 || ^9 || ^10 is not compatible with the next major version of Drupal core. See https://drupal.org/node/3070687.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | show_email-d11-compatibility.patch | 1.39 KB | richarddavies |
| #5 | show_mail.png | 26.24 KB | sarigaraghunath |
Issue fork show_email-3485932
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
Comment #4
sarwan_verma commentedHi,
I have fixed all the Drupal 11 compatibility issues and created MR!2.
Kindly review it.
Thanks!
Comment #5
sarigaraghunath commentedMR2 is working fine in both d10 and d11
Comment #6
maxilein commentedThe patch does not apply on the latest dev odr stable versions (as of 20 Jan 2024 at 20:16 CET)
Comment #7
maxilein commentedSorry it applied to the dev version correctly.
Comment #8
richarddavies commentedHere's a patch that is identical to MR2, but it will work on the 1.2 release (so you don't have to load the dev version--which ironically is currently the same as v1.2).
Comment #9
jaykainthola commentedPatch #8 is working fine with Drupal 11
Comment #10
sautiwari commentedDrupal 11 compatibility note:
The current version of show_email uses user_role_names(), which was deprecated in Drupal 10.2 and removed in Drupal 11.
For projects upgrading to Drupal 11, we replaced the module with a lightweight custom Field Formatter that provides similar functionality without deprecated APIs.
Key changes:
- Removed user_role_names()
- Used Role::loadMultiple() instead
- Avoided procedural user_load_* functions
- Relied on $items->getEntity() for performance
- Added proper cache context (user.roles)
Below is a Drupal 11 compatible formatter implementation:
During Drupal 11 upgrade, we removed deprecated procedural functions (user_role_names(), user_load_by_mail()), eliminated unnecessary .module and schema files, simplified role filtering logic, and modernized the formatter to use entity-based APIs and proper cache contexts.
Comment #12
abdulaziz zaidFixed in 3.0.0. Supports Drupal 10 and 11.
To upgrade: composer require 'drupal/show_email:^3.0'
Thanks, everyone, for your contributions.
Comment #14
abdulaziz zaid