Make WordPress Core

Changeset 61001


Ignore:
Timestamp:
10/21/2025 02:48:53 AM (4 months ago)
Author:
desrosj
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/update.php

    r60493 r61001  
    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(
     
    114115        'image_support'      => array(),
    115116    );
     117
     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    }
    116150
    117151    if ( function_exists( 'gd_info' ) ) {
Note: See TracChangeset for help on using the changeset viewer.