Ticket #34872: 34872.patch
File 34872.patch, 2.9 KB (added by , 9 years ago) |
---|
-
tests/phpunit/tests/dbdelta.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
274 274 $this->assertEmpty( $updates ); 275 275 } 276 276 277 /** 278 * @ticket 34872 279 * 280 * @dataProvider data_provider_schema_indexes 281 * 282 * @param string $schema The table schema. 283 */ 284 public function test_no_duplicate_indexes( $schema ) { 285 286 // Run once to create the table and indexes. 287 $updates = dbDelta( $schema ); 288 289 $this->assertCount( 1, $updates ); 290 $this->assertEquals( 291 array( 'wptests_dbdelta_test_2' => 'Created table wptests_dbdelta_test_2' ) 292 , $updates 293 ); 294 295 // Run again. Nothing should happen. 296 $updates = dbDelta( $schema ); 297 298 $this->assertSame( array(), $updates ); 299 } 300 301 /** 302 * Provides sets of table schemas to test index detection. 303 * 304 * @return array 305 */ 306 public function data_provider_schema_indexes() { 307 308 global $wpdb; 309 310 return array( 311 'named' => array( 312 "CREATE TABLE {$wpdb->prefix}dbdelta_test_2 ( 313 id bigint(20) NOT NULL AUTO_INCREMENT, 314 KEY id (id) 315 )" 316 ), 317 'unnamed' => array( 318 "CREATE TABLE {$wpdb->prefix}dbdelta_test_2 ( 319 id bigint(20) NOT NULL AUTO_INCREMENT, 320 KEY (id) 321 )" 322 ), 323 'primary' => array( 324 "CREATE TABLE {$wpdb->prefix}dbdelta_test_2 ( 325 id bigint(20) NOT NULL AUTO_INCREMENT, 326 PRIMARY KEY (id) 327 )" 328 ), 329 'primary_extra_space' => array( 330 "CREATE TABLE {$wpdb->prefix}dbdelta_test_2 ( 331 id bigint(20) NOT NULL AUTO_INCREMENT, 332 PRIMARY KEY (id) 333 )" 334 ), 335 ); 336 } 337 277 338 // 278 339 // Assertions. 279 340 // -
src/wp-admin/includes/upgrade.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
2256 2256 if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) { 2257 2257 $index_string .= 'FULLTEXT '; 2258 2258 } 2259 $index_string .= 'KEY '; 2260 if ($index_name != 'PRIMARY') { 2261 $index_string .= $index_name; 2262 } 2259 $index_string .= 'KEY'; 2260 2263 2261 $index_columns = ''; 2264 2262 2265 2263 // For each column in the index. … … 2277 2275 $alt_index_columns = preg_replace( '/\([^)]*\)/', '', $index_columns ); 2278 2276 2279 2277 // Add the column list to the index create string. 2278 if ( 'PRIMARY' === $index_name ) { 2279 $index_name = ''; 2280 } 2281 2280 2282 $index_strings = array( 2281 2283 "$index_string ($index_columns)", 2282 2284 "$index_string ($alt_index_columns)", 2285 "$index_string $index_name ($index_columns)", 2286 "$index_string $index_name ($alt_index_columns)", 2283 2287 ); 2284 2288 2285 2289 foreach ( $index_strings as $index_string ) {