Problem/Motivation

The LTI Tool Provider 3.0.0 Role Mapping submodule is not working on Drupal 11.

When accessing the Role Mapping configuration page, Drupal throws a fatal error because the module calls the removed user_roles() function.

The error occurs on:

/admin/config/lti-tool-provider/roles/v1p0

The error is:

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

The error points to:

modules/lti_tool_provider_roles/src/Form/V1p0LtiToolProviderRolesSettingsForm.php

The module is declared as compatible with Drupal 11, so the Role Mapping functionality should also work on Drupal 11.

Steps to reproduce

1. Install Drupal 11.
2. Install LTI Tool Provider 3.0.0.
3. Enable the LTI Tool Provider module.
4. Enable the lti_tool_provider_roles submodule.
5. Navigate to the LTI Tool Provider Role Mapping configuration.
6. Open /admin/config/lti-tool-provider/roles/v1p0.

The page fails with a fatal PHP error:

Call to undefined function Drupal\lti_tool_provider_roles\Form\user_roles()

The same legacy API usage also appears to be present in other files in the Role Mapping submodule.

Proposed resolution

Replace the removed user_roles() API with the Drupal 11-compatible User Role entity API:

\Drupal\user\Entity\Role::loadMultiple()

The existing Role Mapping behavior should be preserved, including the handling of the anonymous role where applicable.

Remaining tasks

Confirm the issue and review the required changes for Drupal 11 compatibility.

Provide a patch or merge request if the proposed approach is accepted.

Test the Role Mapping configuration for both LTI 1.0/1.1 and LTI 1.3 functionality.

User interface changes

None expected.

The fix should allow the existing Role Mapping configuration UI to load normally on Drupal 11.

API changes

Replace the removed Drupal user_roles() function with the User Role entity API.

No new public API is intended.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Comments

    narendra@drupalchamp created an issue. See original summary.

    gurkawal’s picture

    StatusFileSize
    new57.91 KB

    Hi @narendra@drupalchamp

    I reproduced the issue on Drupal 11 and confirmed that the deprecated user_roles() calls were causing fatal errors in the LTI Tool Provider Roles configuration pages.

    I have attached a patch that replaces the legacy user_roles(TRUE) usage with Role::loadMultiple() and excludes the anonymous role using RoleInterface::ANONYMOUS_ID.

    I tested the patch on Drupal 11.4. After applying it, both:

    /admin/config/lti-tool-provider/roles/v1p0

    and

    /admin/config/lti-tool-provider/roles/v1p3

    load successfully without PHP fatal errors, and the expected user roles are displayed correctly.

    Please review and test the patch.

    gurkawal’s picture

    gurkawal’s picture

    Status: Active » Needs review
    vinodhini.e’s picture

    Hi,

    Tested on Drupal 11.4.5 and was able to reproduce the issue.

    After enabling the lti_tool_provider_roles submodule and visiting:

    /admin/config/lti-tool-provider/roles/v1p0
    /admin/config/lti-tool-provider/roles/v1p3

    Encountered the following fatal error:

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

    Then applied patch #3 and retested.

    The Role Mapping configuration pages now loads correctly without any errors.