Skip to:
Content

BuddyPress.org

Changeset 12125


Ignore:
Timestamp:
05/25/2018 11:11:48 PM (7 years ago)
Author:
r-a-y
Message:

Groups: Wrap groups_record_activity() calls with bp_is_active( 'activity' )

In r11924, the bp-groups-activity.php file is loaded only if the Activity
component is enabled.

However, the groups_record_activity() function is located in this file.
Because this function now relies on the Activity component, if the Activity
component is disabled, a fatal error can occur during certain group
actions. This commit addresses the problem by checking for the Activity
component before calling on the function.

Anti-props r-a-y.

See #7870 (3.x branch).

Location:
branches/3.0/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/src/bp-groups/actions/create.php

    r11923 r12125  
    183183
    184184            // Once we completed all steps, record the group creation in the activity stream.
    185             groups_record_activity( array(
    186                 'type' => 'created_group',
    187                 'item_id' => $bp->groups->new_group_id
    188             ) );
     185            if ( bp_is_active( 'activity' ) ) {
     186                groups_record_activity( array(
     187                    'type' => 'created_group',
     188                    'item_id' => $bp->groups->new_group_id
     189                ) );
     190            }
    189191
    190192            /**
  • branches/3.0/src/bp-groups/bp-groups-functions.php

    r12123 r12125  
    586586
    587587    // Record this in activity streams.
    588     groups_record_activity( array(
    589         'type'    => 'joined_group',
    590         'item_id' => $group_id,
    591         'user_id' => $user_id,
    592     ) );
     588    if ( bp_is_active( 'activity' ) ) {
     589        groups_record_activity( array(
     590            'type'    => 'joined_group',
     591            'item_id' => $group_id,
     592            'user_id' => $user_id,
     593        ) );
     594    }
    593595
    594596    /**
  • branches/3.0/src/bp-groups/screens/user/invites.php

    r11923 r12125  
    2929            bp_core_add_message( sprintf( __( 'Group invite accepted. Visit %s.', 'buddypress' ), bp_get_group_link( $group ) ) );
    3030
    31             groups_record_activity( array(
    32                 'type'    => 'joined_group',
    33                 'item_id' => $group->id
    34             ) );
     31            if ( bp_is_active( 'activity' ) ) {
     32                groups_record_activity( array(
     33                    'type'    => 'joined_group',
     34                    'item_id' => $group->id
     35                ) );
     36            }
    3537        }
    3638
  • branches/3.0/src/bp-templates/bp-nouveau/includes/groups/ajax.php

    r12105 r12125  
    108108
    109109            } else {
    110                 groups_record_activity(
    111                     array(
    112                         'type'    => 'joined_group',
    113                         'item_id' => $group->id,
    114                     )
    115                 );
     110                if ( bp_is_active( 'activity' ) ) {
     111                    groups_record_activity(
     112                        array(
     113                            'type'    => 'joined_group',
     114                            'item_id' => $group->id,
     115                        )
     116                    );
     117                }
    116118
    117119                // User is now a member of the group
Note: See TracChangeset for help on using the changeset viewer.