Project

General

Profile

Actions

Bug #6743

closed

Bug #6731: Out-of-control queries on production server

etivite_bp_group_adminmod_member_before_save seems to have a bug that causes an infinite loop

Added by Boone Gorges over 7 years ago. Updated over 7 years ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
WordPress Plugins
Target version:
Start date:
2016-11-15
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

This is in cac-group-admin-auto-add, a fork of an old BP auto-add-to-group plugin. See attached log.

Ray, could you take a look? It would be very helpful if, in addition to fixing the bug, you could give your opinion on whether this is something that broke recently - maybe due to a hook load-order change in BP.


Files

cac-group-admin-auto-add.txt (1.43 MB) cac-group-admin-auto-add.txt Boone Gorges, 2016-11-15 09:54 PM
Actions #1

Updated by Boone Gorges over 7 years ago

  • Target version changed from 1.10.2 to 1.10.3
Actions #2

Updated by Boone Gorges over 7 years ago

  • Target version changed from 1.10.3 to 1.10.4
Actions #3

Updated by Raymond Hoh over 7 years ago

  • Status changed from New to In Progress

I'm slowly working my way through this.

So far, I've created a ticket to remove some unnecessary DB queries when a group member is being promoted - https://buddypress.trac.wordpress.org/ticket/7382.

More to come.

Actions #4

Updated by Raymond Hoh over 7 years ago

  • Status changed from In Progress to Reporter Feedback

Okay, so there isn't really an infinite loop occurring here.

There are two problems:
1. cac-group-admin-auto-add is set up to send group invites from the group's creator with groups_send_invites() to the main group admin group:
https://github.com/cuny-academic-commons/cac/blob/master/wp-content/plugins/cac-group-admin-auto-add/bp-group-adminmod.php#L30

Since mostly every group admin or moderator addition on the Commons will trigger an invite to join the main group admin group, the number of invites in the main group admin group can sometimes be quite large.

2. groups_send_invites() is not set up to send a large number of invites well:
https://buddypress.trac.wordpress.org/browser/tags/2.7.3/src/bp-groups/bp-groups-functions.php?marks=1524,1532#L1507

This is what looks like an infinite loop, but isn't. It's just BP attempting to loop through each group invite to send.

This is what is causing the large query log. There are / were probably a ton of group invites in the queue for the main group admin group.


I'm not sure what we can do here. Maybe instead of sending an email, we just issue a BP screen notification and comment out the groups_send_invites() line in cac-group-admin-auto-add?

Actions #5

Updated by Boone Gorges over 7 years ago

Oh wow. Thanks for digging this up, Ray.

How about if, in our plugin, we do everything between your marks https://buddypress.trac.wordpress.org/browser/tags/2.7.3/src/bp-groups/bp-groups-functions.php?marks=1524,1532#L1507 just for the specific user being invited?

Doesn't this seem like a BuddyPress bug? We shouldn't be re-sending invites to users where `invite_sent=1`, right?

Actions #6

Updated by Boone Gorges over 7 years ago

  • Target version changed from 1.10.4 to 1.10.5
Actions #7

Updated by Raymond Hoh over 7 years ago

  • Status changed from Reporter Feedback to Resolved

Doesn't this seem like a BuddyPress bug? We shouldn't be re-sending invites to users where `invite_sent=1`, right?

I think you're right. I've created a BP ticket about this here.

How about if, in our plugin, we do everything between your marks...

Done. See:
https://github.com/cuny-academic-commons/cac/commit/cbf44184875d6821b4dd3b5aa40513d7e8419a22

Going to mark this as resolved.

Actions #8

Updated by Boone Gorges over 7 years ago

Excellent! Thanks, Ray.

Actions

Also available in: Atom PDF