Make WordPress Core

Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#22369 closed defect (bug) (invalid)

get_transient() do not call delete_transient() when deleting one

Reported by: juliobox's profile juliobox Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: General Keywords: close
Focuses: Cc:



i was wondering why get_transient() is not calling delete_transient when deleting a timeouted transient.

Piece of code from get_transient()

				$transient_option = '_transient_' . $transient;
				$transient_timeout = '_transient_timeout_' . $transient;
				if ( get_option( $transient_timeout ) < time() ) {
					delete_option( $transient_option  );
					delete_option( $transient_timeout );
					return false;

but i need to trigger the "deleted_transient" hook.
Can we do that:

				$transient_option = '_transient_' . $transient;
				$transient_timeout = '_transient_timeout_' . $transient;
				if ( get_option( $transient_timeout ) < time() ) {
					delete_transient( $transient_option  );
					return false;

Change History (3)

#1 @nacin
11 years ago

  • Keywords close added
  • Version changed from trunk to 2.8

The transient isn't being "deleted" — it has simply expired and we've used the opportunity here to clean it up. (We could just as easily do it on cron or on upgrade — things we've considered.) A separate "expired transient" hook could be beneficial, but it wouldn't always work. That's because in environments with an object caching backend such as APC or Memcache, transient caching is completely offloaded there. Data in an external backend could get pushed out of cache at any time.

I do think the return false should go through the existing transient_$transient filter, though. When using an external backend, the false from wp_cache_get() does go through the filter, so this should as well.

#2 @juliobox
11 years ago

ok i understand, thank you !

#3 @johnbillion
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

I've opened #24685 for the transient_$transient filter issue. Going to close this one as invalid because, as nacin stated, the transient isn't being deleted at this point, it has expired.

Last edited 10 years ago by johnbillion (previous) (diff)
Note: See TracTickets for help on using tickets.