Ticket #17998: 17998.3.diff
File 17998.3.diff, 2.2 KB (added by , 13 years ago) |
---|
-
wp-admin/includes/upgrade.php
1459 1459 $cqueries = apply_filters( 'dbdelta_create_queries', $cqueries ); 1460 1460 $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries ); 1461 1461 1462 // Check to see which tables and fields exist1463 if ($tables = $wpdb->get_col('SHOW TABLES;')) {1464 // For every table in the database1465 1462 $global_tables = $wpdb->tables( 'global' ); 1466 foreach ( $tables as $table) {1463 foreach ( $cqueries as $table => $qry ) { 1467 1464 // Upgrade global tables only for the main site. Don't upgrade at all if DO_NOT_UPGRADE_GLOBAL_TABLES is defined. 1468 1465 if ( in_array( $table, $global_tables ) && ( !is_main_site() || defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) ) 1469 1466 continue; 1470 1467 1471 // If a table query exists for the database table... 1472 if ( array_key_exists(strtolower($table), $cqueries) ) { 1468 // Fetch the table column structure from the database 1469 $wpdb->suppress_errors(); 1470 $tablefields = $wpdb->get_results("DESCRIBE {$table};"); 1471 $wpdb->suppress_errors( false ); 1472 1473 if ( ! $tablefields ) 1474 continue; 1475 1473 1476 // Clear the field and index arrays 1474 1477 $cfields = $indices = array(); 1475 1478 // Get all of the field names in the query from between the parens 1476 preg_match("|\((.*)\)|ms", $ cqueries[strtolower($table)], $match2);1479 preg_match("|\((.*)\)|ms", $qry, $match2); 1477 1480 $qryline = trim($match2[1]); 1478 1481 1479 1482 // Separate field lines into an array … … 1508 1511 } 1509 1512 } 1510 1513 1511 // Fetch the table column structure from the database1512 $tablefields = $wpdb->get_results("DESCRIBE {$table};");1513 1514 1514 // For every field in the table 1515 1515 foreach ($tablefields as $tablefield) { 1516 1516 // If the table field exists in the field array... … … 1608 1608 } 1609 1609 1610 1610 // Remove the original table creation query from processing 1611 unset($cqueries[strtolower($table)]); 1612 unset($for_update[strtolower($table)]); 1613 } else { 1614 // This table exists in the database, but not in the creation queries? 1615 } 1611 unset( $cqueries[ $table ], $for_update[ $table ] ); 1616 1612 } 1617 }1618 1613 1619 1614 $allqueries = array_merge($cqueries, $iqueries); 1620 1615 if ($execute) {