Skip to content

Support randomized SQLite storage and DB_PATH - #443

Open
JanJakes wants to merge 2 commits into
mainfrom
sqlite-path-discovery
Open

JanJakes wants to merge 2 commits into
mainfrom
sqlite-path-discovery

Conversation

@JanJakes

@JanJakes JanJakes commented Oct 6, 2026

Copy link
Copy Markdown

Summary

MDI can miss an existing SQLite database when it uses DB_PATH or randomized storage, causing automatic backend selection to choose mdi-native. Mirror mode also uses FQDB even when DB_PATH points elsewhere.

This change makes SQLite path handling consistent:

  • Discover configured, managed, and legacy storage without creating or migrating a database during backend selection.
  • Prefer DB_PATH for mirror connections and directory protection, using SQLite Integration’s storage API when available and retaining compatibility with older versions.
  • Pass the existing PDO connection through the driver’s supported options so current versions use the selected database.

Explicit backend overrides and existing primary, native, and MySQL behavior are preserved.

Validation

Verified randomized storage, legacy layouts, DB_PATH alone, conflicting paths, backend selection, primary index reconstruction, and installation fallbacks against SQLite Integration at 4163f69, v3.0.2, v3.0.0, and v2.2.23 on PHP 8.2 and 8.5. The repository smoke suite, PHP syntax checks, and diff checks also passed.

Related: WordPress/sqlite-database-integration#502
Related: WordPress/sqlite-database-integration#512

Use sqlite_pdo and sqlite_journal_mode with the current driver while
retaining the legacy PDO option. This keeps the supplied connection
instead of opening a separate in-memory database.

Update driver stubs and add a regression probe against real integrations.
Detect configured paths, managed storage metadata, and legacy layouts
without creating or migrating a database during backend selection.

Resolve configured paths before integration defaults are loaded, and
initialize managed storage once in the drop-in. Mirror mode uses the
resolved path for both the connection and directory protection. Keep
primary index reconstruction and stock fallback configuration intact.

Cover path precedence, neighboring legacy files, randomized storage,
backend overrides, primary indexes, and installation fallbacks with
current and older integrations.

Related: WordPress/sqlite-database-integration#502
Related: WordPress/sqlite-database-integration#512
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.

1 participant