[buddypress-trac] [BuddyPress Trac] #5506: fatal errors when enabling BP components

buddypress-trac noreply at wordpress.org
Wed Apr 2 13:20:21 UTC 2014


#5506: fatal errors when enabling BP components
----------------------------+--------------------
 Reporter:  DJPaul          |       Owner:
     Type:  defect (bug)    |      Status:  new
 Priority:  high            |   Milestone:  2.0
Component:  Administration  |     Version:  1.9.2
 Severity:  major           |  Resolution:
 Keywords:  has-patch       |
----------------------------+--------------------
Changes (by boonebgorges):

 * keywords:   => has-patch
 * priority:  highest => high
 * severity:  critical => major


Comment:

 Here's what's happening:

 - We save the component options here:
 https://buddypress.trac.wordpress.org/browser/tags/1.9.2/bp-core/admin/bp-
 core-components.php#L233 During the POST request, the newly active
 components are not only saved to the DB as the new active_components
 variable, but they are also loaded into `$bp->active_components` to act as
 the active components for the current pageload
 - At the end of the function, `wp_redirect()` is run, which sends a
 Location header to the browser. This works, and sends the user back to the
 Components settings page. But it does not stop script execution on the
 pageload (the one triggered by the POST request). The admin panel
 continues to load on the server.
 - Recall that, in this "phantom" pageload, the new component is marked as
 "active" in the $bp global. Say you've activated Settings. As components
 load themselves, `bp_is_active( 'settings' )` will return true. But the
 Settings component has not actually been loaded - the files have not been
 included, because by the time the component settings are saved, our
 `includes()` methods have all been run. So we get the fatal errors you've
 experienced.

 This does not actually affect the proper functioning of BP. Component
 settings are still saved correctly, and they install themselves correctly.
 Everything loads as expected on the next (GET) pageload. It's just this
 phantom fatal error on an abandoned process.

 There are two options for fixing this:
 1. When saving the components, store them in a local variable
 `$active_components`, which would get passed to `bp_core_install()` etc.
 WP continues its phantom pageload, but BP does not attempt to load the
 uninitialized components.
 2. Kill the process right after the redirect. This is the simplest, and
 probably best. See 5506.patch.

 DJPaul, please test to verify that this solves the problem for you.

 Side note: it's likely that something similar is happening throughout BP,
 whenever we use `wp_redirect()`. It's never occurred to me before, but as
 a best practice, we probably ought to use `die` after every redirect. At
 the very least, it'll prevent wasted CPU cycles.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/5506#comment:8>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list