Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/27/2014 09:39:23 PM (10 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/tests/phpunit/testcases/activity/functions.php

    r8990 r9052  
    724724
    725725    /**
     726     * @group bp_activity_new_comment
     727     * @group BP5907
     728     */
     729    public function test_bp_activity_comment_on_deleted_activity() {
     730        $a = $this->factory->activity->create();
     731
     732        bp_activity_delete_by_activity_id( $a );
     733
     734        $c = bp_activity_new_comment( array(
     735            'activity_id' => $a,
     736            'parent_id' => $a,
     737            'content' => 'foo',
     738            'user_id' => 1,
     739        ) );
     740
     741        $this->assertEmpty( $c );
     742    }
     743
     744    /**
    726745     * @group favorites
    727746     * @group bp_activity_add_user_favorite
Note: See TracChangeset for help on using the changeset viewer.