Opened 3 years ago
Last modified 3 years ago
#54771 new defect (bug)
possible disagreement in the return types/values wp_cache_flush() and WP_Object_Cache:flush().
Reported by: | pbiron | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | low |
Severity: | normal | Version: | |
Component: | Cache API | Keywords: | |
Focuses: | docs | Cc: |
Description
WP_Object_Cache::flush() always returns true.
wp_cache_flush() returns the value of calling WP_Object_Cache::flush()
. But, the DocBlock of wp_cache_flush()
lists the return as:
True on success, false on failure.
Is this discrepancy just a mistake, or is it because of the possibility of an object caching plugin returning something different?
Change History (4)
#2
in reply to:
↑ description
@
3 years ago
Replying to pbiron:
Is this discrepancy just a mistake, or is it because of the possibility of an object caching plugin returning something different?
As noted above, per the discussion in comment:2:ticket:23058, it is the latter: the core WP_Object_Cache::flush()
method always returns true
, but other implementations should be able to return false
too.
The same applies to WP_Object_Cache::set()
and wp_cache_set()
.
I'm open to any improvements here that could clarify this :)
#3
follow-up:
↓ 4
@
3 years ago
@SergeyBiryukov
And the way wp_cache_flush()
's return value could be different from WP_Object_Cache::flush()
is a caching plugin replaces the $wp_object_cache
global variable with an instance of their own, which could possibly return something different? Is that correct?
I'll think about how the DocBlock could be change to make that more clear.
#4
in reply to:
↑ 3
@
3 years ago
Replying to pbiron:
And the way
wp_cache_flush()
's return value could be different fromWP_Object_Cache::flush()
is a caching plugin replaces the$wp_object_cache
global variable with an instance of their own, which could possibly return something different? Is that correct?
Yes, that is correct.
The Docblock for
wp_cache_flush()
was changed to its current form as part of general Docblock improvements for 5.4 - #48303.Prior to this, the Docblock was changed from "Always returns true" to "False on failure, true on success" in [23328].
See @SergeyBiryukov's comment on #23058.