Skip to content

Commit 6bfc9a6

Browse files
committed
backport constant rename
1 parent b6e6168 commit 6bfc9a6

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

admin-page.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function sqlite_integration_admin_screen() {
103103
function sqlite_plugin_adminbar_item( $admin_bar ) {
104104
global $wpdb;
105105

106-
if ( defined( 'SQLITE_DB_DROPIN_VERSION' ) && defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ) {
106+
if ( defined( 'SQLITE_DB_DROPIN_VERSION' ) && defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ) {
107107
$title = '<span style="color:#46B450;">' . __( 'Database: SQLite', 'performance-lab' ) . '</span>';
108108
} elseif ( stripos( $wpdb->db_server_info(), 'maria' ) !== false ) {
109109
$title = '<span style="color:#DC3232;">' . __( 'Database: MariaDB', 'performance-lab' ) . '</span>';

constants.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
*/
88

99
// Temporary - This will be in wp-config.php once SQLite is merged in Core.
10-
if ( ! defined( 'DATABASE_TYPE' ) ) {
10+
if ( ! defined( 'DB_ENGINE' ) ) {
1111
if ( defined( 'SQLITE_DB_DROPIN_VERSION' ) ) {
12-
define( 'DATABASE_TYPE', 'sqlite' );
12+
define( 'DB_ENGINE', 'sqlite' );
13+
} elseif ( defined( 'DATABASE_ENGINE' ) ) {
14+
// backwards compatibility with previous versions of the plugin.
15+
define( 'DB_ENGINE', DATABASE_ENGINE );
1316
} else {
14-
define( 'DATABASE_TYPE', 'mysql' );
17+
define( 'DB_ENGINE', 'mysql' );
1518
}
1619
}
1720

db.copy

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ if ( ! file_exists( '{SQLITE_IMPLEMENTATION_FOLDER_PATH}/wp-includes/sqlite/db.p
1818
return;
1919
}
2020

21-
// Define SQLite constant.
21+
// Constant for backward compatibility.
2222
if ( ! defined( 'DATABASE_TYPE' ) ) {
2323
define( 'DATABASE_TYPE', 'sqlite' );
2424
}
25+
// Define SQLite constant.
26+
if ( ! defined( 'DB_ENGINE' ) ) {
27+
define( 'DB_ENGINE', 'sqlite' );
28+
}
2529

2630
// Require the implementation from the plugin.
2731
require_once '{SQLITE_IMPLEMENTATION_FOLDER_PATH}/wp-includes/sqlite/db.php';

health-check.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
* @param array $info The debug data.
1616
*/
1717
function sqlite_plugin_filter_debug_data( $info ) {
18-
$database_type = defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ? 'sqlite' : 'mysql';
18+
$db_engine = defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ? 'sqlite' : 'mysql';
1919

20-
$info['wp-constants']['fields']['DATABASE_TYPE'] = array(
21-
'label' => 'DATABASE_TYPE',
22-
'value' => ( defined( 'DATABASE_TYPE' ) ? DATABASE_TYPE : __( 'Undefined', 'sqlite-database-integration' ) ),
23-
'debug' => ( defined( 'DATABASE_TYPE' ) ? DATABASE_TYPE : 'undefined' ),
20+
$info['wp-constants']['fields']['DB_ENGINE'] = array(
21+
'label' => 'DB_ENGINE',
22+
'value' => ( defined( 'DB_ENGINE' ) ? DB_ENGINE : __( 'Undefined', 'sqlite-database-integration' ) ),
23+
'debug' => ( defined( 'DB_ENGINE' ) ? DB_ENGINE : 'undefined' ),
2424
);
2525

26-
$info['wp-database']['fields']['database_type'] = array(
26+
$info['wp-database']['fields']['db_engine'] = array(
2727
'label' => __( 'Database type', 'sqlite-database-integration' ),
28-
'value' => 'sqlite' === $database_type ? 'SQLite' : 'MySQL/MariaDB',
28+
'value' => 'sqlite' === $db_engine ? 'SQLite' : 'MySQL/MariaDB',
2929
);
3030

31-
if ( 'sqlite' === $database_type ) {
31+
if ( 'sqlite' === $db_engine ) {
3232
$info['wp-database']['fields']['database_version'] = array(
3333
'label' => __( 'SQLite version', 'sqlite-database-integration' ),
3434
'value' => class_exists( 'SQLite3' ) ? SQLite3::version()['versionString'] : null,
@@ -70,9 +70,9 @@ function sqlite_plugin_filter_debug_data( $info ) {
7070
* @return array
7171
*/
7272
function sqlite_plugin_filter_site_status_tests( $tests ) {
73-
$database_type = defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ? 'sqlite' : 'mysql';
73+
$db_engine = defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ? 'sqlite' : 'mysql';
7474

75-
if ( 'sqlite' === $database_type ) {
75+
if ( 'sqlite' === $db_engine ) {
7676
unset( $tests['direct']['utf8mb4_support'] );
7777
unset( $tests['direct']['sql_server'] );
7878
}

wp-includes/sqlite/db.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// Require the constants file.
1010
require_once dirname( dirname( __DIR__ ) ) . '/constants.php';
1111

12-
// Bail early if DATABASE_TYPE is not defined as sqlite.
13-
if ( ! defined( 'DATABASE_TYPE' ) || 'sqlite' !== DATABASE_TYPE ) {
12+
// Bail early if DB_ENGINE is not defined as sqlite.
13+
if ( ! defined( 'DB_ENGINE' ) || 'sqlite' !== DB_ENGINE ) {
1414
return;
1515
}
1616

0 commit comments

Comments
 (0)