[wp-trac] [WordPress Trac] #48855: Updating transient to remove expiration fails

WordPress Trac noreply at wordpress.org
Mon Dec 2 19:50:43 UTC 2019


#48855: Updating transient to remove expiration fails
--------------------------+-----------------------------
 Reporter:  stndrdsnz     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 When updating a transient using the set_transient method, it fails to
 update the transient's expiration date.

 Looking at the code, it appears it's only looking for the expiration and
 deleting it if a new expiration date is specified. This renders it
 impossible to switch a transient from having an expiration date to not
 having one.

 ex. code:

 {{{#!php
 <?php
 //new transient set to expire in one hour
 set_transient('new_transient', 'data', 5000);

 //Update transient and remove expiration
 set_transient('new_transient', 'new_data', 0);

 }}}

 At this point, if you look in the options table for the
 _transient_new_transient_expiration you'll find the previous value of 1
 hour for the expiration instead of the expiration having been removed.

 One thing I recognize, that may render this from being a "bug" is the
 nature of transients would be if transient information isn't available, it
 shouldn't be relied upon, but rather rebuilt. In this use case above, a
 transient that's set to not expire, but actually still has an expiration
 date, would expire and in theory then be regenerated later if the data is
 requested after the expiration.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48855>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list