Error on hook_install when invoked from drush site-install

Created on 30 May 2023, over 1 year ago
Updated 28 November 2023, about 1 year ago

Problem/Motivation

There is a long standing issue (see here πŸ› hook_install() is invoked before the module's default config is installed during config import Needs work ) when accessing config from a hook_install().

In some scenarios (in my case, after upgrading to Drupal 10.1.x and running drush site-install --existing-config), the config is not ready when executing hook_install, so this will fail as the 'authenticated' role will return NULL:

  $role = Role::load('authenticated');

Steps to reproduce

Perform drush site-install --existing-config on an existing site that has Matomo module installed using Drupal 10.1.x.

Proposed resolution

Maybe the hook_install code should belong to a previous step (deploy hook? hook_post_config_import?) where we are sure that Drupal config is completely imported and present.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain idiaz.roncero Madrid

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024