Bedrock 1.15.0 / phpdotenv:5.2 / Error: Error establishing a database connection

Is anyone else experiencing the following problem with vlucas/phpdotenv:5.2 that was updated in Bedrock 1.15.0?

Am I missing something?

Reverting to vlucas/phpdotenv:4.1.8 resolves the error for me. Tried also re-provisioning, but that did not help. Identical experiences with two different sites, while two others without the update continued to work just fine.

Thanks in advance!

TASK [deploy : Create file with multisite constants defined as false] **************************************************************************************
ok: [ip.address]

TASK [deploy : WordPress Installed?] ***********************************************************************************************************************
System info:
  Ansible 2.10.3; Darwin
  Trellis version (per changelog): "Officially support Ubuntu 20.04"
---------------------------------------------------
non-zero return code
Error: Error establishing a database connection. This either means that the
username and password information in your `wp-config.php` file is incorrect
or we can’t contact the database server at `localhost`. This could mean your
host’s database server is down.
fatal: [ip.address]: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed", "--skip-plugins", "--skip-themes", "--require=/srv/www/example.com/shared/tmp_multisite_constants.php"], "delta": "0:00:00.207594", "end": "2020-12-05 14:21:02.279148", "failed_when_result": true, "rc": 1, "start": "2020-12-05 14:21:02.071554", "stderr_lines": ["Error: Error establishing a database connection. This either means that the username and password information in your `wp-config.php` file is incorrect or we can’t contact the database server at `localhost`. This could mean your host’s database server is down."], "stdout": "", "stdout_lines": []}

PLAY RECAP *************************************************************************************************************************************************
ip.address                 : ok=30   changed=13   unreachable=0    failed=1    skipped=33   rescued=0    ignored=0
localhost                  : ok=0    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

Clean Trellis 1.7.0 & Bedrock 1.15.0 seem to work fine, so the problem’s got to do with my old installs. Can’t tell yet what is wrong.

Upgrade your bedrock to v1.15.0, specificly https://github.com/roots/bedrock/pull/563

1 Like

I think in addition to updating vlucas/phpdotenv, you need to change this line in config/application.php

$dotenv = Dotenv\Dotenv::createImmutable($root_dir);

To this
$dotenv = Dotenv\Dotenv::createUnsafeImmutable($root_dir);

I haven’t tested my local site yet, so this my guess.

You are right, it’s about createImmutable vs createUnsafeImmutable.

I had looked into the PR, but failed to see config/application.php there - my bad, sorry :frowning:

:slightly_smiling_face:
I learned from the upgrade from PHPDotEnv V3 to V4, so no problem.

This topic was automatically closed after 42 days. New replies are no longer allowed.