Opened 11 years ago
Last modified 3 months ago
#24686 reviewing enhancement
Introduce generic filter on transient return value
Reported by: | johnbillion | Owned by: | johnbillion |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 2.8 |
Component: | Cache API | Keywords: | has-patch 2nd-opinion dev-feedback has-unit-tests |
Focuses: | Cc: |
Description
The get_transient()
and get_site_transient()
functions have a filter on their return value, but the filter name contains the transient key: transient_{$transient}
.
This means it's not possible to hook into the return value for every transient in order to do something like logging transient hits and misses.
Attachments (6)
Change History (22)
#5
@
11 years ago
Nope, we don't do it for options, meta, or cache. I think it has a use case for transients though (and possibly the object cache, although that could impact performance). My use case is for logging hits and misses when fetching transients.
#6
@
11 years ago
- Keywords 2nd-opinion added
- Milestone changed from 3.7 to Future Release
IRC discussion: http://irclogs.wordpress.org/chanlog.php?channel=wordpress-dev&day=2013-09-17&sort=asc#m689641
Maybe an 'expired_transient' action would be useful. But if you're using a cache backend, you'll get hit and miss statistics automatically.
#7
@
11 years ago
- Milestone Future Release deleted
- Resolution set to wontfix
- Status changed from new to closed
#8
@
8 years ago
- Resolution wontfix deleted
- Status changed from closed to reopened
I have a use case where a generic filter would be extremely useful.
I have written a plugin to bypass transients on a per page basis https://github.com/ryanwelcher/suspend-transients. In order to bypass transients, we need to know their names.
Getting the name requires retrieving them from the database or capturing them using the setted_transient
action and then storing them somewhere ( in my case an option )
Once we have the names of the transients, we then have to add a filter for each one - which can be a very large number of filters to add - and will eventually cause performance issues.
Having a generic filter would address both these issues.
#12
@
8 years ago
- Milestone set to Awaiting Review
Moving reopened tickets without a milestone back to Awaiting Review
for review
#13
@
8 years ago
24686.2.diff adds a matching filter for get_site_transient
24686.3.diff is an alternate version which fires actions before the transients are returned.
Offering do_action
as an alternative based on the IRC discussion: http://irclogs.wordpress.org/chanlog.php?channel=wordpress-dev&day=2013-09-17&sort=asc#m689641
#14
@
8 years ago
24686.4.diff rename hooks, change "getted" to "got".
#15
@
8 years ago
@nacin, @johnbillion what do you think of the approach in 24686.4.diff triggering an action?
Note that the patch on ticket #24685 is needed in conjunction with this to be of any real use.