Skip to:
Content

BuddyPress.org

Changeset 11772 for branches/2.9


Ignore:
Timestamp:
12/13/2017 01:07:58 AM (4 years ago)
Author:
boonebgorges
Message:

Members: Fix PHP 7.2 notice in 'last_activity' usermeta filter.

A new PHP notice in 7.2 shows what has long been a bug: when
_bp_get_user_meta_last_activity_warning() filters get_user_metadata,
it does not obey the $single parameter. This is now fixed.

Merges [11768] to the 2.9 branch.

See #7634.

Location:
branches/2.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.9

  • branches/2.9/src/bp-members/bp-members-functions.php

    r11630 r11772  
    11761176    bp_update_user_meta( $user_id, 'last_activity', $time );
    11771177    add_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 );
    1178     add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 3 );
     1178    add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 4 );
    11791179
    11801180    return BP_Core_User::update_last_activity( $user_id, $time );
     
    11901190 *
    11911191 * @since 2.0.0
     1192 * @since 2.9.3 Added the `$single` parameter.
    11921193 *
    11931194 * @access private For internal use only.
     
    11961197 * @param int    $object_id ID of the user.
    11971198 * @param string $meta_key  Meta key being fetched.
     1199 * @param bool   $single    Whether a single key is being fetched (vs an array).
    11981200 * @return string|null
    11991201 */
    1200 function _bp_get_user_meta_last_activity_warning( $retval, $object_id, $meta_key ) {
     1202function _bp_get_user_meta_last_activity_warning( $retval, $object_id, $meta_key, $single ) {
    12011203    static $warned = false;
    12021204
     
    12081210        }
    12091211
    1210         return bp_get_user_last_activity( $object_id );
     1212        $user_last_activity = bp_get_user_last_activity( $object_id );
     1213        if ( $single ) {
     1214            return $user_last_activity;
     1215        } else {
     1216            return array( $user_last_activity );
     1217        }
    12111218    }
    12121219
    12131220    return $retval;
    12141221}
    1215 add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 3 );
     1222add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 4 );
    12161223
    12171224/**
Note: See TracChangeset for help on using the changeset viewer.