From da05f7435b2bdb1635d14e670292194664da0c45 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 18 Nov 2013 20:45:11 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@26252 git-svn-id: http://core.svn.wordpress.org/trunk@26158 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 4 ++-- wp-includes/ms-functions.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 54c282c0fe..bd250ae2c2 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -1553,9 +1553,9 @@ function dbDelta( $queries = '', $execute = true ) { continue; // Fetch the table column structure from the database - $wpdb->suppress_errors(); + $suppress = $wpdb->suppress_errors(); $tablefields = $wpdb->get_results("DESCRIBE {$table};"); - $wpdb->suppress_errors( false ); + $wpdb->suppress_errors( $suppress ); if ( ! $tablefields ) continue; diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 1e15684b4c..5a1d20df7d 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -1129,10 +1129,10 @@ function install_blog( $blog_id, $blog_title = '' ) { require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); - $wpdb->suppress_errors(); + $suppress = $wpdb->suppress_errors(); if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) die( '

' . __( 'Already Installed' ) . '

' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '

' ); - $wpdb->suppress_errors( false ); + $wpdb->suppress_errors( $suppress ); $url = get_blogaddress_by_id( $blog_id ); @@ -1179,11 +1179,11 @@ function install_blog_defaults($blog_id, $user_id) { require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); - $wpdb->suppress_errors(); + $suppress = $wpdb->suppress_errors(); wp_install_defaults($user_id); - $wpdb->suppress_errors( false ); + $wpdb->suppress_errors( $suppress ); } /**