Error when running sitemap_update_8202

Created on 7 August 2024, 4 months ago
Updated 21 August 2024, 3 months ago

Problem/Motivation

On a site with both the sitemap and book modules installed, the update hook sitemap_update_8202() (added in 📌 Drupal 11 compatibility fixes for sitemap Fixed ) throws an error when you run it:

[error]  Call to undefined method Drupal\Core\Extension\ModuleHandler::install()

Steps to reproduce

  1. Install Drupal and sitemap-8.x-2.0-beta6
  2. Upgrade sitemap to sitemap-8.x-2.0-beta7
  3. Run update hooks

Proposed resolution

diff --git a/sitemap.install b/sitemap.install
index 0ddbccc..c52952a 100644
--- a/sitemap.install
+++ b/sitemap.install
@@ -156,7 +156,7 @@ function sitemap_update_8201(&$sandbox) {
  */
 function sitemap_update_8202(&$sandbox) {
   if (\Drupal::moduleHandler()->moduleExists('book')) {
-    \Drupal::moduleHandler()->install(['sitemap_book']);
+    \Drupal::service('module_installer')->install(['sitemap_book']);
   }
 }

Remaining tasks

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Component

Code

Created by

🇨🇦Canada mparker17 UTC-4

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