Skip to content

Commit 36177da

Browse files
committed
Upgrade/Install: Indicate use of MyISAM storage engine in upgrade check.
In MySQL 5.5.5, the default storage engine was changed from `MyISAM` to `InnoDB`. While still available, usage of `MyISAM` has been discouraged since and is considered legacy due to the lack of support for more modern feature. The percentage of WordPress sites with `MyISAM` tables in the wild is currently unknown. This change adds a field to upgrade checks that includes a list of tables using `MyISAM` to help make more informed decisions about database features in the future. Props johnjamesjacoby, johnbillion, dd32, desrosj, mukesh27. Fixes #63640. git-svn-id: https://develop.svn.wordpress.org/trunk@61001 602fd350-edb4-49c9-b593-d223f7449a82
1 parent cfab276 commit 36177da

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/wp-includes/update.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
106106
'users' => get_user_count(),
107107
'multisite_enabled' => $multisite_enabled,
108108
'initial_db_version' => get_site_option( 'initial_db_version' ),
109+
'myisam_tables' => array(),
109110
'extensions' => array_combine( $extensions, array_map( 'phpversion', $extensions ) ),
110111
'platform_flags' => array(
111112
'os' => PHP_OS,
@@ -114,6 +115,39 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
114115
'image_support' => array(),
115116
);
116117

118+
// Check for default tables using the MyISAM engine.
119+
$table_names = implode( "','", $wpdb->tables() );
120+
$myisam_tables = $wpdb->get_results(
121+
$wpdb->prepare(
122+
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- This query cannot use interpolation.
123+
"SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = %s AND TABLE_NAME IN ('$table_names') AND ENGINE = %s;",
124+
DB_NAME,
125+
'MyISAM'
126+
),
127+
OBJECT_K
128+
);
129+
130+
if ( ! empty( $myisam_tables ) ) {
131+
$all_unprefixed_tables = $wpdb->tables( 'all', false );
132+
133+
// Including the table prefix is not necessary.
134+
$unprefixed_myisam_tables = array_reduce(
135+
array_keys( $myisam_tables ),
136+
function ( $carry, $prefixed_myisam_table ) use ( $all_unprefixed_tables ) {
137+
foreach ( $all_unprefixed_tables as $unprefixed ) {
138+
if ( str_ends_with( $prefixed_myisam_table, $unprefixed ) ) {
139+
$carry[] = $unprefixed;
140+
break;
141+
}
142+
}
143+
return $carry;
144+
},
145+
array()
146+
);
147+
148+
$query['myisam_tables'] = $unprefixed_myisam_tables;
149+
}
150+
117151
if ( function_exists( 'gd_info' ) ) {
118152
$gd_info = gd_info();
119153
// Filter to supported values.

0 commit comments

Comments
 (0)