Compatibility with Core 10.1.*

Created on 27 June 2023, over 1 year ago
Updated 29 June 2023, over 1 year ago

Problem/Motivation

In the current installation process, there is a step to grant the default permission to authenticated users. However, there are two problems:

1. Not every installation profile has a "authenticated" user role, for example, minimal
2. Starting in Drupal 10.1.0, user roles will be available later in the profile installation process ( πŸ› Modules in the profile cannot access to roles during the installation Active ), therefore, if this module is included in an installation profile, it will throw error like this:

[error]  Error: Call to a member function grantPermission() on null in _fontawesome_install_grant_default_permissions() (line 109 of /opt/drupal/web/modules/contrib/fontawesome/fontawesome.install) #0 /opt/drupal/web/modules/contrib/fontawesome/fontawesome.install(99): _fontawesome_install_grant_default_permissions()
#1 [internal function]: fontawesome_install(true)

Steps to reproduce

Proposed resolution

Use a Nullsafety operator on this part

/**
 * Grants 'access fontawesome additional settings' to authenticated users.
 */
function _fontawesome_install_grant_default_permissions() {
  /** @var \Drupal\user\RoleInterface $authenticated_role */
  $authenticated_role = \Drupal::entityTypeManager()->getStorage('user_role')->loadOverrideFree('authenticated');
  $authenticated_role->grantPermission('access fontawesome additional settings')->save();
}  

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡³China skyredwang Shanghai

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

Comments & Activities

Production build 0.71.5 2024