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.


Built from https://develop.svn.wordpress.org/trunk@32108


git-svn-id: http://core.svn.wordpress.org/trunk@32087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2015-04-11 10:40:31 +00:00
parent acef02f060
commit 0179958273
2 changed files with 17 additions and 6 deletions

View File

@ -1980,13 +1980,24 @@ function dbDelta( $queries = '', $execute = true ) {
$index_columns .= '('.$column_data['subpart'].')';
}
}
// The alternative index string doesn't care about subparts
$alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns );
// Add the column list to the index create string.
$index_string .= ' ('.$index_columns.')';
$index_strings = array(
"$index_string ($index_columns)",
"$index_string ($alt_index_columns)",
);
foreach( $index_strings as $index_string ) {
if ( ! ( ( $aindex = array_search( $index_string, $indices ) ) === false ) ) {
unset( $indices[ $aindex ] );
break;
// todo: Remove this?
//echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";
}
}
// todo: Remove this?
//else echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br /><b>Did not find index:</b>".$index_string."<br />".print_r($indices, true)."</pre>\n";
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta4-32107';
$wp_version = '4.2-beta4-32108';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.