Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/12/2017 02:55:14 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.

See #7634.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-functions.php

    r11759 r11768  
    11701170    bp_update_user_meta( $user_id, 'last_activity', $time );
    11711171    add_filter( 'update_user_metadata', '_bp_update_user_meta_last_activity_warning', 10, 4 );
    1172     add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 3 );
     1172    add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 4 );
    11731173
    11741174    return BP_Core_User::update_last_activity( $user_id, $time );
     
    11841184 *
    11851185 * @since 2.0.0
     1186 * @since 2.9.3 Added the `$single` parameter.
    11861187 *
    11871188 * @access private For internal use only.
     
    11901191 * @param int    $object_id ID of the user.
    11911192 * @param string $meta_key  Meta key being fetched.
     1193 * @param bool   $single    Whether a single key is being fetched (vs an array).
    11921194 * @return string|null
    11931195 */
    1194 function _bp_get_user_meta_last_activity_warning( $retval, $object_id, $meta_key ) {
     1196function _bp_get_user_meta_last_activity_warning( $retval, $object_id, $meta_key, $single ) {
    11951197    static $warned = false;
    11961198
     
    12021204        }
    12031205
    1204         return bp_get_user_last_activity( $object_id );
     1206        $user_last_activity = bp_get_user_last_activity( $object_id );
     1207        if ( $single ) {
     1208            return $user_last_activity;
     1209        } else {
     1210            return array( $user_last_activity );
     1211        }
    12051212    }
    12061213
    12071214    return $retval;
    12081215}
    1209 add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 3 );
     1216add_filter( 'get_user_metadata', '_bp_get_user_meta_last_activity_warning', 10, 4 );
    12101217
    12111218/**
Note: See TracChangeset for help on using the changeset viewer.