WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/12/2016 05:08:17 AM (3 years ago)
Author:
pento
Message:

Database: Normalise index names in dbDelta().

When comparing index definitions, normalise the index names to lower case, as they are not case sensitive within MySQL.

Fixes #34874.

File:
1 edited

Legend:

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

    r38109 r38591  
    22842284
    22852285                    // Escape the index name with backticks. An index for a primary key has no name.
    2286                     $index_name = ( 'PRIMARY KEY' === $index_type ) ? '' : '`' . $index_matches['index_name'] . '`';
     2286                    $index_name = ( 'PRIMARY KEY' === $index_type ) ? '' : '`' . strtolower( $index_matches['index_name'] ) . '`';
    22872287
    22882288                    // Parse the columns. Multiple columns are separated by a comma.
     
    24082408
    24092409                // Add the index to the index data array.
    2410                 $keyname = $tableindex->Key_name;
     2410                $keyname = strtolower( $tableindex->Key_name );
    24112411                $index_ary[$keyname]['columns'][] = array('fieldname' => $tableindex->Column_name, 'subpart' => $tableindex->Sub_part);
    24122412                $index_ary[$keyname]['unique'] = ($tableindex->Non_unique == 0)?true:false;
     
    24192419                // Build a create string to compare to the query.
    24202420                $index_string = '';
    2421                 if ($index_name == 'PRIMARY') {
     2421                if ($index_name == 'primary') {
    24222422                    $index_string .= 'PRIMARY ';
    24232423                } elseif ( $index_data['unique'] ) {
     
    24312431                }
    24322432                $index_string .= 'KEY ';
    2433                 if ( 'PRIMARY' !== $index_name  ) {
     2433                if ( 'primary' !== $index_name  ) {
    24342434                    $index_string .= '`' . $index_name . '`';
    24352435                }
Note: See TracChangeset for help on using the changeset viewer.