Ticket #10404: dbDelta_match_extra_spacing.diff
File dbDelta_match_extra_spacing.diff, 2.1 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/upgrade.php
1450 1450 } 1451 1451 1452 1452 /** 1453 * Unify index line, to perform unique cross-matches 1454 * 1455 * Remove extra whitespaces, replace 'INDEX' for 'KEY'. 1456 * 1457 * @param string $input Index options line 1458 * 1459 * @return string Unified index options line 1460 */ 1461 function dbDelta_unifyIndexLine( $input ) { 1462 $input = trim( $input ); 1463 $input = trim( $input, ", \n" ); 1464 $input = preg_replace( '#\s+#', ' ', $input ); 1465 $input = preg_replace( '#\s+\(\s*(\d+)\s*\)#', '(\1)', $input ); 1466 $input = preg_replace( '#([^\s])\s*,\s*([^\s])#', '\1,\2', $input ); 1467 $input = preg_replace( '#^INDEX\s+#', 'KEY ', $input ); 1468 return $input; 1469 } 1470 1471 /** 1453 1472 * {@internal Missing Short Description}} 1454 1473 * 1455 1474 * {@internal Missing Long Description}} … … 1536 1555 case 'unique': 1537 1556 case 'key': 1538 1557 $validfield = false; 1539 $indices[] = trim(trim($fld), ", \n");1558 $indices[] = dbDelta_unifyIndexLine( $fld ); 1540 1559 break; 1541 1560 } 1542 1561 $fld = trim($fld); … … 1552 1571 // If the table field exists in the field array... 1553 1572 if (array_key_exists(strtolower($tablefield->Field), $cfields)) { 1554 1573 // Get the field type from the query 1555 preg_match("|".$tablefield->Field." 1574 preg_match("|".$tablefield->Field."\s+([^ ]*( unsigned)?)|i", $cfields[strtolower($tablefield->Field)], $matches); 1556 1575 $fieldtype = $matches[1]; 1557 1576 1558 1577 // Is actual field type different from the field type in query? … … 1628 1647 } 1629 1648 // Add the column list to the index create string 1630 1649 $index_string .= ' ('.$index_columns.')'; 1650 $index_string = dbDelta_unifyIndexLine( $index_string ); 1631 1651 if (!(($aindex = array_search($index_string, $indices)) === false)) { 1632 1652 unset($indices[$aindex]); 1633 1653 //echo "<pre style=\"border:1px solid #ccc;margin-top:5px;\">{$table}:<br />Found index:".$index_string."</pre>\n";