WordPress.org

Make WordPress Core

Ticket #49364: 49364.diff

File 49364.diff, 12.9 KB (added by SergeyBiryukov, 8 months ago)
  • src/wp-admin/includes/schema.php

     
    5252         */
    5353        $max_index_length = 191;
    5454
     55        $db_version = $wpdb->db_version();
     56
     57        /*
     58         * Display width for integer data types.
     59         *
     60         * Prior to MySQL 8.0.17, integer types had a default width: BIGINT(20), INT(11).
     61         * Since MySQL 8.0.17, display width for integer data types is no longer supported.
     62         */
     63        if ( version_compare( $db_version, '8.0.17', '<' ) ) {
     64                $bigint_display_width = '(20)';
     65                $int_display_width    = '(11)';
     66
     67                // `term_group` field in the `$wpdb->terms` table.
     68                $term_group_display_width = '(10)';
     69        } else {
     70                $bigint_display_width = '';
     71                $int_display_width    = '';
     72
     73                // `term_group` field in the `$wpdb->terms` table.
     74                $term_group_display_width = '';
     75        }
     76
    5577        // Blog-specific tables.
    5678        $blog_tables = "CREATE TABLE $wpdb->termmeta (
    57         meta_id bigint(20) unsigned NOT NULL auto_increment,
    58         term_id bigint(20) unsigned NOT NULL default '0',
     79        meta_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
     80        term_id bigint{$bigint_display_width} unsigned NOT NULL default '0',
    5981        meta_key varchar(255) default NULL,
    6082        meta_value longtext,
    6183        PRIMARY KEY  (meta_id),
     
    6385        KEY meta_key (meta_key($max_index_length))
    6486) $charset_collate;
    6587CREATE TABLE $wpdb->terms (
    66  term_id bigint(20) unsigned NOT NULL auto_increment,
     88 term_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
    6789 name varchar(200) NOT NULL default '',
    6890 slug varchar(200) NOT NULL default '',
    69  term_group bigint(10) NOT NULL default 0,
     91 term_group bigint{$term_group_display_width} NOT NULL default 0,
    7092 PRIMARY KEY  (term_id),
    7193 KEY slug (slug($max_index_length)),
    7294 KEY name (name($max_index_length))
    7395) $charset_collate;
    7496CREATE TABLE $wpdb->term_taxonomy (
    75  term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment,
    76  term_id bigint(20) unsigned NOT NULL default 0,
     97 term_taxonomy_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
     98 term_id bigint{$bigint_display_width} unsigned NOT NULL default 0,
    7799 taxonomy varchar(32) NOT NULL default '',
    78100 description longtext NOT NULL,
    79  parent bigint(20) unsigned NOT NULL default 0,
    80  count bigint(20) NOT NULL default 0,
     101 parent bigint{$bigint_display_width} unsigned NOT NULL default 0,
     102 count bigint{$bigint_display_width} NOT NULL default 0,
    81103 PRIMARY KEY  (term_taxonomy_id),
    82104 UNIQUE KEY term_id_taxonomy (term_id,taxonomy),
    83105 KEY taxonomy (taxonomy)
    84106) $charset_collate;
    85107CREATE TABLE $wpdb->term_relationships (
    86  object_id bigint(20) unsigned NOT NULL default 0,
    87  term_taxonomy_id bigint(20) unsigned NOT NULL default 0,
    88  term_order int(11) NOT NULL default 0,
     108 object_id bigint{$bigint_display_width} unsigned NOT NULL default 0,
     109 term_taxonomy_id bigint{$bigint_display_width} unsigned NOT NULL default 0,
     110 term_order int{$int_display_width} NOT NULL default 0,
    89111 PRIMARY KEY  (object_id,term_taxonomy_id),
    90112 KEY term_taxonomy_id (term_taxonomy_id)
    91113) $charset_collate;
    92114CREATE TABLE $wpdb->commentmeta (
    93         meta_id bigint(20) unsigned NOT NULL auto_increment,
    94         comment_id bigint(20) unsigned NOT NULL default '0',
     115        meta_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
     116        comment_id bigint{$bigint_display_width} unsigned NOT NULL default '0',
    95117        meta_key varchar(255) default NULL,
    96118        meta_value longtext,
    97119        PRIMARY KEY  (meta_id),
     
    99121        KEY meta_key (meta_key($max_index_length))
    100122) $charset_collate;
    101123CREATE TABLE $wpdb->comments (
    102         comment_ID bigint(20) unsigned NOT NULL auto_increment,
    103         comment_post_ID bigint(20) unsigned NOT NULL default '0',
     124        comment_ID bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
     125        comment_post_ID bigint{$bigint_display_width} unsigned NOT NULL default '0',
    104126        comment_author tinytext NOT NULL,
    105127        comment_author_email varchar(100) NOT NULL default '',
    106128        comment_author_url varchar(200) NOT NULL default '',
     
    108130        comment_date datetime NOT NULL default '0000-00-00 00:00:00',
    109131        comment_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
    110132        comment_content text NOT NULL,
    111         comment_karma int(11) NOT NULL default '0',
     133        comment_karma int{$int_display_width} NOT NULL default '0',
    112134        comment_approved varchar(20) NOT NULL default '1',
    113135        comment_agent varchar(255) NOT NULL default '',
    114136        comment_type varchar(20) NOT NULL default 'comment',
    115         comment_parent bigint(20) unsigned NOT NULL default '0',
    116         user_id bigint(20) unsigned NOT NULL default '0',
     137        comment_parent bigint{$bigint_display_width} unsigned NOT NULL default '0',
     138        user_id bigint{$bigint_display_width} unsigned NOT NULL default '0',
    117139        PRIMARY KEY  (comment_ID),
    118140        KEY comment_post_ID (comment_post_ID),
    119141        KEY comment_approved_date_gmt (comment_approved,comment_date_gmt),
     
    122144        KEY comment_author_email (comment_author_email(10))
    123145) $charset_collate;
    124146CREATE TABLE $wpdb->links (
    125         link_id bigint(20) unsigned NOT NULL auto_increment,
     147        link_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
    126148        link_url varchar(255) NOT NULL default '',
    127149        link_name varchar(255) NOT NULL default '',
    128150        link_image varchar(255) NOT NULL default '',
     
    129151        link_target varchar(25) NOT NULL default '',
    130152        link_description varchar(255) NOT NULL default '',
    131153        link_visible varchar(20) NOT NULL default 'Y',
    132         link_owner bigint(20) unsigned NOT NULL default '1',
    133         link_rating int(11) NOT NULL default '0',
     154        link_owner bigint{$bigint_display_width} unsigned NOT NULL default '1',
     155        link_rating int{$int_display_width} NOT NULL default '0',
    134156        link_updated datetime NOT NULL default '0000-00-00 00:00:00',
    135157        link_rel varchar(255) NOT NULL default '',
    136158        link_notes mediumtext NOT NULL,
     
    139161        KEY link_visible (link_visible)
    140162) $charset_collate;
    141163CREATE TABLE $wpdb->options (
    142         option_id bigint(20) unsigned NOT NULL auto_increment,
     164        option_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
    143165        option_name varchar(191) NOT NULL default '',
    144166        option_value longtext NOT NULL,
    145167        autoload varchar(20) NOT NULL default 'yes',
     
    148170        KEY autoload (autoload)
    149171) $charset_collate;
    150172CREATE TABLE $wpdb->postmeta (
    151         meta_id bigint(20) unsigned NOT NULL auto_increment,
    152         post_id bigint(20) unsigned NOT NULL default '0',
     173        meta_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
     174        post_id bigint{$bigint_display_width} unsigned NOT NULL default '0',
    153175        meta_key varchar(255) default NULL,
    154176        meta_value longtext,
    155177        PRIMARY KEY  (meta_id),
     
    157179        KEY meta_key (meta_key($max_index_length))
    158180) $charset_collate;
    159181CREATE TABLE $wpdb->posts (
    160         ID bigint(20) unsigned NOT NULL auto_increment,
    161         post_author bigint(20) unsigned NOT NULL default '0',
     182        ID bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
     183        post_author bigint{$bigint_display_width} unsigned NOT NULL default '0',
    162184        post_date datetime NOT NULL default '0000-00-00 00:00:00',
    163185        post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
    164186        post_content longtext NOT NULL,
     
    174196        post_modified datetime NOT NULL default '0000-00-00 00:00:00',
    175197        post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
    176198        post_content_filtered longtext NOT NULL,
    177         post_parent bigint(20) unsigned NOT NULL default '0',
     199        post_parent bigint{$bigint_display_width} unsigned NOT NULL default '0',
    178200        guid varchar(255) NOT NULL default '',
    179         menu_order int(11) NOT NULL default '0',
     201        menu_order int{$int_display_width} NOT NULL default '0',
    180202        post_type varchar(20) NOT NULL default 'post',
    181203        post_mime_type varchar(100) NOT NULL default '',
    182         comment_count bigint(20) NOT NULL default '0',
     204        comment_count bigint{$bigint_display_width} NOT NULL default '0',
    183205        PRIMARY KEY  (ID),
    184206        KEY post_name (post_name($max_index_length)),
    185207        KEY type_status_date (post_type,post_status,post_date,ID),
     
    189211
    190212        // Single site users table. The multisite flavor of the users table is handled below.
    191213        $users_single_table = "CREATE TABLE $wpdb->users (
    192         ID bigint(20) unsigned NOT NULL auto_increment,
     214        ID bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
    193215        user_login varchar(60) NOT NULL default '',
    194216        user_pass varchar(255) NOT NULL default '',
    195217        user_nicename varchar(50) NOT NULL default '',
     
    197219        user_url varchar(100) NOT NULL default '',
    198220        user_registered datetime NOT NULL default '0000-00-00 00:00:00',
    199221        user_activation_key varchar(255) NOT NULL default '',
    200         user_status int(11) NOT NULL default '0',
     222        user_status int{$int_display_width} NOT NULL default '0',
    201223        display_name varchar(250) NOT NULL default '',
    202224        PRIMARY KEY  (ID),
    203225        KEY user_login_key (user_login),
     
    207229
    208230        // Multisite users table.
    209231        $users_multi_table = "CREATE TABLE $wpdb->users (
    210         ID bigint(20) unsigned NOT NULL auto_increment,
     232        ID bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
    211233        user_login varchar(60) NOT NULL default '',
    212234        user_pass varchar(255) NOT NULL default '',
    213235        user_nicename varchar(50) NOT NULL default '',
     
    215237        user_url varchar(100) NOT NULL default '',
    216238        user_registered datetime NOT NULL default '0000-00-00 00:00:00',
    217239        user_activation_key varchar(255) NOT NULL default '',
    218         user_status int(11) NOT NULL default '0',
     240        user_status int{$int_display_width} NOT NULL default '0',
    219241        display_name varchar(250) NOT NULL default '',
    220242        spam tinyint(2) NOT NULL default '0',
    221243        deleted tinyint(2) NOT NULL default '0',
     
    227249
    228250        // Usermeta.
    229251        $usermeta_table = "CREATE TABLE $wpdb->usermeta (
    230         umeta_id bigint(20) unsigned NOT NULL auto_increment,
    231         user_id bigint(20) unsigned NOT NULL default '0',
     252        umeta_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
     253        user_id bigint{$bigint_display_width} unsigned NOT NULL default '0',
    232254        meta_key varchar(255) default NULL,
    233255        meta_value longtext,
    234256        PRIMARY KEY  (umeta_id),
     
    245267
    246268        // Multisite global tables.
    247269        $ms_global_tables = "CREATE TABLE $wpdb->blogs (
    248         blog_id bigint(20) NOT NULL auto_increment,
    249         site_id bigint(20) NOT NULL default '0',
     270        blog_id bigint{$bigint_display_width} NOT NULL auto_increment,
     271        site_id bigint{$bigint_display_width} NOT NULL default '0',
    250272        domain varchar(200) NOT NULL default '',
    251273        path varchar(100) NOT NULL default '',
    252274        registered datetime NOT NULL default '0000-00-00 00:00:00',
     
    256278        mature tinyint(2) NOT NULL default '0',
    257279        spam tinyint(2) NOT NULL default '0',
    258280        deleted tinyint(2) NOT NULL default '0',
    259         lang_id int(11) NOT NULL default '0',
     281        lang_id int{$int_display_width} NOT NULL default '0',
    260282        PRIMARY KEY  (blog_id),
    261283        KEY domain (domain(50),path(5)),
    262284        KEY lang_id (lang_id)
    263285) $charset_collate;
    264286CREATE TABLE $wpdb->blogmeta (
    265         meta_id bigint(20) unsigned NOT NULL auto_increment,
    266         blog_id bigint(20) NOT NULL default '0',
     287        meta_id bigint{$bigint_display_width} unsigned NOT NULL auto_increment,
     288        blog_id bigint{$bigint_display_width} NOT NULL default '0',
    267289        meta_key varchar(255) default NULL,
    268290        meta_value longtext,
    269291        PRIMARY KEY  (meta_id),
     
    271293        KEY blog_id (blog_id)
    272294) $charset_collate;
    273295CREATE TABLE $wpdb->registration_log (
    274         ID bigint(20) NOT NULL auto_increment,
     296        ID bigint{$bigint_display_width} NOT NULL auto_increment,
    275297        email varchar(255) NOT NULL default '',
    276298        IP varchar(30) NOT NULL default '',
    277         blog_id bigint(20) NOT NULL default '0',
     299        blog_id bigint{$bigint_display_width} NOT NULL default '0',
    278300        date_registered datetime NOT NULL default '0000-00-00 00:00:00',
    279301        PRIMARY KEY  (ID),
    280302        KEY IP (IP)
    281303) $charset_collate;
    282304CREATE TABLE $wpdb->site (
    283         id bigint(20) NOT NULL auto_increment,
     305        id bigint{$bigint_display_width} NOT NULL auto_increment,
    284306        domain varchar(200) NOT NULL default '',
    285307        path varchar(100) NOT NULL default '',
    286308        PRIMARY KEY  (id),
     
    287309        KEY domain (domain(140),path(51))
    288310) $charset_collate;
    289311CREATE TABLE $wpdb->sitemeta (
    290         meta_id bigint(20) NOT NULL auto_increment,
    291         site_id bigint(20) NOT NULL default '0',
     312        meta_id bigint{$bigint_display_width} NOT NULL auto_increment,
     313        site_id bigint{$bigint_display_width} NOT NULL default '0',
    292314        meta_key varchar(255) default NULL,
    293315        meta_value longtext,
    294316        PRIMARY KEY  (meta_id),
     
    296318        KEY site_id (site_id)
    297319) $charset_collate;
    298320CREATE TABLE $wpdb->signups (
    299         signup_id bigint(20) NOT NULL auto_increment,
     321        signup_id bigint{$bigint_display_width} NOT NULL auto_increment,
    300322        domain varchar(200) NOT NULL default '',
    301323        path varchar(100) NOT NULL default '',
    302324        title longtext NOT NULL,
  • tests/phpunit/tests/dbdelta.php

     
    705705        /**
    706706         * @ticket 20263
    707707         */
    708         function test_wp_get_db_schema_does_no_alter_queries_on_existing_install() {
     708        function test_wp_get_db_schema_does_not_alter_queries_on_existing_install() {
    709709                $updates = dbDelta( wp_get_db_schema() );
    710710
    711711                $this->assertEmpty( $updates );