[wp-trac] [WordPress Trac] #10788: (set|delete)_transient need some filters

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 30 10:06:43 UTC 2009


#10788: (set|delete)_transient need some filters
--------------------------+-------------------------------------------------
 Reporter:  dd32          |       Owner:  ryan     
     Type:  defect (bug)  |      Status:  new      
 Priority:  normal        |   Milestone:  2.9      
Component:  Cache         |     Version:  2.9      
 Severity:  normal        |    Keywords:  has-patch
--------------------------+-------------------------------------------------

Comment(by nacin):

 Replying to [comment:9 dd32]:
 > Right now, Its impossible to return false of the option function set via
 the pre_option_* filter, thats what i originally meant. Never intended for
 it to change the way it operated in returning false.

 Correct. Oh, now I fully grasp the implications. Since false means that
 the option is empty or doesn't exist, then that's exactly why you'd want
 to use the pre_* filter to return false.

 This seems hackish, but to maintain backwards compatibility, what if we
 left it as false, but if you returned null to the filter, it'd return the
 option function as false? (It'd only break if someone was deliberately
 returning null, and even then, they'd get false -- which might be what
 they had wanted in the first place but couldn't do.)

 {{{
 $pre = apply_filters( "pre_option_{$option}", false );
         if ( null === $pre )
                 return false;
         if ( false !== $pre )
                 return $pre;
 }}}
 The only downside, I think, is that it is confusing. (I guess it'll need
 some phpdoc.)

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


More information about the wp-trac mailing list