[buddypress-trac] [BuddyPress Trac] #6012: Cache: Invalid usage of `! $count`

buddypress-trac noreply at wordpress.org
Sat Nov 15 04:17:39 UTC 2014


#6012: Cache: Invalid usage of `! $count`
----------------------------+-----------------------
 Reporter:  r-a-y           |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  2.2
Component:  All Components  |    Version:  1.2
 Severity:  normal          |   Keywords:  has-patch
----------------------------+-----------------------
 In some of our object cache calls (see r2618), we do this:

 {{{
 if ( ! $count = wp_cache_get( 'WHATEVER', 'bp' ) {
         $count = FUNCTION_TO_FETCH_COUNT_VIA_DB();
         wp_cache_set( 'WHATEVER', $count, 'bp' );
 }
 }}}


 If `$count` is zero, then the check passes due to the liberal `!`
 condition and will go about hitting the DB again.


 Attached patch fixes this.

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


More information about the buddypress-trac mailing list