Make WordPress Core

Opened 17 months ago

Last modified 17 months ago

#48855 new defect (bug)

Updating transient to remove expiration fails

Reported by: stndrdsnz Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.3
Component: Options, Meta APIs Keywords:
Focuses: Cc:


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:

//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.

Change History (1)

#1 @SergeyBiryukov
17 months ago

  • Component changed from General to Options, Meta APIs
Note: See TracTickets for help on using tickets.