Opened 10 months ago
Closed 10 months ago
#21327 closed defect (bug) (fixed)
No default value is set for $group in WP_Object_Cache for the decr method
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Cache | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
Unlike incr and other methods on WP_Object_Cache, decr does not do a check to see if $group is empty to set it to 'default'. This is problematic when using wp_cache_decr() since the result is that set cache with wp_cache_set (which has $group set as 'default') is not decremented.
Patch included, but not sure if this should be classified 'normal' or 'major'. Unit tests still appear to pass, but more testing probably useful.
Attachments (2)
Change History (9)
bananastalktome — 10 months ago
@nacin the problem is more with the wrapper wp_cache_decr, which passes an empty string as the group param to the decr method on global $wp_object_cache. So, for example, wp_cache_decr("dog", 1) would result in the grouping being set as an empty string rather than "default". I might be wrong, so please correct me if I am :)
Ah ha. Well, still only happens if you use wp_cache_decr() without a group. Always been broken, and not used in core. Good candidate for unit tests + patch.
Ah, ok. Well a request for just that is in the unit-tests trac (#UT110). I'm working on tests for this now, and hopefully putting up a patch soon.
- Owner set to nacin
- Resolution set to fixed
- Status changed from new to closed
In [21294]:
- Resolution fixed deleted
- Status changed from closed to reopened
Another issue found from the unit tests for these functions (#UT110), which is that the profiles of wp_cache_delete and WP_Object_Cache::delete() are different. wp_cache_delete is missing the optional third force parameter.
Patch added to add this as well (or should this be a separate ticket?)

Even low severity would be fine — this really only occurs if you use the method improperly by explicitly passing false, null, "", etc., which I imagine would result in a notice when it is used as a key.