Problem/Motivation

On a site with both the sitemap and book modules installed, the update hook sitemap_update_8202() (added in #3454907: Drupal 11 compatibility fixes for sitemap) 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

  1. Write a patch
  2. Commit
  3. Hotfix release

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork sitemap-3466530

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

mparker17 created an issue. See original summary.

mparker17’s picture

Issue summary: View changes
Status: Active » Needs review

Patch created; waiting for tests to finish.

mparker17’s picture

Issue summary: View changes

Tests pass. Merging. When merged, I'll create and push a tag; then create a new release. In the meantime; I'll write some release notes.

  • mparker17 committed 74f7a09f on 8.x-2.x
    Issue #3466530: Error when running sitemap_update_8202
    
mparker17’s picture

Status: Needs review » Fixed

Merged; making the hotfix release now.

Thanks for your patience, everyone!

mparker17’s picture

Issue summary: View changes

Hotfix in 8.x-2.0-beta8.

mparker17’s picture

Assigned: mparker17 » Unassigned

I can unassign myself now.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.