#22369 closed defect (bug) (invalid)
get_transient() do not call delete_transient() when deleting one
Reported by: |
|
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)
Note: See
TracTickets for help on using
tickets.
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 existingtransient_$transient
filter, though. When using an external backend, the false from wp_cache_get() does go through the filter, so this should as well.