The config check in install_begin_request() always fails for me during Drush site reinstall. The bug is not specific to Drush though. The contents of $config are all the yml files in module owned directories and config.storage gets back an InstallStorage object. This is a bug - we want it to check that the active storage is empty.

In addition, the code comment is wrong, since the default storage is database now.

// Ensure that the active configuration directory is empty before installation
  // starts.
  if ($install_state['config_verified'] && empty($task)) {
    $config = \Drupal::service('config.storage')->listAll();
    if (!empty($config)) {
      $task = NULL;
      throw new AlreadyInstalledException($container->get('string_translation'));
    }
  }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

Title: Crufty config check in installer » Config check in installer checks the wrong config
Issue summary: View changes
pwolanin’s picture

Status: Active » Needs review
FileSize
1.05 KB

This might behave better.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

This fixes the exception for me.

sun’s picture

Status: Reviewed & tested by the community » Needs review

One problem with this is essentially the concern that I had mentioned in #2161591-85: Change default active config from file storage to DB storage already: The new config storage attempts to automatically create the storage, no?


It's not clear to me why this error is triggered via Drush, but not in the regular interactive installer, nor in tests (which are using the non-interactive installer)...?

How can this error be reproduced?

pwolanin’s picture

@sun - I was getting this intermittently in the ui too. Not sure how to test though.

the listAll() method does NOT create the storage (by design). Here's the code:


  public function listAll($prefix = '') {
    try {
      return $this->connection->query('SELECT name FROM {' . $this->connection->escapeTable($this->table) . '} WHERE name LIKE :name', array(
        ':name' => $this->connection->escapeLike($prefix) . '%',
      ), $this->options)->fetchCol();
    }
    catch (\Exception $e) {
      return array();
    }
  }

tstoeckler’s picture

I'm consistently when trying to reinstall as well. I just commented out the throw call in the OP and Drupal installed fine.

sun’s picture

Title: Config check in installer checks the wrong config » Installer checks wrong config storage to verify installation state
Issue tags: +Needs tests
Parent issue: » #2161591: Change default active config from file storage to DB storage

@pwolanin: Ah, sorry, I wrongly remembered that part.

It is still not clear to me why I'm not able to reproduce this issue locally, and why our existing interactive installer tests are not encountering it either.

So either something is wrong with our existing tests, or we're missing test coverage for the scenario here. — What is the scenario here?

Some of you referred to "reinstall", but how exactly? With or without existing settings.php? Does settings.php contain a db connection? $config_directories? Is the database empty?


Separate from that, the non-interactive installer can only reach this code path, if the config storage exists ahead of time already. Since #2161591 that no longer means the active config directory, but the {config} database table.

This means that not only $install_state['config_verified'] must be TRUE, but $install_state['database_verified'] must also be TRUE. Both must be TRUE already when the installer is initially invoked, because install_begin_request() is only entered once in the non-interactive installer.

It's not clear why $install_state['config_verified'] is TRUE to begin with?

tstoeckler’s picture

Right by reinstall I mean I have a settings.php with $databases and $config_directories (that exist). Previously that prompted the database settings form, which I just had to re-submit and Drupal would install. Now I get the "Drupal already installed." I'll try to re-produce again later.

sun’s picture

FileSize
4.79 KB

@moshe weitzman clarified in IRC:

i get this with reinstall via drush site-install. more specifically:

existing settings.php with DB connnection (DB is empty) and with config folders configured and existing but empty

That scenario is not covered by tests yet. We have an InstallerExistingSettingsTest, but it is a misnomer, since the preconfigured settings.php only contains database settings (but nothing else).

Attached patch renames the existing test and adds a new one to test a fully populated settings.php. It fails for me locally, and is expected to fail.

Status: Needs review » Needs work

The last submitted patch, 9: install.settings.8.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
5.78 KB
1014 bytes

Incorporating #2.

pwolanin’s picture

Issue tags: -Needs tests

Thanks for adding the test.

Status: Needs review » Needs work

The last submitted patch, 11: install.settings.10.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
FileSize
5.79 KB
779 bytes

Oops.

pwolanin’s picture

This test looks basically good, but I think it loses test coverage for one path to installation? why don't we add this new one instead of replacing the existing one?

sun’s picture

Sorry for the confusion, I have renames=copies enabled. Both tests are retained; the diff file headers clarify:

similarity index 89%
copy from core/modules/system/lib/Drupal/system/Tests/Installer/InstallerExistingSettingsTest.php
copy to core/modules/system/lib/Drupal/system/Tests/Installer/InstallerExistingDatabaseSettingsTest.php
...
--- a/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerExistingSettingsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Installer/InstallerExistingSettingsTest.php
moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

oh, i missed those headers too. rtbc then.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 14: install.settings.14.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
5.85 KB

Here'a re-roll.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Yup.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

  • Commit 9aeaf29 on 8.x by catch:
    Issue #2247281 by sun, pwolanin: Installer checks wrong config storage...

Status: Fixed » Closed (fixed)

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