[buddypress-trac] [BuddyPress] #4403: Fatal Error After Upgrading to BuddyPress 1.6
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Tue Aug 7 20:49:14 UTC 2012
#4403: Fatal Error After Upgrading to BuddyPress 1.6
--------------------------+--------------------
Reporter: steve7777 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 1.6.1
Component: Core | Version: 1.6
Severity: critical | Resolution:
Keywords: 2nd-opinion |
--------------------------+--------------------
Changes (by boonebgorges):
* keywords: => 2nd-opinion
Comment:
OK, I have done a bit more investigation, and here's what I've found.
I can reproduce the problem with the following function:
{{{
function bp_4403_test() {
if ( bp_is_user() ) {
echo 'foo';
}
}
add_action( 'bp_include', 'bp_4403_test', 7 );
}}}
The key here is that the function is loaded on 'bp_include', but at or
before priority 8. If you load at 9 or above, then the components will
have been loaded, and bp_displayed_user_id() will have been defined.
I took a look back through and found that changeset r5301 was responsible
for making this happen. Prior to r5301, you could hook a function
containing bp_is_user() nice and early and it will work fine. It looks
like the reason is that we used to reference the global directly here.
On the one hand, it's likely that the plugins/themes that are causing this
issue are doing something wrong, like using bp_core_new_subnav_item() way
too early. On the other hand, this is a regression. Moreover, there's
something wrong architecturally when functions in bp-core-template.php are
dependent on functions that are loaded later on in the load order of
BuddyPress. In the long run, we should probably work to fix this latter
problem. In the short term, we have basically three options.
(1) Swap out the bp_displayed_user_id() call in bp_is_user() with a direct
reference to $bp->displayed_user->id.
(2) Move bp_displayed_user_id(), and probably bp_loggedin_user_id(), into
the Core component.
(3) Verify that my initial hunch is right, and this problem is caused by
incorrect use of bp_core_new_subnav_item() (the only place I can see where
bp_is_user() is used in the Core component). If I'm right, refactor that
function so that it references the global directly instead.
In the short run, I would prefer (3), because it's the least intrusive.
But I would first want verification from some of the folks reporting the
problem that bp_core_new_subnav_item() is indeed the root cause of the
problem - steve7777, in your case that would mean checking to see
whether/how BP Mag uses bp_core_new_subnav_item(). (2) is acceptable but
seems a bit hackish, in that it's a band-aid fix for the long-term problem
that the functions are loaded in a funky order. (Likewise (1).)
Can I get some feedback from another dev?
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4403#comment:15>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list