-
Notifications
You must be signed in to change notification settings - Fork 49
Add WP_SQLITE_DB_NAME constant to take precedence over DB_NAME #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
@JanJakes , what do you think about using this constant to override the DB_NAME? |
* TODO: For version 3.0, enforce the DB_NAME constant and remove the fallback. | ||
*/ | ||
if ( defined( 'DB_NAME' ) && '' !== DB_NAME ) { | ||
if ( defined( 'WP_SQLITE_DB_NAME' ) && '' !== WP_SQLITE_DB_NAME ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the prefix WP_SQLITE_
to be consistent with other constants required by this plugin, such as WP_SQLITE_AST_DRIVER
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sejas for improving this! I’ve tested it, and can confirm that after breaking the connection, applying these changes, and adding the new constant, the site works again.
This LGTM, so I’m accepting the PR, but leaving it to you or someone from the team to decide whether to merge it.
Database name incorrect | Adding the constant | Refreshing the site |
---|---|---|
![]() |
![]() |
![]() |
Because filters actually don’t work in db.php, I suggest removing the
wp_sqlite_default_db_name
filter and introducing a new constantWP_SQLITE_DB_NAME
to take precedence over DB_NAME.Error establishing a database connection
define( 'WP_SQLITE_DB_NAME', 'database_name_here' );
Credit to @wojtekn for the code. I just removed the filter as it seemed misleading.