Error: Call to undefined function Drupal\stickynav\Form\user_roles()

Created on 29 April 2025, 2 months ago

Problem/Motivation

The module on its configuration page throw error 404, and when check at report it shows message:
[error php] Error: Call to undefined function Drupal\stickynav\Form\user_roles() in Drupal\stickynav\Form\StickynavSettingsForm->buildForm() (line 73 of /var/www/html/modules/contrib/stickynav/src/Form/StickynavSettingsForm.php)

Steps to reproduce

First, the module is unable to be installed in Drupal 11. I manually download and change the .info file, add the core requirement to 11. Then able to install via drush. On the module page, on this module, there is configuration icon. Click on this, you will get error page.

Proposed resolution

With the error message, I change the file /modules/contrib/stickynav/src/Form/StickynavSettingsForm.php
line 73 :
original: $roles = user_roles();
change to : $roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple();
save this and clear cache.
Try get back to the module configuration page, it WORKS well.
And it works on the web page as well.

Remaining tasks

Need someone to update the code, and update also for core availability Drupal 11.

User interface changes

none

API changes

none

Data model changes

none

🐛 Bug report
Status

Active

Version

1.4

Component

Code

Created by

🇲🇾Malaysia mimpro

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

Comments & Activities

Production build 0.71.5 2024