Problem/Motivation
View profiles permissions ist not yet ready for Drupal 11.
Steps to reproduce
Drupal Rector summarizes 5 obstacles on the way to Drupal 11 readiness
Proposed resolution
Check via Drupal Rector and find:
modules/contrib/view_profiles_perms/src/ViewProfilesPermsPermissions.php
Row 26:
Call to deprecated function user_roles(). 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.
modules/contrib/view_profiles_perms/view_profile_perms.install
Row 13:
Call to deprecated function user_roles(). 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.
modules/contrib/view_profiles_perms/tests/modules/view_profiles_perms_test/view_profiles_perms_test.info.yml
Row 5:
Value of core_version_requirement: ^8 || ^9 is not compatible with the next major version of Drupal core. See https://drupal.org/node/3070687.
modules/contrib/view_profiles_perms/composer.json
Row 1:
The drupal/core requirement is not compatible with the next major version of Drupal. Either remove it or update it to be compatible. See https://www.drupal.org/docs/develop/using-composer/add-a-composerjson-fi....
Remaining tasks
Would anyone be able to patch the module to enable it to be maintained throughout Drupal 11? This would be great
As I am no developer I am unable to solve the issues.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | view_profiles_perms-d11.patch | 1.95 KB | titacvetkovic |
| #4 | view_profiles_perms-3540750-drupal11-readiness.patch | 2.73 KB | chike |
Issue fork view_profiles_perms-3540750
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 #2
mediengenosse commentedIs this module still maintained? Or will it be abandoned?
I am in doubt, as there are no responses to this question.
Comment #3
chikeI am equally worried about the status of this module. It is a very useful module, and for it to still be stuck at Drupal 10, with all the DCMS buzz is worrying.
Comment #4
chikeThe attached patch makes the module ready for Drupal 11, produced with help of ChatGPT Codex.
Changes made include:
view_profile_perms.installby replacinguser_roles(TRUE)with entity storage loading via\Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple().ViewProfilesPermsPermissions.php.view_profiles_perms.info.ymlandcomposer.json.view_profiles_perms_test.info.yml.Comment #5
titacvetkovic commented@chike's patch at #4 no longer applies cleanly against 2.1.1 due to context mismatches, as the installed version of
ViewProfilesPermsPermissions.phpdiffers from what the patch expects.I have attached a new patch for 2.1.1 that addresses all issues flagged by Upgrade Status:
user_roles()inViewProfilesPermsPermissions.phpwithRole::loadMultiple()filtered via array_filter(), explicitly excludingANONYMOUS_ID,AUTHENTICATED_IDand admin rolescore_version_requirementinview_profiles_perms.info.ymlto^9 || ^10 || ^11core_version_requirementin the test module'sinfo.ymlto^8 || ^9 || ^10 || ^11Please note that the
view_profile_perms.installfile still referencesuser_roles()in the view_profile_perms_update_8600() hook. As this is a historical update hook that would only run on sites upgrading from a very old version, it is not addressed in this patch.Also, the c
omposer.jsondrupal/coreconstraint fix from the original patch is also not included here as Upgrade Status flags this as a false positive. The current constraint^9 || ^10 || ^11in the installed version is already correct.Comment #6
tim corkerton commentedIs there any update on when or if a stable D11 version will be released?
I applied the latest patch and get
web/modules/contrib/view_profiles_perms/view_profile_perms.install
Call to deprecated function user_roles(). 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.
Comment #9
manuel garcia commentedThanks everyone for the patches and the testing, and sorry for the long wait.
I opened MR !8, which makes 2.1.x compatible with 11.x and 12.x:
core_version_requirement: ^10.5 || ^11.2 || ^12, also in composer.json and the test module. It matches edit_profiles_perms, which needs core 10.5 or 11.2 for how it handles deleted roles.view_profile_perms.install. Its file and function names never matched the module's (view_profile_permsinstead ofview_profiles_perms), so its one update hook never ran on any site. It only mattered for sites upgrading from 8.x-1.0-alpha1. It is also where theuser_roles()error @tim corkerton reported comes from.The patches here also replace
user_roles()inViewProfilesPermsPermissions. 2.1.x-dev already did that in #3406820, after 2.1.1 was tagged, so that part is already in. The latest patch also left admin roles out of the generated permissions. I didn't include that, because sites that granted those permissions would lose them.Tests pass on 11.4 and 12.x-dev. Once this is in I'll tag 2.2.0.
AI-Generated: Partially. Claude Code drafted this comment; I reviewed the change and ran the tests on 11.x and 12.x.
Comment #10
ressaThanks @manuel garcia, since Drupal 10 is soon EOL (~6 weeks), perhaps this should be elevated to Major Priority?
https://www.drupal.org/about/core/policies/core-release-cycles/schedule#...
Comment #11
ressaI tried the MR in Drupal 11, and it works well. I can block access to different profiles, based on the role of the visitor and the role of the profile. If I do not allow anonymous user access to the Content editor role and an anonymous user tries to access such a user profile, the page is blocked and this inserted in the log:
If I allow anonymous user access to profiles with this role, the profile for users with the Content editor role can be accessed. Users with another role, such as Administrator, is still blocked.
Likewise, I can grant view access between roles, such as Content editor role profiles access to Administrator role profiles.
Comment #13
manuel garcia commentedDrupal 11 compatibility is merged into 2.1.x as
3636d3cand released as 2.1.2.Testing: the GitLab CI PHPUnit job passed on Drupal 11.4.9 (PHP 8.3, MySQL 8.0), and @ressa on Drupal 11 confirmed the role-based access. Thanks to everyone who tested and posted patches.
Still open: MR !9 (#3036516) for the linked-label fix, which builds on this change.
AI-Generated: Yes (Claude Code drafted the CI file and the release notes; I reviewed them and ran the CI pipeline.)
Comment #15
ressaThank you @manuel garcia!