Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#26102 closed defect (bug) (fixed)

$wpdb error suppression should always inherit previous value when being toggled

Reported by: wonderboymusic's profile wonderboymusic Owned by: wonderboymusic's profile wonderboymusic
Milestone: 3.8 Priority: normal
Severity: normal Version: 2.5
Component: Database Keywords: has-patch
Focuses: Cc:

Description

There are some places in core that explicitly set $wpdb->suppress_errors to false via the $wpdb->suppress_errors() method. Other places handle this correctly:

$suppress = $wpdb->suppress_errors();
code_that_might_blow_up();
$wpdb->suppress_errors( $suppress );

Perfect example of why this matters: multisite unit tests will explode if database errors are output. Even if $wpdb->suppress_errors() is called in setUp or in individual tests, install_blog() is overriding this value by setting it to false after it itself suppresses the errors.

Attachments (1)

26102.diff (4.7 KB) - added by wonderboymusic 11 years ago.

Download all attachments as: .zip

Change History (2)

#1 @wonderboymusic
11 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 26252:

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.

Note: See TracTickets for help on using tickets.