~canonical-sysadmins/wordpress/4.7

« back to all changes in this revision

Viewing changes to wp-admin/includes/upgrade.php

  • Committer: Barry Price
  • Date: 2016-06-22 02:23:41 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: barry.price@canonical.com-20160622022341-9qrp2nesacwfx017
Merge WP4.5.3 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
2154
2154
         */
2155
2155
        $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries );
2156
2156
 
 
2157
        $text_fields = array( 'tinytext', 'text', 'mediumtext', 'longtext' );
 
2158
        $blob_fields = array( 'tinyblob', 'blob', 'mediumblob', 'longblob' );
 
2159
 
2157
2160
        $global_tables = $wpdb->tables( 'global' );
2158
2161
        foreach ( $cqueries as $table => $qry ) {
2159
2162
                // Upgrade global tables only for the main site. Don't upgrade at all if conditions are not optimal.
2223
2226
 
2224
2227
                                // Is actual field type different from the field type in query?
2225
2228
                                if ($tablefield->Type != $fieldtype) {
 
2229
                                        $do_change = true;
 
2230
                                        if ( in_array( strtolower( $fieldtype ), $text_fields ) && in_array( strtolower( $tablefield->Type ), $text_fields ) ) {
 
2231
                                                if ( array_search( strtolower( $fieldtype ), $text_fields ) < array_search( strtolower( $tablefield->Type ), $text_fields ) ) {
 
2232
                                                        $do_change = false;
 
2233
                                                }
 
2234
                                        }
 
2235
 
 
2236
                                        if ( in_array( strtolower( $fieldtype ), $blob_fields ) && in_array( strtolower( $tablefield->Type ), $blob_fields ) ) {
 
2237
                                                if ( array_search( strtolower( $fieldtype ), $blob_fields ) < array_search( strtolower( $tablefield->Type ), $blob_fields ) ) {
 
2238
                                                        $do_change = false;
 
2239
                                                }
 
2240
                                        }
 
2241
 
 
2242
                                        if ( $do_change ) {
2226
2243
                                        // Add a query to change the column type
2227
 
                                        $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
2228
 
                                        $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
 
2244
                                                $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
 
2245
                                                $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
 
2246
                                        }
2229
2247
                                }
2230
2248
 
2231
2249
                                // Get the default value from the array