Make WordPress Core


Ignore:
Timestamp:
04/11/2015 10:39:49 AM (11 years ago)
Author:
pento
Message:

When dbDelta() is checking whether an index is defined in a CREATE TABLE statement, don't worry if MySQL has a subpart defined on an index, but the CREATE TABLE doesn't.

Fixes #31869.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/upgrade.php

    r32027 r32108  
    19811981                                        }
    19821982                                }
     1983
     1984                                // The alternative index string doesn't care about subparts
     1985                                $alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns );
     1986
    19831987                                // Add the column list to the index create string.
    1984                                 $index_string .= ' ('.$index_columns.')';
    1985                                 if (!(($aindex = array_search($index_string, $indices)) === false)) {
    1986                                         unset($indices[$aindex]);
    1987                                         // todo: Remove this?
    1988                                         //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
     1988                                $index_strings = array(
     1989                                        "$index_string ($index_columns)",
     1990                                        "$index_string ($alt_index_columns)",
     1991                                );
     1992
     1993                                foreach( $index_strings as $index_string ) {
     1994                                        if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) {
     1995                                                unset( $indices[ $aindex ] );
     1996                                                break;
     1997                                                // todo: Remove this?
     1998                                                //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
     1999                                        }
    19892000                                }
    19902001                                // todo: Remove this?
Note: See TracChangeset for help on using the changeset viewer.