Skip to:
Content

BuddyPress.org

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#7296 closed defect (bug) (fixed)

BuddyPress Private groups showing "Request Membership" Tab to admin/users

Reported by: sbrajesh Owned by: boonebgorges
Milestone: 2.7 Priority: high
Severity: major Version:
Component: Groups Keywords: has-patch
Cc: sbrajesh

Description

With the addition of magical getter/setter in BP_Groups_Group, It is no longer possible to add random data on the group object.

This cause issues with exiting code that dynamically added property on the group object. One such issue in the BuddyPress core has cropped up on private Groups.

If you are the admin of the private group and visit it, you will see the Request membership navigation link in addition to other links.

This is happening because the Groups component sets up dynamic property 'is_user_member' but it is not available due to getters/setters.

The solution is to modify the definitions of the magical methods(get/set, isset) and use an array to store/retrieve random property.

Please find the patch attached.

Attachments (1)

7296.diff (1.0 KB) - added by sbrajesh 3 years ago.
Fix the magic method bugs

Download all attachments as: .zip

Change History (5)

@sbrajesh
3 years ago

Fix the magic method bugs

This ticket was mentioned in Slack in #buddypress by boone. View the logs.


3 years ago

#2 @boonebgorges
3 years ago

Thanks for the report, @sbrajesh. I'm not sure that we always need to maintain backward compatibility for arbitrary properties, but we absolutely cannot break compatibility with is_user_member (and front_template, which suffers from the same problem).

At the moment, I don't see a benefit to storing arbitrary data in an array rather than directly as properties on the object; this would be useful if we were protecting access somehow, or if we did actual OOP things with the object, but we don't.

#3 @boonebgorges
3 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 11199:

Groups: It should be possible to set arbitrary props on BP_Groups_Group objects.

In a number of places (user_is_member, front_template), BP sets
properties on the BP_Groups_Group object. The change to magic methods
(see #5451) broke this process for properties not included in the
class definition of BP_Groups_Group. To maintain compatibility with
previous use, arbitrary properties can now be fetched and set on
these objects.

Props sbrajesh, dcavins.
Fixes #7296.

#4 @sbrajesh
3 years ago

Thank you for fixing it in 2.7.
No issues with storing as property on the object.

Thank you.

Note: See TracTickets for help on using tickets.