Preserve custom db.php drop-ins during SQLite integration updates#3095
Open
Preserve custom db.php drop-ins during SQLite integration updates#3095
Conversation
Studio unconditionally overwrites wp-content/db.php on every site start, import, export, push, and pull. This breaks plugins that extend the SQLite integration with a custom db.php (e.g. markdown-database-integration). Add hasCustomDbDropin() to detect custom drop-ins by checking if db.php defines SQLITE_DB_DROPIN_VERSION but is not the stock auto-generated file. When a custom drop-in is detected, skip overwriting db.php but still update the SQLite mu-plugin (which custom drop-ins depend on). Fixes #3094
Collaborator
📊 Performance Test ResultsComparing 1995062 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) |
Apply prettier formatting to sqlite-integration.ts and its test file to fix CI lint failures.
Contributor
Author
|
@wojtekn sounds like it would work out of the box for my use case. In the meantime I am running this patch locally to test the Markdown database integration. Otherwise all the posts get wiped every time the site restarts. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hasCustomDbDropin()method to detect custom database drop-ins that extend the SQLite integrationdb.phpwhen a custom drop-in is detected, preserving plugins like markdown-database-integrationProblem
keepSqliteIntegrationUpdated()unconditionally overwriteswp-content/db.phpwith the stock SQLite drop-in on everysite start,import,export,push, andpull. This makes it impossible to use a customdb.phpthat extendsWP_SQLite_DB/WP_SQLite_Driver.The markdown-database-integration plugin provides a custom
db.phpthat uses in-memory SQLite with markdown files as the source of truth. Every time Studio touches the site, it reverts to the stock drop-in, causing data loss (markdown-stored posts become invisible).Detection Logic
A custom drop-in is identified by two conditions:
SQLITE_DB_DROPIN_VERSION(so the SQLite plugin recognizes it as a valid drop-in)"This file is auto-generated and copied from the sqlite plugin"This correctly distinguishes:
db.php→ overwrite as before ✅db.php(e.g. markdown-database-integration) → preserve ✅db.php→ create fromdb.copyas before ✅Testing
db.phpfilesFixes #3094