Installer does not pick up password value from settings.php when hash_salt is not pre-populated

Created on 30 January 2021, over 3 years ago
Updated 7 June 2024, 18 days ago

Setup of the system on which Drupal is being installed

I have a fresh copy of Drupal 9, created through Composer. I have created a settings.local.php file with the database credentials supplied (username, database name, driver = mysql, password, but no prefix). The settings.local.php file does not contain a value for hash_salt, so that the installer can generate a fresh random value for this. I have previously successully installed Drupal in exactly this context, but that was when 8.8 was the most recent major core release.

What should happen

The installer should skip past the "Set up database" also known as "Database configuration" screen, moving straight from "Verify requirements" to "Install site" because the database credentials are known and correct.

What actually happens

On clicking "Save and continue" in the "Verify requirements" screen, I am invited to enter "Database configuration". The username and database name are populated in the form, but the password field is empty.

If I re-enter my password in that field, saving the settings form appends a fresh database credentials array to settings.php.

If I drop all tables and re-run the installer, with that additional database credentials array still in place, the same thing happens, and another database credentials array gets created.

For some reason, the installer is not reading the password from the settings.php file and concludes that settings.php needs the full database credentials adding.

Steps taken to debug 1: hash_salt

The problem is triggered by not having hash_salt pre-populated in settings.php.

If I enter a value manually (say, copying one from another site I manage), the installation works as expected.

This means this issue is related to #2972002: Missing hash salt throws AlreadyInstalled exception during manual installation when settings.php already exists β†’ . However I've opened another issue for this, because it may not be a straight duplicate. The problem there is to do with the installation only completing partially when the database credentials are pre-populated in settings.php but hash_salt is not. The issue here is the installer not reading the password from settings.(local.)php correctly.

Steps taken to debug 2: debugging the PHP code in the installer

I've inserted print statements to print_r the $database array to screen, or particular values from it, at various points in core/lib/Drupal/Core/Database/Install/Tasks.php and core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php. At every point, the $database array includes the password value from settings.php, and $database['password'] is correctly set. This includes (current) line 267 of Tasks.php, where I have verified that the default value for the form password field is correctly populated at this point in time:

    $form['password'] = [
      '#type' => 'password',
      '#title' => t('Database password'),
      '#default_value' => empty($database['password']) ? '' : $database['password'],
      '#required' => FALSE,
      '#size' => 45,
    ];

I've also tried changing the #default_value line at that point to set the password form field to 'password', and it still shows as empty.

So the password is being read from the database correctly, but the database settings form does not include the password (for some reason I cannot determine).

Work Around

At this point in time, the only way to get the site to install is to generate hash_salt manually, and put that value into settings.local.php.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
InstallΒ  β†’

Last updated about 9 hours ago

No maintainer
Created by

πŸ‡¬πŸ‡§United Kingdom JamesOakley Kent, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024