[wp-trac] [WordPress Trac] #22791: dbDelta triggers create table for existing tables when using multisite upgrade
WordPress Trac
noreply at wordpress.org
Thu Dec 6 14:18:34 UTC 2012
#22791: dbDelta triggers create table for existing tables when using multisite
upgrade
-----------------------------+-----------------------------
Reporter: fliespl | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: Upgrade/Install
Version: | Severity: minor
Keywords: has-patch |
-----------------------------+-----------------------------
If you are using multisite and upgrade is run on the database, it will try
to create global tables for each multisite blog (triggering errors).
It's because of the line: 1533-1534 in wp-admin/includes/upgrade.php
{{{
if ( in_array( $table, $global_tables ) && (
!is_main_site() || defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) )
continue;
}}}
Since you put continue, "create table" will never be "unset" in the line
1679, because it had already left the loop:
{{{
unset( $cqueries[ $table ], $for_update[ $table ] );
}}}
Proposed fix:
change lines 1533-1534 from:
{{{
if ( in_array( $table, $global_tables ) && (
!is_main_site() || defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) )
continue;
}}}
to:
{{{
if ( in_array( $table, $global_tables ) && (
!is_main_site() || defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) ) {
$wpdb->suppress_errors();
$tablefields = $wpdb->get_results("DESCRIBE
{$table};");
$wpdb->suppress_errors( false );
if ( $tablefields )
unset( $cqueries[ $table ], $for_update[
$table ] );
continue;
}
}}}
This way, if global tables don't exist they will remain in $cqueries, but
if they exist, they will be unset from creation.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22791>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list