WordPress.org

Make WordPress Core

Opened 18 months ago

Closed 10 months ago

Last modified 10 months ago

#22369 closed defect (bug) (invalid)

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

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

Description

Hello

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)

comment:1 nacin17 months 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.

comment:2 juliobox17 months ago

ok i understand, thank you !

comment:3 johnbillion10 months 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 becase, as nacin stated, the transient isn't being deleted at this point, it has expired.

Version 0, edited 10 months ago by johnbillion (next)
Note: See TracTickets for help on using tickets.