Encountered while installing Drupal 8 on Acquia Dev Desktop (ADD), but this is a Drupal bug.

Steps to reproduce

  1. Install Drupal using ADD or while running mysql on a non-standard MySQL port (i.e. not 3306) or postgres on a non-standard port (not 5432)
  2. Empty the database and remove the config directories and then re-install be going to core/install.php
  3. At the database page, note that your database name has been pre-filled, but the database port is 3306 (for mysql)
  4. Open the existing setting.php file and note that the port number is set to your correct data base port.

Conclusion:
- Drupal is not correctly reading the port from settings. Same is true of table prefix

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YesCT’s picture

Issue tags: +d8 dev environment
nyirocsaba’s picture

You are on MAC, right? PDO will use unix socket when connecting to localhost. Try to replace the database host from "localhost" to "127.0.0.1".

ianthomas_uk’s picture

No, that was on Windows. I'm not sure why that's relevant anyway - whatever ADD added to the settings file (which gets included in settings.php) should be the default values when you get to the database stage of the install process. If it had put the wrong values into settings.php then that would clearly be an ADD bug.

YesCT’s picture

Issue tags: +Novice

I suspect we might be able to provide steps to reproduce that dont involve ADD.

Maybe just changing the port in settings and then seeing if the installer picks up that different port.
tagging novice for trying that.
https://drupal.org/contributor-tasks/add-steps-to-reproduce

dmitry_bezer’s picture

FileSize
698 bytes

Acquia Dev Desktop is not needed to reproduce this - just edit settings.php before you start installing Drupal 8 and you will see it. Suggested patch is attached.

pwolanin’s picture

Status: Active » Needs review

I just wrote this exact same patch. setting to CNR, since the patch it not getting tested.

pwolanin’s picture

FileSize
1.37 KB

Same problem for the postgres diver. This should address both.

pwolanin’s picture

Issue summary: View changes
pwolanin’s picture

I tested my patch with mysql and it found the pre-existing port setting correctly.

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

seems like a simple fix to me.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Fix looks great, but it'd be wonderful if we could add a test for this. I see some stuff in core/modules/system/lib/Drupal/system/Tests/Installer but not sure. We don't want to go all the way through with the install, since it'll obviously break, but being able to make the assertion that these form values should be pre-populated by existing settings.php settings seems like a really good idea, so we don't inadvertently break this in the future.

pwolanin’s picture

Status: Needs work » Needs review

I just spent an hour trying to write such a test. I think it's currently impossible.

Drupal throws a AlreadyInstalledException if there are existing but invalid DB credentials, there seems no way to test the non-standard port bug default value we're fixing here.

pwolanin’s picture

Priority: Normal » Major
Issue tags: -Novice, -Needs tests
FileSize
6.42 KB
7.79 KB

OMG, beating my head on a test that would just test pre-filled DB credentials (though it won't actually test that the port is picked up on testbot, though it does for me locally with DevDesktop) and I found ANOTHER bug, in that the existing prefix is not used (as well as some small bugs in the base classes).

This non-prefixing was very ugly - actually broke the parent site by running the test without the fix, don't try it at home.

Note that the majority of the new test setUp() is just copy/paste from InstallerTestBase so that we can change the step of the DB settings form and send an empty POST instead of posting the parameters.

Status: Needs review » Needs work

The last submitted patch, 13: default-db-2212947-13.patch, failed testing.

pwolanin’s picture

this passes locally both CLI and UI, so this is annoying

pwolanin’s picture

Status: Needs work » Needs review
FileSize
1.11 KB
7.93 KB

Maybe has something to do with file perms? Adding a couple extra chmod calls.

Status: Needs review » Needs work

The last submitted patch, 16: default-db-2212947-16.patch, failed testing.

pwolanin’s picture

Status: Needs work » Needs review
FileSize
1.15 KB
8.16 KB

Argh - the form doesn't actually populate the password value, which causes this failure. I didn't see it locally because I had no password for my local dev database. According to sun, this is by design, so working around by posting just the password.

pwolanin’s picture

Title: Installer doesn't pick up database port from settings.php » Installer doesn't pick up database port or table prefix from settings.php
Issue summary: View changes
Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

yay, green with a new test, RTBC.

sun’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
5.75 KB
5.04 KB

Properly extend InstallerTestBase.

Verbose browser debug output reveals that the default port of the pre-configured database connection from settings.php is taken over for all database drivers. → In the edge-case that a user switches to a different driver (despite pre-configured settings.php), the default value for the different driver has a wrong/faulty default value for the port.

sun’s picture

FileSize
5.83 KB
926 bytes

Use translatePostValues().

pwolanin’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for simplifying the code to use more of the parent class. I think this can be back to RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome, thanks for that. It's good to get this expected behaviour documented explicitly.

Committed and pushed to 8.x. Thanks!

  • Commit b431efa on 8.x by webchick:
    Issue #2212947 by sun, pwolanin, dmitry_bezer | ianthomas_uk: Installer...
sun’s picture

The follow-up for that @todo is essentially:

#2156401: Write install_profile value to configuration and only to settings.php if it is writeable

Slightly different symptom, but identical root cause.

Status: Fixed » Closed (fixed)

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