[wp-trac] [WordPress Trac] #20004: Fix NULL and FALSE in WP_Object_Cache and make found/not-found unambiguous.

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 9 22:34:21 UTC 2012


#20004: Fix NULL and FALSE in WP_Object_Cache and make found/not-found unambiguous.
------------------------------------+------------------------------
 Reporter:  andy                    |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Cache                   |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |
------------------------------------+------------------------------

Comment (by andy):

 I included both the function and the pass-by-ref param because I could not
 choose a clear winner. Each one wins in different code contexts.

 The backwards-compatible use case with the function call is even more
 verbose than with the pass-by-ref:
 {{{
 $value = wp_cache_get( $key, $group );
 if ( ! $value || ( function_exists( 'wp_cache_found' ) && !
 wp_cache_found() ) ) {
     $value = $wpdb->get_results( $query );
     wp_cache_set( $key, $value, $group );
 }
 }}}

 If you are counting ```$found = null;``` you should consider that you only
 have to define $found this way once. You can reuse it in subsequent calls
 to ```wp_cache_get()``` in the same lexical context.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20004#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list