Problem/Motivation

As part of the 2.0.1 update, the following hook is updating core.extension.yml incorrectly:

/**
 * Ensure caches are cleared with new module folder locations.
 */
function captcha_update_8906() {
  // Remove test modules if they're on the site. They won't rebuild.
  $extension = \Drupal::configFactory()->getEditable('core.extension');
  $modules = $extension->get('module');
  unset($modules['captcha_long_form_id_test']);
  unset($modules['captcha_test']);
  $extension->set('modules', $modules);
  $extension->save();

  // Need to flush all caches due to module paths changing.
  drupal_flush_all_caches();
}

Note the lines:

$modules = $extension->get('module');

$extension->set('modules', $modules);

The second line should be updating "module", not "modules". This is leading to erroneous data getting added to core.extension.yml.

Steps to reproduce

Run captcha_update_8906 on any Drupal website, export config, notice core.extension.yml get a new modules key.

Proposed resolution

Update the hook to set "module" and not "modules".

Issue fork captcha-3375400

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

ThomWilhelm created an issue. See original summary.

thomwilhelm’s picture

Assigned: thomwilhelm » Unassigned
keshavv’s picture

Status: Active » Needs review
anybody’s picture

Status: Needs review » Needs work

Thanks for finding this! Looking at this detail and comparing these two lines, this is indeed wrong.

This means we need another update hook after that one, deleting the newly created "modules".

anybody’s picture

anybody’s picture

Incorporated the MR from #3375351: Problem after updating to 2.0.1 by @ChrisSnyder!

anybody’s picture

anybody’s picture

Status: Needs work » Needs review
mkalkbrenner’s picture

Status: Needs review » Reviewed & tested by the community

I ran into this issue, too.

  • Anybody committed fdce0696 on 2.x authored by ThomWilhelm
    Issue #3375400 by ThomWilhelm, Anybody, ChrisSnyder: captcha_update_8906...
anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, merged! Going to tag 2.0.2

jaydarnell’s picture

Good catch. I was really confused when I upgraded to 2.0.1 and saw the duplicate "modules" in the core.extension.yml :)

japerry’s picture

Thanks everyone for grabbing this overnight! I even manually tested the upgrade path (due to the test modules failing).

Status: Fixed » Closed (fixed)

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