Skip to content

fix(doctor): see, reach and fix a site's database whatever framework it belongs to - #1406

Merged
geodro merged 1 commit into
mainfrom
fix/doctor-and-lerd-env-reach-the-real-database
Aug 8, 2026
Merged

fix(doctor): see, reach and fix a site's database whatever framework it belongs to#1406
geodro merged 1 commit into
mainfrom
fix/doctor-and-lerd-env-reach-the-real-database

Conversation

@geodro

@geodro geodro commented Aug 8, 2026

Copy link
Copy Markdown
Member

Three things stood between the doctor and a Drupal site's database, and together they let a site be misconfigured, say so, and offer nothing.

The wiring finding named the problem and stopped there. It had no fix because, when it was written, lerd env would have appended constants Drupal never reads and the button would have resolved nothing. lerd writes the array Drupal actually runs on now, so the finding offers to write it, from the dashboard and from lerd site:doctor --fix alike. The detail says it repoints the app, because it does.

lerd env then failed on the file it needed to write:

✗ writing web/sites/default/settings.php: open ...: permission denied

Drupal's installer leaves settings.php read-only, and its directory too, which is right for a deployed site and no reason to refuse to configure a local one. By then the databases had been created, so the user was left to chmod by hand and work out what else was half done. Writing restores permission for the duration and puts the mode back exactly, even when the write fails, so a file lerd could not update is left as hardened as it was found. Every format goes through the one writer, so a hardened wp-config or env.php behaves the same.

And the check that catches a database which does not exist could not see a Drupal one at all: it read DB_CONNECTION, DB_HOST and DB_DATABASE by name, which are Laravel's, from behind a dotenv gate. It resolves through the framework declaration now, like its SQLite sibling, so a project configured in a PHP settings file or behind a DSN is checked like any other. An engine that cannot be reached still produces no finding rather than a false one.

Driven end to end against a Drupal project serving 200 throughout:

mode before:  -r--r--r--     HTTP before: 200
⚠ Service Wiring ... fix: env_sync
→ lerd site:doctor --fix     wrote the connection values
✓ Service Wiring             ✓ Database
mode after:   -r--r--r--     HTTP after:  200

and with the database dropped out from under it:

✗ Database
    Database "dru" does not exist on mysql — create it with lerd db:create dru, then run migrations.
    fix: updb

which is the framework's own command, not Laravel's word for it.

Closes #1405

…it belongs to

Three things stood between the doctor and a Drupal site's database, and together they let a site be misconfigured, say so, and offer nothing.

The wiring finding named the problem and stopped. It had no fix because, when it was written, `lerd env` would have appended constants Drupal never reads and the button would have resolved nothing. lerd writes the array Drupal actually runs on now, so the finding offers to write it, from the dashboard and from `lerd site:doctor --fix` alike. The detail says it repoints the app, because it does.

`lerd env` then failed on the file it needed to write: Drupal's installer leaves settings.php read-only, which is right for a deployed site and no reason to refuse to configure a local one. Writing restores permission for the duration and puts the mode back exactly, even when the write fails, so a file lerd could not update is left as hardened as it was found. Every format goes through the one writer, so a hardened wp-config or env.php behaves the same.

And the check that catches a database which does not exist could not see a Drupal one at all: it read DB_CONNECTION, DB_HOST and DB_DATABASE by name, which are Laravel's, from behind a dotenv gate. It resolves through the framework declaration now, like its SQLite sibling, so a project configured in a PHP settings file or behind a DSN is checked like any other, and an engine that cannot be reached still produces no finding rather than a false one.
@geodro
geodro requested a review from a team as a code owner August 8, 2026 09:11
@geodro
geodro merged commit 477eb99 into main Aug 8, 2026
3 checks passed
@geodro
geodro deleted the fix/doctor-and-lerd-env-reach-the-real-database branch August 8, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(doctor): the doctor cannot see, reach or fix a Drupal site's database

1 participant