Skip to content

Preserve SQLite integration during database import - #4356

Open
chubes4 wants to merge 5 commits into
trunkfrom
fix/3518-import-db-dropin
Open

Preserve SQLite integration during database import#4356
chubes4 wants to merge 5 commits into
trunkfrom
fix/3518-import-db-dropin

Conversation

@chubes4

@chubes4 chubes4 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Related issues

Proposed changes

WordPress.com backups can contain a foreign wp-content/db.php, such as Query Monitor's database drop-in. Restoring that file before wp sqlite import hides SQLITE_DB_DROPIN_VERSION and makes the database pull fail.

  • Reinstall Studio's SQLite integration after backup content is restored and before SQL import.
  • Classify the destination before any backup mutation so an intentional-MySQL site cannot be silently converted to SQLite.
  • Reject database import into an external/MySQL destination before copying content or creating SQLite artifacts.
  • Cover both the foreign-drop-in repair and intentional-MySQL non-mutation with real CLI E2E tests.

George Garside's two commits from #3692 are preserved with original authorship. The branch was rebased onto current trunk because maintainer push access to the contributor fork remained unavailable.

Verification

  • npm test -- apps/cli/lib/import-export/import/importers/tests/importer.test.ts packages/common/lib/tests/sqlite-integration.test.ts (58 passed)
  • npm -w wp-studio run typecheck
  • focused ESLint on all changed files
  • npm test -- apps/cli/commands/tests/import.e2e.test.ts --tagsFilter=e2e (7 passed)

AI assistance

OpenAI GPT-5.6 Sol via OpenCode investigated the compatibility regression, implemented the destination preflight and MySQL regression case, and ran verification under Chris Huber's direction. Chris reviewed the changes and remains responsible for every line. George's original implementation and regression-test commits retain their original authorship.

@chubes4

chubes4 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@wojtekn this is the landable continuation of #3692, with George's original commits/authorship preserved and the MySQL classification regression fixed. Please review when you have time.

Before recommending approval, I am running a focused fuzz testing campaign against only the two contracts changed here:

  1. foreign backup db.php recovery on SQLite destinations
  2. explicit, pre-mutation rejection on intentional-MySQL destinations

The broader db.php hardening findings discovered during rig bring-up are tracked separately in #4355 and are not being folded into this PR. This PR still requires the normal Studio maintainer review and approval.

@chubes4
chubes4 requested a review from wojtekn July 27, 2026 13:16
@wpmobilebot

wpmobilebot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing a5641d9 vs trunk

app-size

Metric trunk a5641d9 Diff Change
App Size (Mac) 1378.86 MB 1375.40 MB 3.46 MB 🟢 -0.3%

site-editor

Metric trunk a5641d9 Diff Change
load 1033 ms 1071 ms +38 ms ⚪ 0.0%

site-startup

Metric trunk a5641d9 Diff Change
siteCreation 6486 ms 6509 ms +23 ms ⚪ 0.0%
siteStartup 2373 ms 2380 ms +7 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@chubes4
chubes4 marked this pull request as draft July 27, 2026 13:36
@chubes4
chubes4 marked this pull request as ready for review July 27, 2026 13:50
@chubes4

chubes4 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Focused fuzz result: 19/19 passed, zero findings

Tested this exact PR revision: 0bb440eddd8ebe53c15fe826a30c5ec13b2f58b0. The campaign ran the real built Studio CLI against isolated generated sites and covered the two contracts changed here:

  • Foreign backup db.php recovery across all seven non-empty combinations of the SQLite drop-in, database artifact, and integration plugin.
  • Six foreign payload shapes through Jetpack backup and raw SQL imports.
  • Repeated-import idempotency and imports while a site was running, including restoration of running state.
  • Intentional-MySQL rejection before mutation, verified by byte-for-byte filesystem snapshots before and after each rejected import.

Result: 19 cases passed; 0 findings. Target and operation coverage were complete, and case logs, replay data, coverage summary, and the result envelope were retained. Broader provider-hardening findings remain separately scoped in #4355.

The reusable campaign source is in homeboy-rigs PR #700, tested at 7ccbe54558d145d022ef2b88f3ba9f7e2063df5e. It can be reproduced without Homeboy from the Studio checkout:

npm ci --ignore-scripts
node --experimental-strip-types ./scripts/download-wp-server-files.ts
npm run cli:build
node /path/to/homeboy-rigs/Automattic/studio/fuzz/import-db-dropin-fuzz-runner.mjs

The runner writes human-readable evidence to artifacts/fuzz/run/: results.json, coverage-summary.json, case-log.jsonl, and replay.json.

@chubes4
chubes4 requested a review from gcsecsey July 29, 2026 00:18
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.

"Could not determine the version of the SQLite integration plugin" on pull of database from WordPress.com site

3 participants