[buddypress-trac] [BuddyPress] #2627: Excessive database connections caused by improper assignment of global var in bp_forums_load_bbpress()
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Sat Sep 11 16:47:24 UTC 2010
#2627: Excessive database connections caused by improper assignment of global var
in bp_forums_load_bbpress()
------------------------+---------------------------------------------------
Reporter: nickwondra | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 1.3
Component: Forums | Keywords:
------------------------+---------------------------------------------------
In the function bp_forums_load_bbpress() in the file bp-forums-
bbpress.php, line 73 performs an improper reference assignment between two
global variables:
$bb_roles =& $wp_roles;
Since $bb_roles and $wp_roles are globals in this function scope, they are
already references so this assignment will not persist to the $bb_roles
global object (it will only alter the value of $bb_roles in the scope of
this function). The proper assignment should be as follows:
$bb_roles = $wp_roles;
This assignment persists the value of $bb_roles at the global scope to
reference the same object as $wp_roles.
This improper assignment causes bp_forums_load_bbpress() to never assign a
value to $bb_roles, so it runs in its entirety every time it is called
even though it is only meant to run through once (see lines 9-10). Since
bp_forums_load_bbpress() is called frequently (it is the target of the
action 'bbpress_init') and it creates a new database connection through a
new BBDB object, this can lead to a very high number of database
connection attempts. Some hosts will refuse connections after a certain
number of attempts in a given time limit. This can be a big problem,
especially where the 'bbpress_init' action is called multiple times for a
single user operation, such as adding a new topic -- it can result in
things like the topic being created, but the user's initial post being
lost.
I'm not up to speed on the current roadmap for upcoming milestones, so I'm
leaving this as targeted at 1.3 (the default). Since this is such a simple
fix, it would be great to get it into 1.2.6 if the schedule allows.
Thanks!
--
Ticket URL: <http://trac.buddypress.org/ticket/2627>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list