WordPress.org

Making WordPress.org

Changeset 3530


Ignore:
Timestamp:
06/22/2016 09:32:21 AM (4 years ago)
Author:
dd32
Message:

Plugin Directory: Ensure that only valid WP_User objects are returned from Tools::get_plugin_subscribers().

See #1584

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php

    r3516 r3530  
    265265    public static function get_plugin_subscribers( $plugin_slug, $include_committers = false ) {
    266266        global $wpdb;
    267         $post = Plugin_Directory::get_plugin_post( $plugin_slug );
    268         if ( ! $post ) {
    269             return false;
    270         }
    271267
    272268        $users = array();
    273 
    274         // These users are subscribed the plugin commits.
    275         $subscribers = get_post_meta( $post->ID, '_commit_subscribed', true ) ?: array();
    276         foreach ( $subscribers as $subscriber_id ) {
    277             $users[] = get_user_by( 'id', $subscriber_id );
    278         }
    279 
    280         // Plugin Committers are always subscrived to plugin commits.
    281         $committers  = self::get_plugin_committers( $plugin_slug );
    282         foreach ( $committers as $committer ) {
    283             $users[] = get_user_by( 'login', $committer );
    284         }
    285269
    286270        // Include the subscribers from the bbPress plugin directory until we've fully migrated.
     
    288272        if ( $bbpress_subscribers ) {
    289273            foreach ( array_keys( $bbpress_subscribers ) as $subscriber_id ) {
    290                 $users[] = get_user_by( 'id', $subscriber_id );
     274                if ( $subscriber_id && $user = get_user_by( 'id', $subscriber_id ) ) {
     275                    $users[] = $user;
     276                }
    291277            }
    292278        }
    293279
    294         $users = array_filter( $users );
     280        // Plugin Committers are always subscrived to plugin commits.
     281        $committers  = self::get_plugin_committers( $plugin_slug );
     282        foreach ( $committers as $committer ) {
     283            if ( $committer && $user = get_user_by( 'login', $committer ) ) {
     284                $users[] = $user;
     285            }
     286        }
     287
     288        $post = Plugin_Directory::get_plugin_post( $plugin_slug );
     289        if ( ! $post ) {
     290            return $users;
     291        }
     292
     293        // These users are subscribed the plugin commits.
     294        $subscribers = get_post_meta( $post->ID, '_commit_subscribed', true ) ?: array();
     295        foreach ( $subscribers as $subscriber_id ) {
     296            if ( $subscriber_id && $user = get_user_by( 'id', $subscriber_id ) ) {
     297                $users[] = $user;
     298            }
     299        }
    295300
    296301        return $users;
Note: See TracChangeset for help on using the changeset viewer.