[wp-trac] [WordPress Trac] #22232: Setting Transient Expiration to 0 Causes Transient To Never Expire

WordPress Trac noreply at wordpress.org
Sat Oct 20 01:59:23 UTC 2012


#22232: Setting Transient Expiration to 0 Causes Transient To Never Expire
-----------------------------+-------------------------
 Reporter:  cgrymala         |       Type:  enhancement
   Status:  new              |   Priority:  normal
Milestone:  Awaiting Review  |  Component:  Cache
  Version:  2.8              |   Severity:  normal
 Keywords:                   |
-----------------------------+-------------------------
 I realize this may be by design, but the way the `set_transient()`
 function handles expiration timeouts that are set to 0 is a little
 counter-intuitive.

 Logically, it seems like setting a transient's expiration to 0 would cause
 the transient to expire immediately (essentially, you wouldn't even set
 the transient). However, in reality, setting the expiration to 0 actually
 causes the transient to never expire (like a standard option, just with
 the _transient_ prefix on the option name). The biggest issue with the way
 it's currently handled is the fact that those transients also auto-load;
 so an unsuspecting developer could easily start to fill up the memory
 buffer with auto-loading transients that should logically have never been
 set.

 This issue may become even more important now that the concept of
 filtering a transient's expiration has been introduced
 (http://core.trac.wordpress.org/ticket/21330).

 I would propose simply exiting the function without storing the transient
 if the `$expiration` parameter is empty.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22232>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list