Skip to content

Make --dbname and --dbuser optional when SQLite is active#221

Open
abhi3315 wants to merge 2 commits intowp-cli:mainfrom
abhi3315:sqlite-config-create-support
Open

Make --dbname and --dbuser optional when SQLite is active#221
abhi3315 wants to merge 2 commits intowp-cli:mainfrom
abhi3315:sqlite-config-create-support

Conversation

@abhi3315
Copy link
Copy Markdown

@abhi3315 abhi3315 commented Apr 9, 2026

wp config create requires --dbname and --dbuser even when the SQLite integration plugin is active. SQLite doesn't use these parameters, so users are forced to pass dummy MySQL credentials to create a wp-config.php for a SQLite-backed site.

Addresses the enhancement suggested by @mrsdizzie in #167 (comment).

Also incorporates all review feedback from #219 (batched error messages, is_readable() guard, isset() instead of empty()).

Changes

  • Synopsis: --dbname and --dbuser are now optional ([--dbname=<dbname>], [--dbuser=<dbuser>])
  • SQLite detection: New is_sqlite_integration_active() method scans wp-content/db.php for SQLITE_DB_DROPIN_VERSION, matching the approach used by DB_Command_SQLite::is_sqlite()
  • Validation: When SQLite is not detected, missing --dbname/--dbuser still produces an error with both parameters reported in a single message
  • MySQLi check: Skipped entirely when SQLite is detected

Test coverage

  • New @require-sqlite scenario: verifies wp config create --skip-salts succeeds without --dbname/--dbuser when the SQLite drop-in is present
  • New @skip-sqlite scenario: verifies the error message when both parameters are missing on MySQL/MariaDB

Fixes #167

--

Related wp-cli/wp-cli#6295

@abhi3315 abhi3315 requested a review from a team as a code owner April 9, 2026 10:59
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

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

Files with missing lines Patch % Lines
src/Config_Command.php 88.88% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for SQLite integration in the wp config create command, allowing users to omit the --dbname and --dbuser parameters when an SQLite drop-in is detected. The changes include a new helper method to check for the SQLite drop-in, updated parameter validation logic, and corresponding feature tests. I have provided feedback regarding the robust construction of the wp-content directory path to avoid potential path concatenation errors and suggested simplifying the error messages for better clarity.

@swissspidy
Copy link
Copy Markdown
Member

Please note that we already have an active PR for this at #219...

@github-actions

This comment was marked as resolved.

@github-actions github-actions bot added command:config Related to 'config' command scope:distribution Related to distribution labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:config Related to 'config' command scope:distribution Related to distribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQLite Compatibility

2 participants