Skip to:
Content

BuddyPress.org

Changeset 8054


Ignore:
Timestamp:
03/06/2014 01:31:01 AM (11 years ago)
Author:
boonebgorges
Message:

Ensure that a last_activity value is set for each user in BP_User_Query::populate_extras()

This helps to avoid PHP notices when directly accessing this value for a user
who has not yet logged activity.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-classes.php

    r8047 r8054  
    574574        $last_activities = BP_Core_User::get_last_activity( $this->user_ids );
    575575
    576         if ( ! empty( $last_activities ) ) {
    577             foreach ( $last_activities as $la_user => $la_value ) {
    578                 if ( isset( $this->results[ $la_user ] ) ) {
    579                     $this->results[ $la_user ]->last_activity = $la_value['date_recorded'];
    580                 }
    581             }
     576        // Set a last_activity value for each user, even if it's empty
     577        foreach ( $this->results as $user_id => $user ) {
     578            $user_last_activity = isset( $last_activities[ $user_id ] ) ? $last_activities[ $user_id ]['date_recorded'] : '';
     579            $this->results[ $user_id ]->last_activity = $user_last_activity;
    582580        }
    583581
Note: See TracChangeset for help on using the changeset viewer.