[buddypress-trac] [BuddyPress Trac] #6615: bp_get_the_post_class() mistakenly removes classes

buddypress-trac noreply at wordpress.org
Thu Sep 10 21:11:12 UTC 2015

#6615: bp_get_the_post_class() mistakenly removes classes
 Reporter:  dcavins           |      Owner:
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  2.4
Component:  Component - Core  |    Version:  2.3.3
 Severity:  normal            |   Keywords:  has-patch
 `bp_get_the_post_class()` tries to unset the classes `page` and `type-
 page` on BuddyPress pages. However, it uses `array_search()` to find the
 key to unset and doesn't check for strict falsey-ness (`array_search`
 returns the found key--including 0-- or `false` if nothing is found).

 In our function, if the targeted class isn't found, the zeroth element of
 the array is accidentally unset. I've added a strict check on the result
 of `array_search()` before unsetting anything.

 This also could be done using `array_diff()`, if you have some idea that
 that would be more efficient/less klutzy, please let me know. :)

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

More information about the buddypress-trac mailing list