Make WordPress Core

Opened 5 years ago

Last modified 5 years ago

#48855 new defect (bug)

Updating transient to remove expiration fails

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

Description

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
//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
5 years ago

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