Changeset 53897 for trunk/src/wp-admin/includes/upgrade.php
- Timestamp:
- 08/15/2022 01:16:22 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/upgrade.php
r53896 r53897 2714 2714 * 2715 2715 * @since 1.5.0 2716 * @since 6.1.0 Ignores display width for integer data types on MySQL 8.0.17 or later, 2717 * to match MySQL behavior. Note: This does not affect MariaDB. 2716 2718 * 2717 2719 * @global wpdb $wpdb WordPress database abstraction object. … … 2790 2792 $text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' ); 2791 2793 $blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' ); 2792 2793 $global_tables = $wpdb->tables( 'global' ); 2794 $int_fields = array( 'tinyint', 'smallint', 'mediumint', 'int', 'integer', 'bigint' ); 2795 2796 $global_tables = $wpdb->tables( 'global' ); 2797 $db_version = $wpdb->db_version(); 2798 $db_server_info = $wpdb->db_server_info(); 2799 2794 2800 foreach ( $cqueries as $table => $qry ) { 2795 2801 // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal. … … 2949 2955 $tablefield_type_lowercased = strtolower( $tablefield->Type ); 2950 2956 2957 $tablefield_type_without_parentheses = preg_replace( 2958 '/' 2959 . '(.+)' // Field type, e.g. `int`. 2960 . '\(\d*\)' // Display width. 2961 . '(.*)' // Optional attributes, e.g. `unsigned`. 2962 . '/', 2963 '$1$2', 2964 $tablefield_type_lowercased 2965 ); 2966 2967 // Get the type without attributes, e.g. `int`. 2968 $tablefield_type_base = strtok( $tablefield_type_without_parentheses, ' ' ); 2969 2951 2970 // If the table field exists in the field array... 2952 2971 if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) { … … 2956 2975 $fieldtype = $matches[1]; 2957 2976 $fieldtype_lowercased = strtolower( $fieldtype ); 2977 2978 $fieldtype_without_parentheses = preg_replace( 2979 '/' 2980 . '(.+)' // Field type, e.g. `int`. 2981 . '\(\d*\)' // Display width. 2982 . '(.*)' // Optional attributes, e.g. `unsigned`. 2983 . '/', 2984 '$1$2', 2985 $fieldtype_lowercased 2986 ); 2987 2988 // Get the type without attributes, e.g. `int`. 2989 $fieldtype_base = strtok( $fieldtype_without_parentheses, ' ' ); 2958 2990 2959 2991 // Is actual field type different from the field type in query? … … 2968 3000 if ( in_array( $fieldtype_lowercased, $blob_fields, true ) && in_array( $tablefield_type_lowercased, $blob_fields, true ) ) { 2969 3001 if ( array_search( $fieldtype_lowercased, $blob_fields, true ) < array_search( $tablefield_type_lowercased, $blob_fields, true ) ) { 3002 $do_change = false; 3003 } 3004 } 3005 3006 if ( in_array( $fieldtype_base, $int_fields, true ) && in_array( $tablefield_type_base, $int_fields, true ) 3007 && $fieldtype_without_parentheses === $tablefield_type_without_parentheses 3008 ) { 3009 /* 3010 * MySQL 8.0.17 or later does not support display width for integer data types, 3011 * so if display width is the only difference, it can be safely ignored. 3012 * Note: This is specific to MySQL and does not affect MariaDB. 3013 */ 3014 if ( version_compare( $db_version, '8.0.17', '>=' ) 3015 && ! str_contains( $db_server_info, 'MariaDB' ) 3016 ) { 2970 3017 $do_change = false; 2971 3018 }
Note: See TracChangeset
for help on using the changeset viewer.