Ticket #36919: 36919.patch
File 36919.patch, 3.5 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/upgrade.php
2216 2216 2217 2217 // For every field in the table. 2218 2218 foreach ($tablefields as $tablefield) { 2219 $tablefield_field_lowercased = strtolower( $tablefield->Field ); 2220 $tablefield_type_lowercased = strtolower( $tablefield->Type ); 2219 2221 2220 2222 // 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 ) ) { 2222 2224 2223 2225 // 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); 2225 2227 $fieldtype = $matches[1]; 2228 $fieldtype_lowercased = strtolower( $fieldtype ); 2226 2229 2227 2230 // Is actual field type different from the field type in query? 2228 2231 if ($tablefield->Type != $fieldtype) { 2229 2232 $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 ) ) { 2232 2235 $do_change = false; 2233 2236 } 2234 2237 } 2235 2238 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 ) ) { 2238 2241 $do_change = false; 2239 2242 } 2240 2243 } 2241 2244 2242 2245 if ( $do_change ) { 2243 2246 // 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 ]; 2245 2248 $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; 2246 2249 } 2247 2250 } 2248 2251 2249 2252 // 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 ) ) { 2253 2254 $default_value = $matches[1]; 2254 2255 if ($tablefield->Default != $default_value) { 2255 2256 // Add a query to change the column's default value … … 2259 2260 } 2260 2261 2261 2262 // Remove the field from the array (so it's not added). 2262 unset( $cfields[strtolower($tablefield->Field)]);2263 unset( $cfields[ $tablefield_field_lowercased ] ); 2263 2264 } else { 2264 2265 // This field exists in the table, but not in the creation queries? 2265 2266 }