Make WordPress Core

Ticket #36919: 36919.patch

File 36919.patch, 3.5 KB (added by ocean90, 9 years ago)
  • src/wp-admin/includes/upgrade.php

     
    22162216
    22172217                // For every field in the table.
    22182218                foreach ($tablefields as $tablefield) {
     2219                        $tablefield_field_lowercased = strtolower( $tablefield->Field );
     2220                        $tablefield_type_lowercased = strtolower( $tablefield->Type );
    22192221
    22202222                        // If the table field exists in the field array ...
    2221                         if (array_key_exists(strtolower($tablefield->Field), $cfields)) {
     2223                        if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) {
    22222224
    22232225                                // Get the field type from the query.
    2224                                 preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches);
     2226                                preg_match("|".$tablefield->Field." ([^ ]*( unsigned)?)|i", $cfields[ $tablefield_field_lowercased ], $matches);
    22252227                                $fieldtype = $matches[1];
     2228                                $fieldtype_lowercased = strtolower( $fieldtype );
    22262229
    22272230                                // Is actual field type different from the field type in query?
    22282231                                if ($tablefield->Type != $fieldtype) {
    22292232                                        $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 ) ) {
     2233                                        if ( in_array( $fieldtype_lowercased, $text_fields ) && in_array( $tablefield_type_lowercased, $text_fields ) ) {
     2234                                                if ( array_search( $fieldtype_lowercased, $text_fields ) < array_search( $tablefield_type_lowercased, $text_fields ) ) {
    22322235                                                        $do_change = false;
    22332236                                                }
    22342237                                        }
    22352238
    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 ) ) {
     2239                                        if ( in_array( $fieldtype_lowercased, $blob_fields ) && in_array( $tablefield_type_lowercased, $blob_fields ) ) {
     2240                                                if ( array_search( $fieldtype_lowercased, $blob_fields ) < array_search( $tablefield_type_lowercased, $blob_fields ) ) {
    22382241                                                        $do_change = false;
    22392242                                                }
    22402243                                        }
    22412244
    22422245                                        if ( $do_change ) {
    22432246                                        // Add a query to change the column type
    2244                                                 $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[strtolower($tablefield->Field)];
     2247                                                $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN {$tablefield->Field} " . $cfields[ $tablefield_field_lowercased ];
    22452248                                                $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
    22462249                                        }
    22472250                                }
    22482251
    22492252                                // Get the default value from the array
    2250                                         // todo: Remove this?
    2251                                         //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
    2252                                 if (preg_match("| DEFAULT '(.*?)'|i", $cfields[strtolower($tablefield->Field)], $matches)) {
     2253                                if ( preg_match("| DEFAULT '(.*?)'|i", $cfields[ $tablefield_field_lowercased ], $matches ) ) {
    22532254                                        $default_value = $matches[1];
    22542255                                        if ($tablefield->Default != $default_value) {
    22552256                                                // Add a query to change the column's default value
     
    22592260                                }
    22602261
    22612262                                // Remove the field from the array (so it's not added).
    2262                                 unset($cfields[strtolower($tablefield->Field)]);
     2263                                unset( $cfields[ $tablefield_field_lowercased ] );
    22632264                        } else {
    22642265                                // This field exists in the table, but not in the creation queries?
    22652266                        }