Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/27/2014 07:29:08 PM (10 years ago)
Author:
boonebgorges
Message:

Bail from bp_activity_remove_user_favorite() if the user has not previously favorited the item in question

The failure to do this check could result in the incorrect decrementing of the
item's favorite_count.

Fixes #5478

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-functions.php

    r8175 r8177  
    471471        $user_id = bp_loggedin_user_id();
    472472
    473     // Remove the fav from the user's favs
    474473    $my_favs = bp_get_user_meta( $user_id, 'bp_favorite_activities', true );
    475474    $my_favs = array_flip( (array) $my_favs );
     475
     476    // Bail if the user has not previously favorited the item
     477    if ( ! isset( $my_favs[ $activity_id ] ) ) {
     478        return false;
     479    }
     480
     481    // Remove the fav from the user's favs
    476482    unset( $my_favs[$activity_id] );
    477483    $my_favs = array_unique( array_flip( $my_favs ) );
Note: See TracChangeset for help on using the changeset viewer.