Making WordPress.org

Changeset 3332


Ignore:
Timestamp:
06/11/2016 08:46:03 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Fix a bug where plugin names in count query were escaped.

Introduced in [3329].

See #1571.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php

    r3330 r3332  
    381381        }
    382382
    383         if ( empty( $plugins ) ) {
    384             $user_post_count = intval( $wpdb->get_var( $wpdb->prepare( "
    385                 SELECT COUNT( 1 )
    386                 FROM $wpdb->posts
    387                 WHERE post_type = %s
    388                 AND post_author = %d
    389             ", $post_type, $current_user_id ) ) );
    390 
    391         } else {
    392             $user_post_count = intval( $wpdb->get_var( ($wpdb->prepare( "
    393                 SELECT COUNT( 1 )
    394                 FROM $wpdb->posts
    395                 WHERE post_type = %s
    396                 AND ( post_author = %d OR post_name IN ( %s ) )
    397             ", $post_type, $current_user_id, implode( ', ', $plugins ) ) ) ) );
    398         }
     383        $user_post_count_query = "
     384            SELECT COUNT( 1 )
     385            FROM $wpdb->posts
     386            WHERE post_type = %s
     387            AND post_author = %d
     388        ";
     389
     390        if ( ! empty( $plugins ) ) {
     391            $user_post_count_query = str_replace('AND post_author = %d', "AND ( post_author = %d OR post_name IN ( '" . implode( "','", $plugins ) . "' ) )", $user_post_count_query );
     392        }
     393
     394        $user_post_count = intval( $wpdb->get_var( $wpdb->prepare( $user_post_count_query, $post_type, $current_user_id ) ) );
    399395
    400396        // Subtract post types that are not included in the admin all list.
Note: See TracChangeset for help on using the changeset viewer.