Based on the change record https://www.drupal.org/node/2049309 user_access function calls needs to be changed to \Drupal::currentUser()->hasPermission()

Comments

gokulnk’s picture

StatusFileSize
new4.28 KB

Providing a patch with the changes.

jaak’s picture

Simplytest.me says after enabling admin_menu module:

Fatal error: Call to undefined function current_path() in /home/se1b3739babe1cf5/www/sites/default/modules/admin_menu/admin_menu.module on line 153

hongpong’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new4.59 KB

This applies cleanly against current HEAD and seems to be essential to moving forward. @jaak to prevent the current_path() fatal error the path core module must be enabled. This has been noted on #2563867: PHP Fatal errors: Cannot instantiate interface Drupal\Core\Cache\CacheBackendInterface and others and also attached here is a re roll that fixes this fatal. I think it is RTBC so we can unravel some other fatal errors on other fronts.

dave reid’s picture

Status: Reviewed & tested by the community » Needs work

FYI in D8 code you should always be using "\Drupal" and not just "Drupal" to indicate you're using the root namespace class. Also, you shouldn't RTBC your own patch, others should be doing that and reviewing & testing your patches.

hongpong’s picture

Ugh I am really sorry about that, I got overcaffeinated and a bit frenzied from the fatals. Won't happen again :[

andrew.mikhailov’s picture

Status: Needs work » Needs review
StatusFileSize
new4.29 KB

Hello guys!
I corrected this patch, but I see you have many work with this module.
You didn't port variables, menu, config of module and etc.
Can I help you? I have enough time for contribute.
Best regards.

Status: Needs review » Needs work

The last submitted patch, 6: change_user_access_calls-2457801-7-6.patch, failed testing.

andrew.mikhailov’s picture

Status: Needs work » Needs review

Sorry don't understand what's problem...
I applied patch via git for last module version and for me it was correct.
Try again...

Status: Needs review » Needs work

The last submitted patch, 6: change_user_access_calls-2457801-7-6.patch, failed testing.

andrew.mikhailov’s picture

I've checked Drupal CI, I think problem on their side http://joxi.ru/Vrw3eBYCnMYWrX
Best regards.

andrew.mikhailov’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: change_user_access_calls-2457801-7-6.patch, failed testing.

loopduplicate’s picture

Status: Needs work » Needs review

Changing status back to needs review to see if the testbot is working now. This based on #10

Status: Needs review » Needs work

The last submitted patch, 6: change_user_access_calls-2457801-7-6.patch, failed testing.

The last submitted patch, 6: change_user_access_calls-2457801-7-6.patch, failed testing.

yash_khandelwal’s picture

By replacing user_access function with Drupal::currentUser()->hasPermission method, issue resolved.

webel’s picture

I've tried updating using composer (on an active site) and also downloading and inspecting the tgz of the latest version from:

https://www.drupal.org/project/admin_menu/releases/8.x-3.x-dev

It (still) crashes vs Drupal 8.6.2, because it is still apparently riddled with user_access invocations:

$ grep -R user_access .
./admin_menu.api.php:      '#access' => user_access('administer site configuration'),
./admin_menu.inc:    '#access' => user_access('administer site configuration'),
./admin_menu.inc:    '#access' => $GLOBALS['user']->uid == 1 || !empty($GLOBALS['update_free_access']) || user_access('administer software updates'),
./admin_menu.inc:    '#access' => user_access('display drupal links'),
./admin_menu.inc:    '#access' => user_access('flush caches'),
./admin_menu.inc:    '#href' => (user_access('administer users') ? 'admin/people/people' : 'user'),
./admin_menu.map.inc:  if (user_access('administer content types')) {
./admin_menu.map.inc:      if (user_access('administer ' . $entity_type . ' fields')) {
./admin_menu.module:  if (!user_access('access administration menu') || admin_menu_suppress(FALSE)) {

At https://www.drupal.org/project/admin_menu it says:

Development version: 8.x-3.x-dev updated 17 Sep 2018 at 15:48 UTC

I don't understand how anybody can possible be using this module vs Drupal8, I've not been able to use it for 2 years now, and it is also difficult to then uninstall with drush.

webel’s picture

Priority: Normal » Major

Updating to major (could even be critical) because crashes Drupal8 sites and very hard to then uninstall.

hongpong’s picture

@webel admin_menu has been discontinued for Drupal 8 and replaced with a couple other helper modules. The maintainers are pretty firm about this.

thalles’s picture

Category: Bug report » Support request
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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