Make WordPress Core

Changeset 41700


Ignore:
Timestamp:
10/03/2017 04:39:08 AM (7 years ago)
Author:
jeremyfelt
Message:

Multisite: Use %s when building query for archived sites in WP_Site_Query.

In [25548], the archived column in wp_blogs was changed from ENUM to TINYINT to match other status fields. When WP_Site_Query was written later, it used %d as a placeholder when formatting the archived status.

It is possible that this query will fail for any installations that did not update the schema for wp_blogs as only single quoted values are accepted for the ENUM type. In this case, '0' or '1' rather than 0 or 1.

We can work around this and support both ENUM and TINYINT in the query by using the %s placeholder and casting the value with absint().

Props stephdau.
Fixes #38856. See #27832.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-site-query.php

    r41686 r41700  
    448448        if ( is_numeric( $this->query_vars['archived'] ) ) {
    449449            $archived = absint( $this->query_vars['archived'] );
    450             $this->sql_clauses['where']['archived'] = $wpdb->prepare( "archived = %d ", $archived );
     450            $this->sql_clauses['where']['archived'] = $wpdb->prepare( "archived = %s ", absint( $archived ) );
    451451        }
    452452
Note: See TracChangeset for help on using the changeset viewer.