[buddypress-trac] [BuddyPress Trac] #6649: Compatibility with `WP_Hook`

buddypress-trac noreply at wordpress.org
Fri Oct 9 03:38:27 UTC 2015


#6649: Compatibility with `WP_Hook`
--------------------------+-----------------------
 Reporter:  boonebgorges  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  2.4
Component:  API           |    Version:
 Severity:  normal        |   Keywords:  has-patch
--------------------------+-----------------------
 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.

--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/6649>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list