Problem/Motivation

If you re-install the Amp module you get pre-existing configuration errors.

Steps to reproduce:

  1. Install Amp library
  2. Install Amp module
  3. Uninstall Amp module
  4. Install Amp module
  5. KABOOM!!!
The following extensions will be enabled: amp
Do you really want to continue? (y/n): y
Drupal\Core\Config\PreExistingConfigException: Configuration objects (image.style.amp_metadata_logo_600x60) provided by amp already    [error]
exist in active configuration in
/Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Config/PreExistingConfigException.php:65
Stack trace:
#0 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Config/ConfigInstaller.php(480):
Drupal\Core\Config\PreExistingConfigException::create('amp', Array)
#1 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php(132):
Drupal\Core\Config\ConfigInstaller->checkConfigurationToInstall('module', 'amp')
#2 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/Extension/ModuleInstaller.php(141):
Drupal\Core\ProxyClass\Config\ConfigInstaller->checkConfigurationToInstall('module', 'amp')
#3 /Volumes/devdisk/dev/sites/drupal8alt.dev/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(83):
Drupal\Core\Extension\ModuleInstaller->install(Array, true)
#4 /Volumes/devdisk/dev/drush5/commands/core/drupal/environment.inc(131):
Drupal\Core\ProxyClass\Extension\ModuleInstaller->install(Array, true)
#5 /Volumes/devdisk/dev/drush5/commands/core/drupal/environment.inc(198): drush_module_install(Array)
#6 /Volumes/devdisk/dev/drush5/commands/pm/pm.drush.inc(1167): drush_module_enable(Array)
#7 /Volumes/devdisk/dev/drush5/includes/command.inc(422): drush_pm_enable('amp')
#8 /Volumes/devdisk/dev/drush5/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#9 /Volumes/devdisk/dev/drush5/includes/command.inc(199): drush_command('amp')
#10 /Volumes/devdisk/dev/drush5/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#11 /Volumes/devdisk/dev/drush5/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#12 /Volumes/devdisk/dev/drush5/drush.php(12): drush_main()
#13 {main}

Proposed resolution

Add enforced dependencies to the image styles.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#3 2867733-2.patch1.8 KBalexpott
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Issue summary: View changes
alexpott’s picture

Status: Active » Needs review
FileSize
1.8 KB

Added the enforced dependencies and provided an update path. Also noticed that the config file for one of the image styles in config/install is wrong. This happens not to matter because of the way configuration install works but having the correct name helps for sanity.

  • mtift committed dae5667 on 8.x-1.x authored by alexpott
    Issue #2867733 by alexpott, mtift: Make the Amp module re-installable
    
mtift’s picture

Status: Needs review » Fixed

Looks good. Fixes the problem. Committed to 8.x-1.x. Thanks, Alex!

Status: Fixed » Closed (fixed)

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

quietcorn’s picture

I applied the patch, saw this:

patching file amp.install
Hunk #1 succeeded at 102 (offset 16 lines).
patching file config/install/image.style.amp_metadata_content_image_696.yml
patching file config/install/image.style.amp_metadata_logo_600x60.yml

Then did a pm-uninstall and saw this:

amp is already uninstalled.                                                                             [ok]
There were no extensions that could be uninstalled.

Then did a drush en amp command and got this:

Drush command terminated abnormally due to an unrecoverable error.                                      [error]
Error: Cannot redeclare amp_update_8003() (previously declared in
/Applications/MAMP/htdocs/drushlm8target/drushinstall1/modules/contrib/amp/amp.install:92) in
/Applications/MAMP/htdocs/drushlm8target/drushinstall1/modules/contrib/amp/amp.install, line 118

Trying to enable the module through the UI results in a white page of death php error.

Any thoughts?

quietcorn’s picture

as an update, I found some information about how to remove a configuration. I ran this with the drush php console:

>>> Drupal::configFactory()->getEditable('image.style.amp_metadata_logo_600x60')->delete();

resulting in this message:

=> Drupal\Core\Config\Config {#7443}

Then I tried re-enabling amp, and got this response:

Drush command terminated abnormally due to an unrecoverable error.                                                                                      [error]
Error: Cannot redeclare amp_update_8003() (previously declared in
/Applications/MAMP/htdocs/drushlm8target/drushinstall1/modules/contrib/amp/amp.install:92) in
/Applications/MAMP/htdocs/drushlm8target/drushinstall1/modules/contrib/amp/amp.install, line 118