Recreate missing db.php drop-ins and preserve custom SQLite drop-ins - #3993
Conversation
There was a problem hiding this comment.
I tested the old MDI failure mode against this branch: a configured site with MDI's custom wp-content/db.php, with @studio-keep removed, running the Studio SQLite setup path via keepSqliteIntegrationUpdated() -> installSqliteIntegration(). The markerless MDI drop-in was preserved, stayed identifiable via MARKDOWN_DB_DROPIN, did not become the stock drop-in, and the SQLite mu-plugin was still refreshed.
Given that, this fixes the issue I cared about. One cleanup suggestion: if SQLITE_DB_DROPIN_VERSION is now the preservation contract for SQLite-compatible custom drop-ins, I think we can remove the @studio-keep escape hatch to avoid carrying two contracts. MDI can align to the new contract without the marker. Not blocking from me.
fredrikekelund
left a comment
There was a problem hiding this comment.
The needsSqliteSetup logic is meant to allow users to use MySQL instead of SQLite if they want, which I would think is a more common use case than bringing custom db.php drop-ins (although we can support both). See documentation about MySQL support for more context
Agreed, this is a use case that allows users to use Studio with a MySQL server of their choice. Let's ensure that all the test cases from the spreadsheet are still supported. |
…ls' into gcsecsey/stu-1821-fix-clone-fatals
📊 Performance Test ResultsComparing 4421166 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
@fredrikekelund @wojtekn Thanks for the catch, and for the MySQL docs link. I restored needsSqliteSetup with checks according to the docs, and updated the tests. @wojtekn could you share the spreadsheet you mentioned? |
…E_DB_DROPIN_VERSION (STU-1571)
Good call, thanks @chubes4! I checked that we don't have any public-facing docs about it, then removed |
fredrikekelund
left a comment
There was a problem hiding this comment.
LGTM 👍 This works as expected.
I left a comment about changing the logic of shouldKeepExistingDbDropin() from negative to affirmative that'd be nice to address, but I'll let you decide about that, @gcsecsey.
Co-authored-by: Fredrik Rombach Ekelund <fredrik@f26d.dev>
Related issues
How AI was used in this PR
I used Claude to investigate both issues, trace the shared root cause in the SQLite drop-in management policy, implement the fix, and write the unit and end-to-end tests. I reviewed the diagnosis and verified every branch of the new policy against real
db.phpfiles from local sites.Proposed Changes
The way Studio managed the
wp-content/db.phpSQLite drop-in was wrong in two ways. A configured site whosedb.phpwent missing was never restored, leaving the site stuck on "Error establishing a database connection" (STU-1821 Problem 1). At the same time, a presentdb.phpwas reinstalled on every operation, breaking custom SQLite drop-ins like markdown-database-integration (STU-1571).db.phpwhenever it is missing, so a cloned or repaired site can connect to its database again.db.phpis replaced so the site can boot, and a custom SQLite-compatible drop-in (or one marked@studio-keep) is preserved.Testing Instructions
Core fix (STU-1821 Problem 1):
wp-content/db.php, then start the site again.Error establishing a database connectionerror, and to recreatedb.php.db.phppolicy (STU-1571):For each case below, drop the file into
~/Studio/<site>/wp-content/db.php, then stop and start the site. A unique comment that survives means the file was kept, if it is gone, the file was replaced.Pull path:
db.phpto be present after the pull.Pre-merge Checklist