D11 compatibility

Created on 3 March 2025, 4 months ago

Problem/Motivation

I'd like to upgrade my site but Entity Limit does not support D11.

Upgrade Status module scan reports 2 issues, both usages of user_roles().

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.
📌 Task
Status

Active

Version

3.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

  • Issue created by @karuonu
  • Merge request !4D11 compatibility fixes → (Open) created by orkut murat yılmaz
  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    Can someone test and review this?

  • Tested. Unable to add role limits.

    The website encountered an unexpected error. Try again later.
    
    Error: Call to a member function getStorage() on null in Drupal\entity_limit\Plugin\EntityLimit\RoleLimit->buildConfigurationForm() (line 77 of modules/contrib/entity_limit/src/Plugin/EntityLimit/RoleLimit.php).
    

    Details

    Drupal\entity_limit\Form\EntityLimitAddLimitForm->form() (Line: 107)
    Drupal\Core\Entity\EntityForm->buildForm()
    call_user_func_array() (Line: 528)
    Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 279)
    Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult()
    call_user_func_array() (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 593)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 183)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
    Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
    Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 57)
    Drupal\advban\AdvbanMiddleware->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 263)
    Drupal\shield\ShieldMiddleware->bypass() (Line: 219)
    Drupal\shield\ShieldMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 709)
    Drupal\Core\DrupalKernel->handle() (Line: 19
    
  • 🇺🇸United States jdvc

    Here is a new patch with updates and dependency injection updates. Resolved error for me.

  • 🇺🇸United States jdvc
  • 🇺🇸United States jdvc

    Patch with actual diff..

  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    @pearls, can you review the @jdvc's MR too?

  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    Sorry, I forgot saying that, I've applied the MR as a patch and scanned entity limit with upgrade status module:

    No problems found

  • #8 patch is ok. But now the other patches can not be applied with this patch(#8).

    3432063-Drupal calls should be avoided in classes, use dependency injection instead 📌 \Drupal calls should be avoided in classes, use dependency injection instead Active

    3347700-checkAccess() throws an exception Invalid specifier 'type' with non node entities 🐛 checkAccess() throws an exception "Invalid specifier 'type'" with non node entities Needs review

    Maybe, there must be a holistic solution.

  • 🇹🇷Turkey orkut murat yılmaz Istanbul

    @pearls, I do agree with you. Should I contact one of the maintainers?

  • 🇺🇸United States jdvc

    Yeah I tried messaging one of them, haven't heard anything, can't we just close the other two issues to merge this one in?

  • The problems mentioned above(#12) are important and the patches created for them work without any problems. But unfortunately they were not merged. Maybe a new version should be created for d11.
    I think entity_limit is an important module for Drupal environment, but unfortunately it did not get the value it deserved. If mainteinars has stopped supporting this module, maybe it would be good to replace it with those who do.

Production build 0.71.5 2024