Project

General

Profile

Actions

Bug #19214

closed

Group creation is causing a fatal error

Added by Raymond Hoh 8 months ago. Updated 8 months ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
Groups (misc)
Target version:
Start date:
2023-11-06
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

While looking into #19202, I found that group creation is broken. On the group creation page, if you click on the "Create Group and Continue" button, you will get a fatal error.

tl;dr: The bug is with the cac-group-library plugin and how it attempts to modify a group's navigation to remove some nav menu items. The bug only came about once we made our bp-nelo theme its own theme in CAC 2.2.0.

Boone, here's the rundown:
1. Before CAC 2.2.0, bp-nelo was a child theme of bp-default. When loading a BuddyPress template, all code execution stops after the template is loaded: https://github.com/buddypress/buddypress/blob/7a2458117e98f4861f9a9b85806b712770fb5919/src/bp-core/bp-core-catchuri.php#L511-L512

2. In CAC 2.2.0, bp-nelo is its own theme so BuddyPress's theme compat layer kicks in. However, BP theme compat doesn't halt code execution after a template is loaded: https://github.com/buddypress/buddypress/blob/7a2458117e98f4861f9a9b85806b712770fb5919/src/bp-core/bp-core-catchuri.php#L527-L532.

3. This led to the following on the group creation page:
i. When a BuddyPress group is created, it sets the buddypress()->groups->current_group property to the new group's details: https://github.com/buddypress/buddypress/blob/7a2458117e98f4861f9a9b85806b712770fb5919/src/bp-groups/actions/create.php#L60-L62 . This code runs on 'bp_actions' at priority 10.

ii. The 'cac-group-library' plugin attemps to alter a group's nav menu and it does a check for bp_is_group() to determine if we're on a single group page: https://github.com/cuny-academic-commons/cac-group-library/blob/b9d15c3f512e065d56ade216e7eb509b873a5248/src/Nav.php#L64-L70. This code runs on 'bp_actions' at priority 200. When this code runs at priority 200, bp_is_group() is returning true due to 3)i: https://github.com/buddypress/buddypress/blob/7a2458117e98f4861f9a9b85806b712770fb5919/src/bp-core/bp-core-template.php#L2737-L2739 .

iii. Due to bp_is_group() returning true, the cac-group-library plugin attempts to access some group nav class methods that only exist on a single group page . This causes the fatal error.


I've patched up the cac-group-library nav removal code to run on 'bp_actions' at priority 9 to sidestep the bp_is_group() problem and will create a ticket over on BuddyPress Trac to let devs know how bp_is_group() can potentially be true on the group creation page.


Related issues

Has duplicate CUNY Academic Commons - Bug #19239: Error occured when creating a group in CDevResolvedRaymond Hoh2023-11-09

Actions
Actions

Also available in: Atom PDF