[buddypress-trac] [BuddyPress Trac] #6242: Possible conflict with BuddyPress member type user cache and the WordPress term cache

buddypress-trac noreply at wordpress.org
Fri Feb 20 21:05:56 UTC 2015


#6242: Possible conflict with BuddyPress member type user cache and the WordPress
term cache
--------------------------+-----------------------------
 Reporter:  imath         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  API - Cache   |    Version:  2.2
 Severity:  normal        |   Keywords:  2nd-opinion
--------------------------+-----------------------------
 While building a small plugin to add some UIs to manage member types, i've
 noticed there was a possible conflict between BuddyPress member types user
 cache and the WordPress term cache for the `'bp_member_type'` taxonomy.

 If you use `get_terms( 'bp_member_type' )`, there's a possibility, if the
 user_id == the term_id that when getting the member type for a user you
 get this error `array_pop() expects parameter 1 to be array, object
 given`. That's because the cache already contains the term datas. see
 WordPress [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/taxonomy.php#L3837 update_term_cache()] function.

 So to avoid this, i suggest to use a different name for the cache group as
 WordPress is already using the taxonomy name, in our case :
 'bp_member_type'

 In the case of [https://github.com/imath/bp-mt-extended/blob/master/bp-mt-
 extended.php#L353 my plugin], i've used a fields argument != 'all' to
 avoid the problem.

 I'm adding a unit test so that it will be easy to reproduce the problem.

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


More information about the buddypress-trac mailing list