#6649 closed defect (bug) (fixed)
Compatibility with `WP_Hook`
Reported by: | boonebgorges | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 2.4 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Core | Keywords: | has-patch dev-feedback needs-testing |
Cc: |
Description
See https://core.trac.wordpress.org/ticket/17817 and especially https://core.trac.wordpress.org/ticket/17817#comment:158.
bp_get_template_stack()
reaches into $wp_filter
and operates on some nested arrays in situ. #WP17817 proposes that $wp_filter
become an array of WP_Hook
objects instead of multidimensional arrays. So things like foreach ( current( $wp_filter[ $tag ] ) )
become impossible, because $wp_filter[ $tag ]
is a WP_Hook
object. WP_Hook
does implement ArrayAccess
, so passing it to current()
doesn't throw a fatal error. But WP_Hook
stores callbacks in the callbacks
property, which is a different structure than what bp_get_template_stack()
expects.
jbrinley's recommendation is to assign the callback array (by reference) to a variable before operating on it, and to check if ( class_exists( 'WP_Hook' ) )
in order to figure out how to set that variable. I've confirmed that this works. It's also completely backward compatible. The only change is the use of a variable where previously we were operating directly on $wp_filter['bp_template_stack']
.
The sooner we get this fix into BP, the sooner people will start upgrading to versions of BP that are WP_Hook
-compatible. So I'm recommending that we go with the attached patch for 2.4.
I tested the patch briefly on a few BP plugins that rely on registering a template stack, without applying the
WP_Hook
patch from #WP17817 and everything still works well.I say let's commit it for now and return to this once #WP17817 is sorted out.