Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Let's start to convert all calls to user_access() with the new AccountInterface::hasPermission() method.
Part of #2048171: [meta] Replace user_access() calls with $account->hasPermission() wherever possible.
Change records for this issue:
Comment | File | Size | Author |
---|---|---|---|
#6 | 2062023-statistics-replace-user_access-calls-6.patch | 1.52 KB | rhm5000 |
#6 | interdiff-2062023-3-6.txt | 894 bytes | rhm5000 |
#3 | 2062023-statistics-replace-user_access-calls-3.patch | 1.51 KB | rhm5000 |
#3 | interdiff-2062023-1-3.txt | 1.64 KB | rhm5000 |
#1 | drupal-statistics_replace_user_access-2062023.patch | 1.59 KB | InternetDevels |
Comments
Comment #1
InternetDevels CreditAttribution: InternetDevels commentedHere is the patch.
Comment #2
andypostSuppose blocks should use current_user service via injection
Drupal::currentUser()->hasPermission('view post access counter')
Comment #3
rhm5000 CreditAttribution: rhm5000 commentedComment #5
andypostThis needs '\' before Drupal at least
Comment #6
rhm5000 CreditAttribution: rhm5000 commentedComment #7
andypostthis could go, but I wish a maintainer should decide about the usage of
\Drupal
here.Probably better to file new issue to pass $account to block access() method
Comment #8
catchYeah let's open an issue for that if there's not one already.
Comment #9
andypostThere's one #1951386: Extend BlockPluginInterface::access to allow passing in an account
Comment #10
catchCommitted/pushed to 8.x, thanks!