Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[site:install] fails when the settings file is populated #3572

Closed
cburschka-pwc opened this issue Nov 7, 2017 · 4 comments
Closed

[site:install] fails when the settings file is populated #3572

cburschka-pwc opened this issue Nov 7, 2017 · 4 comments

Comments

@cburschka-pwc
Copy link
Contributor

To reproduce this:

  1. Install Drupal
  2. Drop all tables
  3. Use drupal site:install again.

The wizard continues until the installation starts, and then fails with the error Drupal is already installed. (This seems like a valid use case, especially in local environments where the database is frequently torn down and reinstalled. Also, note that Drupal's web installer seemingly has no problem with an existing settings.php, as long as the DB isn't installed yet.)

Investigation shows that this is actually caused by the bootstrap adding some tables automatically, and adding a single config object (which then makes the configuration fail the "non-empty" check).

collection	name    	data
	        system.file	a:1:{s:4:"path";a:1:{s:9:"temporary";s:4:"/tmp";}}

A workaround is to run drupal site:install, then (once it has bootstrapped and reached the first prompt), manually truncate the config table, and then let the installer continue. Maybe we can somehow prevent this config object from being inserted during bootstrap, or remove it before the installation begins?

@jmolivas
Copy link
Member

jmolivas commented Nov 9, 2017

@cburschka-pwc You can use the --force option/flag to force the installation even if database exists. Using --force will drop the site database.

drupal site:install --force

@cburschka-pwc
Copy link
Contributor Author

cburschka-pwc commented Nov 16, 2017

Unfortunately, in 1.1.0 this problem has been exacerbated, and --force no longer works.

Running site:install with an empty database now crashes with the following error (after first auto-creating the cache_bootstrap and cache_config tables):

  [Drupal\Core\Database\DatabaseExceptionWrapper]                                                                          
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.key_value' doesn't exist: SELECT 1 AS expression  
  FROM                                                                                                                     
  {key_value} key_value                                                                                                    
  WHERE (name = :db_condition_placeholder_0) AND (collection = :db_condition_placeholder_1); Array                         
  (                                                                                                                        
      [:db_condition_placeholder_0] => system.module.files                                                                 
      [:db_condition_placeholder_1] => state                                                                               
  )                                                                                                                        
                                                                                                   
  [PDOException]                                                                                   
  SQLSTATE[42S02]: Base table or view not found: 1146 Table 'database.key_value' doesn't exist  

In particular, this happens with all commands, including list, and probably others that should be available without a full site.

In 1.0.2, drupal list with a settings.php file and no database shows the missing table warning, but then lists the available commands, and drupal si --force installs the database with the given settings.

In 1.1.* and 1.2, both crash with the above error.

@jmolivas
Copy link
Member

@cburschka-pwc I will check this and add some comments on this issue.

jmolivas added a commit to jmolivas/drupal-console that referenced this issue Nov 18, 2017
@jmolivas
Copy link
Member

jmolivas commented Nov 18, 2017

I tested by dropping database using:

  • MySQL:
drop database drupal_default;
  • DrupalConsole (this command only drop tables)
drupal database:drop -y

After executing some commands against the not yet installed site some tables are created.

mysql [email protected]:drupal_default> show tables;
+----------------------------+
| Tables_in_drupal_default   |
|----------------------------|
| cache_bootstrap            |
| cache_config               |
| cache_container            |
| cache_data                 |
| cache_default              |
| cache_discovery            |
| cache_entity               |
| cache_menu                 |
| cache_render               |
+----------------------------+
9 rows in set
Time: 0.014s
mysql [email protected]:drupal_default>

I sent the PR #3598 to avoid this from happening by validating the sessions table exists as Drupal does on the InstallerRedirectTrait class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants