Make WordPress Core


Ignore:
Timestamp:
04/24/2012 10:13:47 PM (14 years ago)
Author:
ryan
Message:
  • Return empty arrays instead of false for all conditions in get_blogs_of_user().
  • When deleting a user, use a delete_metadata_by_mid() loop over the meta so that the meta cache is cleared.
  • Use remove_user_from_blog() for DRYness.

Props nacin, duck_
Fixes #19500

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/user.php

    r20532 r20581  
    653653 * @param int $user_id User ID
    654654 * @param bool $all Whether to retrieve all blogs, or only blogs that are not marked as deleted, archived, or spam.
    655  * @return array A list of the user's blogs. False if the user was not found or an empty array if the user has no blogs.
     655 * @return array A list of the user's blogs. An empty array if the user doesn't exist or belongs to no blogs.
    656656 */
    657657function get_blogs_of_user( $user_id, $all = false ) {
    … …  
    662662        // Logged out users can't have blogs
    663663        if ( empty( $user_id ) )
    664                 return false;
     664                return array();
    665665
    666666        $keys = get_user_meta( $user_id );
    667667        if ( empty( $keys ) )
    668                 return false;
     668                return array();
    669669
    670670        if ( ! is_multisite() ) {
    … …  
    746746
    747747        $blogs = get_blogs_of_user( $user_id );
    748         if ( is_array( $blogs ) )
    749                 return array_key_exists( $blog_id, $blogs );
    750         else
    751                 return false;
     748        return array_key_exists( $blog_id, $blogs );
    752749}
    753750
Note: See TracChangeset for help on using the changeset viewer.