Drupal 11 compatibility

Created on 3 August 2024, 7 months ago
Updated 6 August 2024, 7 months ago

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

๐Ÿ› Bug report
Status

Active

Version

3.4

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ญBahrain smhar

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @smhar
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Rajan Kumar@2026

    Rajan Kumar@2026 โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Rajan Kumar@2026

    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.

  • Status changed to RTBC 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia riddhi.addweb

    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.

  • #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}
    
  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Great thanks I made a couple of comments in the MR

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps
  • 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.

  • First commit to issue fork.
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Rhezios

    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)
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands timohuisman Leiden, Netherlands

    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
  • Pipeline finished with Success
    3 months ago
    Total: 198s
    #342517
  • heddn Nicaragua

    +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.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps
  • Pipeline finished with Skipped
    3 months ago
    #346886
  • Pipeline finished with Skipped
    3 months ago
    #346887
  • Pipeline finished with Skipped
    3 months ago
    #346893
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom adamps

    Great thanks

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

Production build 0.71.5 2024