From 0c7b629ae65dbfa45f5b318df95311540915d290 Mon Sep 17 00:00:00 2001 From: desrosj Date: Tue, 21 Oct 2025 02:50:27 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@61001 git-svn-id: http://core.svn.wordpress.org/trunk@60337 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/update.php | 34 ++++++++++++++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/wp-includes/update.php b/wp-includes/update.php index 867ead3cdd..4ab8f5a4e4 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -106,6 +106,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) { 'users' => get_user_count(), 'multisite_enabled' => $multisite_enabled, 'initial_db_version' => get_site_option( 'initial_db_version' ), + 'myisam_tables' => array(), 'extensions' => array_combine( $extensions, array_map( 'phpversion', $extensions ) ), 'platform_flags' => array( 'os' => PHP_OS, @@ -114,6 +115,39 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) { 'image_support' => array(), ); + // Check for default tables using the MyISAM engine. + $table_names = implode( "','", $wpdb->tables() ); + $myisam_tables = $wpdb->get_results( + $wpdb->prepare( + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- This query cannot use interpolation. + "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = %s AND TABLE_NAME IN ('$table_names') AND ENGINE = %s;", + DB_NAME, + 'MyISAM' + ), + OBJECT_K + ); + + if ( ! empty( $myisam_tables ) ) { + $all_unprefixed_tables = $wpdb->tables( 'all', false ); + + // Including the table prefix is not necessary. + $unprefixed_myisam_tables = array_reduce( + array_keys( $myisam_tables ), + function ( $carry, $prefixed_myisam_table ) use ( $all_unprefixed_tables ) { + foreach ( $all_unprefixed_tables as $unprefixed ) { + if ( str_ends_with( $prefixed_myisam_table, $unprefixed ) ) { + $carry[] = $unprefixed; + break; + } + } + return $carry; + }, + array() + ); + + $query['myisam_tables'] = $unprefixed_myisam_tables; + } + if ( function_exists( 'gd_info' ) ) { $gd_info = gd_info(); // Filter to supported values. diff --git a/wp-includes/version.php b/wp-includes/version.php index e174e60023..bed110092f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-alpha-61000'; +$wp_version = '6.9-alpha-61001'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.