Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/27/2014 09:39:23 PM (11 years ago)
Author:
imath
Message:

Make sure the parent activity exists before adding a comment to it.

There can be a case when the activity displayed in the stream has been deleted by another user. Adding a comment should not be possible for this particular case as the parent activity does not exist anymore. The patch is adding a check on the date_recorded field of the parent activity before adding a comment. If it is not set, then false is returned and a default message is displayed to the user by bp_legacy_theme_new_activity_comment(). As boonebgorges, some improvements on the message can still be added.

See #5907

File:
1 edited

Legend:

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

    r8996 r9052  
    13511351    $activity_id = $r['activity_id'];
    13521352
     1353    // Get the parent activity
     1354    $activity  = new BP_Activity_Activity( $activity_id );
     1355
     1356    // Bail if the parent activity does not exist
     1357    if ( empty( $activity->date_recorded ) ) {
     1358        return false;
     1359    }
     1360
    13531361    // Check to see if the parent activity is hidden, and if so, hide this comment publically.
    1354     $activity  = new BP_Activity_Activity( $activity_id );
    13551362    $is_hidden = ( (int) $activity->hide_sitewide ) ? 1 : 0;
    13561363
     
    16621669            }
    16631670        }
    1664        
     1671
    16651672        // Delete the comment itself
    16661673        bp_activity_delete( array(
Note: See TracChangeset for help on using the changeset viewer.