[wp-trac] [WordPress Trac] #63364: Ensure consistent $expire casting to (int) in wp_cache_set_multiple() and wp_cache_add_multiple() functions
WordPress Trac
noreply at wordpress.org
Mon Apr 28 12:14:19 UTC 2025
#63364: Ensure consistent $expire casting to (int) in wp_cache_set_multiple() and
wp_cache_add_multiple() functions
------------------------------+-----------------------------
Reporter: dilipbheda | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cache API | Version:
Severity: normal | Keywords: has-patch
Focuses: coding-standards |
------------------------------+-----------------------------
While reviewing the `wp_cache_*` functions (e.g., `wp_cache_add()`,
`wp_cache_add_multiple()`, `wp_cache_replace()`, `wp_cache_set()`,
`wp_cache_set_multiple()`), I noticed inconsistencies regarding how the
`$expire` parameter is handled:
- In some functions, `$expire` is explicitly cast to an integer `(int)
$expire` before passing to `$wp_object_cache` methods.
- In others, `$expire` is passed directly without casting.
The attached patch ensures **consistent integer casting** for the
`$expire` argument across all cache-related wrapper functions, improving
type safety and alignment with how object caches typically expect
expiration times.
**References:**
- `wp_cache_add()`
- `wp_cache_add_multiple()`
- `wp_cache_replace()`
- `wp_cache_set()`
- `wp_cache_set_multiple()`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63364>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list