Skip to:
Content

BuddyPress.org

Changeset 10632


Ignore:
Timestamp:
03/04/2016 06:42:58 PM (11 years ago)
Author:
imath
Message:

Make sure the Activity Component is active before using functions relative to it inside the Blogs component.

r10544 introduced a side effect on the BuddyPress Emails feature when the Blogs component is activated and the Activity one is deactivated.

This changeset removed some bp_is_active() checks inside bp_blogs_delete_activity() and bp_blogs_record_activity() in favor a conditional load of the whole bp-blogs/bp-blogs-activity.php file.

Unfortunately, an issue appeared when the Activity component is not active because these functions are used when some WordPress hooks are fired, for instance when a post type is deleted.

For the 2.5 Branch we are bringing back the bp_is_active() checks before using the two functions mentioned earlier. For next release, we will carry on moving all the code specific to the activity component inside the bp-blogs/bp-blogs-activity.php file.

See #6937 (trunk)

File:
1 edited

Legend:

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

    r10544 r10632  
    280280        $is_private = !apply_filters( 'bp_is_new_blog_public', !$is_private );
    281281
    282         // Only record this activity if the blog is public.
    283         if ( !$is_private && !$no_activity && bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) {
     282        // Only record this activity if the activity component is active and the blog is public.
     283        if ( bp_is_active( 'activity' ) && !$is_private && !$no_activity && bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) {
    284284
    285285                // Record this in activity streams.
     
    816816        BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    817817
    818         // Delete activity stream item.
    819         bp_blogs_delete_activity( array(
    820                 'item_id'   => $blog_id,
    821                 'component' => buddypress()->blogs->id,
    822                 'type'      => 'new_blog'
    823         ) );
     818        /**
     819         * Delete activity stream item only if the Activity component is active
     820         *
     821         * @see https://buddypress.trac.wordpress.org/ticket/6937
     822         */
     823        if ( bp_is_active( 'activity' ) ) {
     824                bp_blogs_delete_activity( array(
     825                        'item_id'   => $blog_id,
     826                        'component' => buddypress()->blogs->id,
     827                        'type'      => 'new_blog'
     828                ) );
     829        }
    824830
    825831        /**
     
    858864        BP_Blogs_Blog::delete_blog_for_user( $blog_id, $user_id );
    859865
    860         // Delete activity stream item.
    861         bp_blogs_delete_activity( array(
    862                 'item_id'   => $blog_id,
    863                 'component' => buddypress()->blogs->id,
    864                 'type'      => 'new_blog'
    865         ) );
     866        /**
     867         * Delete activity stream item only if the Activity component is active
     868         *
     869         * @see https://buddypress.trac.wordpress.org/ticket/6937
     870         */
     871        if ( bp_is_active( 'activity' ) ) {
     872                bp_blogs_delete_activity( array(
     873                        'item_id'   => $blog_id,
     874                        'component' => buddypress()->blogs->id,
     875                        'type'      => 'new_blog'
     876                ) );
     877        }
    866878
    867879        /**
     
    911923        do_action( 'bp_blogs_before_remove_post', $blog_id, $post_id, $user_id );
    912924
    913         // Delete activity stream item.
    914         bp_blogs_delete_activity( array(
    915                 'item_id'           => $blog_id,
    916                 'secondary_item_id' => $post_id,
    917                 'component'         => buddypress()->blogs->id,
    918                 'type'              => 'new_blog_post'
    919         ) );
     925        /**
     926         * Delete activity stream item only if the Activity component is active
     927         *
     928         * @see https://buddypress.trac.wordpress.org/ticket/6937
     929         */
     930        if ( bp_is_active( 'activity' ) ) {
     931                bp_blogs_delete_activity( array(
     932                        'item_id'           => $blog_id,
     933                        'secondary_item_id' => $post_id,
     934                        'component'         => buddypress()->blogs->id,
     935                        'type'              => 'new_blog_post'
     936                ) );
     937        }
    920938
    921939        /**
     
    11091127        BP_Blogs_Blog::delete_blog_for_all( $blog_id );
    11101128
    1111         // Delete activity stream item.
    1112         bp_blogs_delete_activity( array(
    1113                 'item_id'   => $blog_id,
    1114                 'component' => buddypress()->blogs->id,
    1115                 'type'      => false
    1116         ) );
     1129        /**
     1130         * Delete activity stream item only if the Activity component is active
     1131         *
     1132         * @see https://buddypress.trac.wordpress.org/ticket/6937
     1133         */
     1134        if ( bp_is_active( 'activity' ) ) {
     1135                bp_blogs_delete_activity( array(
     1136                        'item_id'   => $blog_id,
     1137                        'component' => buddypress()->blogs->id,
     1138                        'type'      => false
     1139                ) );
     1140        }
    11171141
    11181142        /**
Note: See TracChangeset for help on using the changeset viewer.