Skip to content

Support DB_PATH for SQLite database commands - #351

Open
JanJakes wants to merge 1 commit into
wp-cli:mainfrom
JanJakes:sqlite-db-path
Open

JanJakes wants to merge 1 commit into
wp-cli:mainfrom
JanJakes:sqlite-db-path

Conversation

@JanJakes

@JanJakes JanJakes commented Oct 2, 2026 •

Copy link
Copy Markdown

SQLite Database Integration 3.1 will introduce DB_PATH as the primary database path setting. Legacy constants remain supported, but DB_PATH takes precedence when both are defined (and conflicting legacy values only trigger warnings).

This PR prepares WP-CLI file operations for that change by preferring DB_PATH while retaining the existing fallbacks for older plugin versions.

The tests cover conflicting, matching, and legacy-only configurations through export and drop and verify that the other database stays unchanged. The tests were also run against the merged SQLite plugin code.

The Codecov job is failing because coverage is collected only from the MySQL job. The SQLite jobs pass but run without coverage enabled, so Codecov reports the new SQLite lines as uncovered.

Related: WordPress/sqlite-database-integration#512

Summary by CodeRabbit

  • Bug Fixes
    • SQLite database commands now use the configured DB_PATH when available, so exports and database removal target the selected database.

Use the database selected by WordPress when legacy constants conflict,
while retaining the existing fallback for older plugin versions.

Cover file operations with conflicting, matching, and legacy settings,
including checks that the other database remains unchanged.

WordPress/sqlite-database-integration#512
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 601f8e0c-3e3d-4078-b7d8-40bac71ab8c9

📥 Commits

Reviewing files that changed from the base of the PR and between 23dddd7 and eb9ef6a.

📒 Files selected for processing (2)
  • features/db-sqlite-path.feature
  • src/DB_Command_SQLite.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

SQLite database path lookup now checks DB_PATH before FQDB and fallback paths. A feature scenario covers four path-constant configurations and checks that export and drop affect the selected database.

Changes

SQLite database path selection

Layer / File(s) Summary
DB_PATH precedence and feature coverage
src/DB_Command_SQLite.php, features/db-sqlite-path.feature
get_sqlite_db_path() now returns DB_PATH when defined. The scenario outline checks that export uses the selected database and that dropping it leaves the other database unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: swissspidy

Merge Risk: ⚪ Minimal · up to eb9ef

No actionable issue is established for the SQLite path change; it is mergeable after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to eb9ef

WP-CLI will follow DB_PATH even when older settings point to another database. Existing command safeguards remain, and no new attack path was established. Agreement with the SQLite plugin’s active database has not been independently verified across supported versions.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The effective target is a filesystem database accessible to the invoking process. Configuration can redirect existing read, write, and deletion operations without a resolver-enforced directory boundary; this authority already existed through legacy path settings.

Trust Boundaries and Controls

  • observed — The existing SQLite detection gate remains. Drop still presents the selected path through its confirmation flow before deletion; export retains its existing SQLite dispatch. These are unchanged controls, not newly added authorization boundaries.

Resilience and Maintainability Implications

  • observed — Drop and reset retain close-before-unlink ordering and deletion-error handling. Reset still deletes before checking sqlite3 availability, so a later failure can leave the selected database absent; this recovery limitation predates the PR. The reviewed evidence does not establish that the external drop-in’s active connection always matches DB_PATH.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding DB_PATH support for SQLite database commands.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added bug command:db Related to 'db' command command:db-drop Related to 'db drop' command command:db-export Related to 'db export' command scope:testing Related to testing labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Hello! 👋

Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project.

Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Here are some useful Composer commands to get you started:

  • composer install: Install dependencies.
  • composer test: Run the full test suite.
  • composer phpcs: Check for code style violations.
  • composer phpcbf: Automatically fix code style violations.
  • composer phpunit: Run unit tests.
  • composer behat: Run behavior-driven tests.

To run a single Behat test, you can use the following command:

# Run all tests in a single file
composer behat features/some-feature.feature

# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123

You can find a list of all available Behat steps in our handbook.

@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/DB_Command_SQLite.php 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@JanJakes JanJakes changed the title Prefer DB_PATH for SQLite database commands Support DB_PATH for SQLite database commands Oct 2, 2026
@JanJakes
JanJakes marked this pull request as ready for review October 2, 2026 07:34
@JanJakes
JanJakes requested a review from a team as a code owner October 2, 2026 07:34
@ernilambar
ernilambar requested a lite review from Copilot October 3, 2026 11:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Address the :memory: handling and Windows scenario exclusion issues.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Updates SQLite file operations to prefer DB_PATH while preserving legacy fallbacks.

Changes:

  • Adds DB_PATH precedence to SQLite path resolution.
  • Adds Behat coverage for conflicting and legacy configurations.
File Summary Review status
src/​DB_Command_SQLite.php Resolves the configured SQLite database path. Moderate issue: handle :memory: explicitly.
features/​db-sqlite-path.feature Tests exports and drops against selected databases. Moderate issue: exclude the file-locking scenario on Windows.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -0,0 +1,62 @@
@require-sqlite
Comment thread src/DB_Command_SQLite.php
Comment on lines +66 to +68
if ( defined( 'DB_PATH' ) ) {
return DB_PATH;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:db Related to 'db' command command:db-drop Related to 'db drop' command command:db-export Related to 'db export' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants