Make WordPress Core


Ignore:
Timestamp:
11/18/2013 08:44:34 PM (11 years ago)
Author:
wonderboymusic
Message:

For unit tests that call wpmu_create_blog(), Blog factory, or installation code that attempts to clear transients: suppress database errors on setUp and restore on tearDown.

There are a few places in core that were preventing this from working by explicity setting $wpdb->suppress_errors to false. Instead, they should inherit the value that existed before errors were suppressed.

This allows Multisite unit tests to run without explosive database errors, and allows $wpdb->suppress_errors to be overridden all the way down the chain.

Fixes #26102.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r26120 r26252  
    11301130    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    11311131
    1132     $wpdb->suppress_errors();
     1132    $suppress = $wpdb->suppress_errors();
    11331133    if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) )
    11341134        die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
    1135     $wpdb->suppress_errors( false );
     1135    $wpdb->suppress_errors( $suppress );
    11361136
    11371137    $url = get_blogaddress_by_id( $blog_id );
     
    11801180    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    11811181
    1182     $wpdb->suppress_errors();
     1182    $suppress = $wpdb->suppress_errors();
    11831183
    11841184    wp_install_defaults($user_id);
    11851185
    1186     $wpdb->suppress_errors( false );
     1186    $wpdb->suppress_errors( $suppress );
    11871187}
    11881188
Note: See TracChangeset for help on using the changeset viewer.