Make WordPress Core


Ignore:
Timestamp:
11/18/2013 08:44:34 PM (12 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/tests/phpunit/includes/factory.php

    r25660 r26252  
    160160
    161161    function create_object( $args ) {
     162        global $wpdb;
    162163        $meta = isset( $args['meta'] ) ? $args['meta'] : array();
    163164        $user_id = isset( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
    164         return wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] );
     165        // temp tables will trigger db errors when we attempt to reference them as new temp tables
     166        $suppress = $wpdb->suppress_errors();
     167        $blog = wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] );
     168        $wpdb->suppress_errors( $suppress );
     169        return $blog;
    165170    }
    166171
Note: See TracChangeset for help on using the changeset viewer.