diff --git wp-admin/includes/upgrade.php wp-admin/includes/upgrade.php
index d4c0097..8efbc9c 100644
|
|
function dbDelta( $queries = '', $execute = true ) { |
2168 | 2168 | continue; |
2169 | 2169 | |
2170 | 2170 | // Clear the field and index arrays. |
2171 | | $cfields = $indices = array(); |
| 2171 | $cfields = $indices = $change_indices = array(); |
2172 | 2172 | |
2173 | 2173 | // Get all of the field names in the query from between the parentheses. |
2174 | 2174 | preg_match("|\((.*)\)|ms", $qry, $match2); |
… |
… |
function dbDelta( $queries = '', $execute = true ) { |
2307 | 2307 | "$index_string ($alt_index_columns)", |
2308 | 2308 | ); |
2309 | 2309 | |
| 2310 | // Find the index key so we know what already exists and needs to be dropped first. |
| 2311 | if ( preg_match( "/KEY ([^ ]*)/", $index_string, $matches ) || preg_match( "/INDEX ([^ ]*)/", $index_string, $matches ) ) { |
| 2312 | if ( ! empty( $matches[1] ) ) { |
| 2313 | foreach ( $indices as $key => $value ) { |
| 2314 | if ( false !== stripos( $value, 'KEY ' . $matches[1] . ' ' ) || false !== stripos( $value, 'INDEX ' . $matches[1] . ' ' ) ) { |
| 2315 | |
| 2316 | // We found an existing key, but need to determine if the index actually is changing. |
| 2317 | if ( ! in_array( $value, $index_strings ) ) { |
| 2318 | // If we reach this point, an existing index exists and is changing. |
| 2319 | $change_indices[ $matches[1] ] = $value; |
| 2320 | } |
| 2321 | |
| 2322 | unset( $indices[ $key ] ); |
| 2323 | break; |
| 2324 | } |
| 2325 | } |
| 2326 | } |
| 2327 | } |
| 2328 | |
2310 | 2329 | foreach ( $index_strings as $index_string ) { |
2311 | 2330 | if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) { |
2312 | 2331 | unset( $indices[ $aindex ] ); |
… |
… |
function dbDelta( $queries = '', $execute = true ) { |
2320 | 2339 | } |
2321 | 2340 | } |
2322 | 2341 | |
| 2342 | /** |
| 2343 | * Handle indexes that are changing. |
| 2344 | */ |
| 2345 | foreach ( $change_indices as $existing_index => $index ) { |
| 2346 | $cqueries[] = "ALTER TABLE {$table} DROP INDEX $existing_index, ADD $index"; |
| 2347 | $for_update[] = 'Changed index ' . $table . ' ' . $existing_index . ' to ' . $index; |
| 2348 | } |
| 2349 | |
2323 | 2350 | // For every remaining index specified for the table. |
2324 | 2351 | foreach ( (array) $indices as $index ) { |
2325 | 2352 | // Push a query line into $cqueries that adds the index to that table. |