Skip to content

Commit

Permalink
Rename DATABASE_TYPE to DB_ENGINE for consistency with other constants
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Mar 16, 2023
1 parent 0bd4cb3 commit 524518f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
24 changes: 12 additions & 12 deletions src/wp-admin/includes/class-wp-debug-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ public static function debug_data() {
'label' => 'WP_MAX_MEMORY_LIMIT',
'value' => WP_MAX_MEMORY_LIMIT,
),
'DATABASE_TYPE' => array(
'label' => 'DATABASE_TYPE',
'value' => ( defined( 'DATABASE_TYPE' ) ? DATABASE_TYPE : __( 'Undefined' ) ),
'debug' => ( defined( 'DATABASE_TYPE' ) ? DATABASE_TYPE : 'undefined' ),
'DB_ENGINE' => array(
'label' => 'DB_ENGINE',
'value' => ( defined( 'DB_ENGINE' ) ? DB_ENGINE : __( 'Undefined' ) ),
'debug' => ( defined( 'DB_ENGINE' ) ? DB_ENGINE : 'undefined' ),
),
'WP_DEBUG' => array(
'label' => 'WP_DEBUG',
Expand Down Expand Up @@ -844,10 +844,10 @@ public static function debug_data() {
);
}

$database_type = defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ? 'sqlite' : 'mysql';
$db_engine = defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ? 'sqlite' : 'mysql';

$extension = null;
if ( 'mysql' === $database_type ) {
if ( 'mysql' === $db_engine ) {
// Populate the database debug fields.
if ( is_resource( $wpdb->dbh ) ) {
// Old mysql extension.
Expand All @@ -871,12 +871,12 @@ public static function debug_data() {
}
}

$info['wp-database']['fields']['database_type'] = array(
'label' => __( 'Database type' ),
'value' => 'sqlite' === $database_type ? 'SQLite' : 'MySQL/MariaDB',
$info['wp-database']['fields']['db_engine'] = array(
'label' => __( 'Database engine' ),
'value' => 'sqlite' === $db_engine ? 'SQLite' : 'MySQL/MariaDB',
);

if ( 'mysql' === $database_type ) {
if ( 'mysql' === $db_engine ) {
$info['wp-database']['fields']['extension'] = array(
'label' => __( 'Extension' ),
'value' => $extension,
Expand Down Expand Up @@ -909,7 +909,7 @@ public static function debug_data() {
'value' => $wpdb->dbname,
'private' => true,
);
} elseif ( 'sqlite' === $database_type ) {
} elseif ( 'sqlite' === $db_engine ) {
$info['wp-database']['fields']['database_version'] = array(
'label' => __( 'SQLite version' ),
'value' => class_exists( 'SQLite3' ) ? SQLite3::version()['versionString'] : null,
Expand All @@ -933,7 +933,7 @@ public static function debug_data() {
'private' => true,
);

if ( 'mysql' === $database_type ) {
if ( 'mysql' === $db_engine ) {
$info['wp-database']['fields']['database_charset'] = array(
'label' => __( 'Database charset' ),
'value' => $wpdb->charset,
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private function prepare_sql_data() {
global $wpdb;

$mysql_server_type = $wpdb->db_server_info();
$this->is_sqlite = defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ? 'sqlite' : 'mysql';
$this->is_sqlite = defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ? 'sqlite' : 'mysql';

$this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' );

Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function wp_install( $blog_title, $user_name, $user_email, $is_public, $deprecat
wp_check_mysql_version();
wp_cache_flush();

if ( defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ) {
if ( defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ) {
sqlite_make_db_sqlite(); // phpcs:ignore PHPCompatibility.Extensions.RemovedExtensions.sqliteRemoved
} else {
make_db_current_silent();
Expand Down
6 changes: 3 additions & 3 deletions src/wp-admin/setup-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ function setup_config_display_header( $body_classes = array() ) {
*
* @ignore
*/
define( 'DATABASE_TYPE', $dbtype );
define( 'DB_ENGINE', $dbtype );
define( 'DB_NAME', $dbname );
define( 'DB_USER', $uname );
define( 'DB_PASSWORD', $pwd );
Expand All @@ -354,7 +354,7 @@ function setup_config_display_header( $body_classes = array() ) {
*
* @ignore
*/
define( 'DATABASE_TYPE', $dbtype );
define( 'DB_ENGINE', $dbtype );
define( 'DB_NAME', '' );
define( 'DB_USER', '' );
define( 'DB_PASSWORD', '' );
Expand Down Expand Up @@ -433,7 +433,7 @@ function setup_config_display_header( $body_classes = array() ) {
$padding = $match[2];

switch ( $constant ) {
case 'DATABASE_TYPE':
case 'DB_ENGINE':
case 'DB_NAME':
case 'DB_USER':
case 'DB_PASSWORD':
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ function require_wp_db() {

require_once ABSPATH . WPINC . '/class-wpdb.php';

if ( defined( 'DATABASE_TYPE' ) && 'sqlite' === DATABASE_TYPE ) {
if ( defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ) {
require_once ABSPATH . WPINC . '/sqlite/db.php';
}

Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/sqlite/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @since 1.0.0
*/

// Bail early if DATABASE_TYPE is not defined as sqlite.
if ( ! defined( 'DATABASE_TYPE' ) || 'sqlite' !== DATABASE_TYPE ) {
// Bail early if DB_ENGINE is not defined as sqlite.
if ( ! defined( 'DB_ENGINE' ) || 'sqlite' !== DB_ENGINE ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-load.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}

// @TODO: Remove this. It's only here so that the PR can be tested.
define( 'DATABASE_TYPE', 'sqlite' );
define( 'DB_ENGINE', 'sqlite' );

/*
* The error_reporting() function can be disabled in php.ini. On systems where that is the case,
Expand Down
2 changes: 1 addition & 1 deletion wp-config-sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

// ** Database settings - You can get this info from your web host ** //
define( 'DATABASE_TYPE', 'mysql' );
define( 'DB_ENGINE', 'mysql' );

/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
Expand Down

0 comments on commit 524518f

Please sign in to comment.