[buddypress-trac] [BuddyPress Trac] #7392: PHP 7.1 compat
buddypress-trac
noreply at wordpress.org
Mon Feb 6 18:00:16 UTC 2017
#7392: PHP 7.1 compat
--------------------------+-----------------------------
Reporter: DJPaul | Owner:
Type: defect (bug) | Status: new
Priority: highest | Milestone: Future Release
Component: Core | Version:
Severity: normal | Resolution:
Keywords: |
--------------------------+-----------------------------
Changes (by boonebgorges):
* priority: normal => highest
Comment:
BP won't load on PHP 7.1 because of an issue with the way our components
set up the admin bar. See
http://php.net/manual/en/migration71.incompatible.php "The empty index
operator is not supported for strings anymore". `bp_setup_admin_bar()`
does the following:
{{{
do_action( 'bp_setup_admin_bar' );
}}}
which WordPress, since the introduction of `WP_Hook`, converts to
`$hook->apply_filters( '', $args )` - the first `''` is an empty string
passed as the missing "value" in a `do_action()` call. This means that all
instances of `'bp_setup_admin_bar'` are passed an empty string, overriding
the `$wp_admin_nav = array()` in the function definition. When components
try adding items to the array (`$wp_admin_nav[] = ...`), a fatal is
thrown.
The smallest fix I can see is to change `bp_setup_admin_bar()` so that it
does this instead:
{{{
apply_filters( 'bp_setup_admin_bar', array() );
}}}
But this changes the semantics a bit - our 'bp_setup_admin_bar' callbacks
don't actually use the value returned from the filter, which makes it
somewhat misleading to call it a "filter". Another option is to have an
explicit check in each `'bp_setup_admin_bar'` callback:
{{{
if ( '' === $wp_admin_nav ) {
$wp_admin_nav = array();
}
}}}
or to remove the default `$wp_admin_nav` from the function definition
altogether, and rely on a local variable. But neither of these will fix
the problem in third-party plugins.
I'm glad to spin this off into another ticket - it's important enough that
it should be fixed in the next minor release.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7392#comment:11>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list