Problem/Motivation

Upgrade Status module reported the following message:

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.

Proposed resolution

There are basically two files to be edited with simple changes

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

smhar created an issue. See original summary.

Rajan Kumar@2026 made their first commit to this issue’s fork.

rajan kumar@2026’s picture

Status: Active » Needs review
StatusFileSize
new19.22 KB

Hii @smhar

I reviewed the code in this branch (git checkout -b '3465727-drupal-11-compatibility' --track administerusersbyrole-3465727/'3465727-drupal-11-compatibility') and checked the Drupal Upgrade Status module's persistent issue, which was attached with a screenshot. I have fixed the issue and created a Merge Request (MR).

Thank you.

rajan kumar@2026’s picture

StatusFileSize
new51.38 KB
riddhi.addweb’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new34.24 KB
new53.98 KB
new91.35 KB
new36.46 KB

The mentioned page issue is resolved, & I have also checked and it is working as expected. I am attaching the Screenshots & doing RTBC for the same.

pearls’s picture

#2 - MR !8 didn't work.
Here are the logs.

Error: Call to undefined function Drupal\administerusersbyrole\Services\user_roles() in Drupal\administerusersbyrole\Services\AccessManager->managedRoles() (line 143 of /var/www/html/d11/web/modules/contrib/administerusersbyrole/src/Services/AccessManager.php).
#0 /var/www/html/d11/web/modules/contrib/administerusersbyrole/src/Services/AccessManager.php(82): Drupal\administerusersbyrole\Services\AccessManager->managedRoles()
#1 /var/www/html/d11/web/modules/contrib/administerusersbyrole/src/AdministerusersbyrolePermissions.php(45): Drupal\administerusersbyrole\Services\AccessManager->permissions()
#2 [internal function]: Drupal\administerusersbyrole\AdministerusersbyrolePermissions->permissions()
#3 /var/www/html/d11/web/core/modules/user/src/PermissionHandler.php(157): call_user_func()
#4 /var/www/html/d11/web/core/modules/user/src/PermissionHandler.php(116): Drupal\user\PermissionHandler->buildPermissionsYaml()
#5 /var/www/html/d11/web/core/modules/user/src/Form/EntityPermissionsForm.php(104): Drupal\user\PermissionHandler->getPermissions()
#6 /var/www/html/d11/web/core/modules/user/src/Form/EntityPermissionsForm.php(184): Drupal\user\Form\EntityPermissionsForm->permissionsByProvider()
#7 [internal function]: Drupal\user\Form\EntityPermissionsForm->access()
#8 /var/www/html/d11/web/core/lib/Drupal/Core/Access/CustomAccessCheck.php(66): call_user_func_array()
#9 [internal function]: Drupal\Core\Access\CustomAccessCheck->access()
#10 /var/www/html/d11/web/core/lib/Drupal/Core/Access/AccessManager.php(160): call_user_func_array()
#11 /var/www/html/d11/web/core/lib/Drupal/Core/Access/AccessManager.php(136): Drupal\Core\Access\AccessManager->performCheck()
#12 /var/www/html/d11/web/core/lib/Drupal/Core/Access/AccessManager.php(93): Drupal\Core\Access\AccessManager->check()
#13 /var/www/html/d11/web/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php(187): Drupal\Core\Access\AccessManager->checkNamedRoute()
#14 /var/www/html/d11/web/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php(76): Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->menuLinkCheckAccess()
#15 /var/www/html/d11/web/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php(80): Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->checkAccess()
#16 /var/www/html/d11/web/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php(80): Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->checkAccess()
#17 /var/www/html/d11/web/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php(80): Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->checkAccess()
#18 [internal function]: Drupal\Core\Menu\DefaultMenuLinkTreeManipulators->checkAccess()
#19 /var/www/html/d11/web/core/lib/Drupal/Core/Menu/MenuLinkTree.php(114): call_user_func()
#20 /var/www/html/d11/web/modules/contrib/admin_toolbar/src/Render/Element/AdminToolbar.php(47): Drupal\Core\Menu\MenuLinkTree->transform()
#21 [internal function]: Drupal\admin_toolbar\Render\Element\AdminToolbar::preRenderTray()
#22 /var/www/html/d11/web/core/lib/Drupal/Core/Security/DoTrustedCallbackTrait.php(107): call_user_func_array()
#23 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(825): Drupal\Core\Render\Renderer->doTrustedCallback()
#24 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(387): Drupal\Core\Render\Renderer->doCallback()
#25 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(459): Drupal\Core\Render\Renderer->doRender()
#26 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(459): Drupal\Core\Render\Renderer->doRender()
#27 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(203): Drupal\Core\Render\Renderer->doRender()
#28 /var/www/html/d11/web/core/modules/toolbar/toolbar.module(94): Drupal\Core\Render\Renderer->render()
#29 [internal function]: template_preprocess_toolbar()
#30 /var/www/html/d11/web/core/lib/Drupal/Core/Theme/ThemeManager.php(261): call_user_func_array()
#31 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Theme\ThemeManager->render()
#32 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(459): Drupal\Core\Render\Renderer->doRender()
#33 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(203): Drupal\Core\Render\Renderer->doRender()
#34 /var/www/html/d11/web/core/lib/Drupal/Core/Template/TwigExtension.php(475): Drupal\Core\Render\Renderer->render()
#35 /var/www/html/d11/web/sites/default/files/php/twig/66acc8eb83dbb_html.html.twig_0qvMTbD6IgDcRIdmzy5VtRdb8/0V_h5NwB0gCZZQBNof1hVOFwGf4fBHeiaLH0NIziJ4Q.php(84): Drupal\Core\Template\TwigExtension->escapeFilter()
#36 /var/www/html/d11/vendor/twig/twig/src/Template.php(360): __TwigTemplate_04208223c542bfa6f6fcda62af3f3142->doDisplay()
#37 /var/www/html/d11/vendor/twig/twig/src/Template.php(335): Twig\Template->yield()
#38 /var/www/html/d11/vendor/twig/twig/src/TemplateWrapper.php(38): Twig\Template->render()
#39 /var/www/html/d11/web/core/themes/engines/twig/twig.engine(33): Twig\TemplateWrapper->render()
#40 /var/www/html/d11/web/core/lib/Drupal/Core/Theme/ThemeManager.php(348): twig_render_template()
#41 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(446): Drupal\Core\Theme\ThemeManager->render()
#42 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(203): Drupal\Core\Render\Renderer->doRender()
#43 /var/www/html/d11/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(158): Drupal\Core\Render\Renderer->render()
#44 /var/www/html/d11/web/core/lib/Drupal/Core/Render/Renderer.php(593): Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
#45 /var/www/html/d11/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(153): Drupal\Core\Render\Renderer->executeInRenderContext()
#46 /var/www/html/d11/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
#47 /var/www/html/d11/vendor/symfony/event-dispatcher/EventDispatcher.php(246): Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
#48 /var/www/html/d11/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}()
#49 /var/www/html/d11/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
#50 /var/www/html/d11/vendor/symfony/http-kernel/HttpKernel.php(188): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
#51 /var/www/html/d11/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#52 /var/www/html/d11/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#53 /var/www/html/d11/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#54 /var/www/html/d11/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#55 /var/www/html/d11/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#56 /var/www/html/d11/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#57 /var/www/html/d11/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#58 /var/www/html/d11/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#59 /var/www/html/d11/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#60 /var/www/html/d11/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#61 /var/www/html/d11/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#62 /var/www/html/d11/web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#63 /var/www/html/d11/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#64 {main}
adamps’s picture

Status: Reviewed & tested by the community » Needs work

Great thanks I made a couple of comments in the MR

AdamPS credited heddn.

adamps’s picture

pearls’s picture

I tested it. Patch is OK. Applied and module installed without any problems.
But I couldn't create a new user.
There's HTTP ERROR 500 , my d11 test site is currently unable to handle this request.
When I uninstalled the module ı can create a new user.
It was a quick test, no error logs. It might be due to my system environment.

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

rhezios’s picture

I've updated MR8, the commits contains changes for:

  • Drop Drupal 8/9 support
  • Unset anonymous and authenticated (and limit the lines changed)
  • Add return type to OverrideUserMailRequiredValidator::validate() to match the parent (error mentioned in #11)
timohuisman’s picture

Status: Needs work » Reviewed & tested by the community

I've tested the changes from MR11 against drupal/core 11.0.7 and it works as expected.

The steps I took;

  1. Fresh Drupal installation with drupal/recommended-project:^11
  2. Used mglaman/composer-drupal-lenient and cweagans/composer-patches to install the patch
  3. Enabled the administerusersbyrole module
  4. Verified that I can still add new users (resolves #11)
  5. Verified that I can only assign roles which I'm allowed to
heddn’s picture

Category: Bug report » Task

+1 on RTBC. I added a gitlab-ci.yml file in that last commit that demonstrates that automated tests also pass green now on D11 too. LGTM.

adamps’s picture

  • adamps committed 3779156b on 8.x-3.x authored by smhar
    Issue #3465727 by smhar, adamps, rajan kumar@2026, heddn, rhezios:...
adamps’s picture

Status: Reviewed & tested by the community » Fixed

Great thanks

Status: Fixed » Closed (fixed)

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