Make WordPress Core

Opened 3 weeks ago

Closed 3 weeks ago

#63364 closed defect (bug) (fixed)

Ensure consistent $expire casting to (int) in wp_cache_set_multiple() and wp_cache_add_multiple() functions

Reported by: dilipbheda's profile dilipbheda Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Cache API Keywords: has-patch
Focuses: coding-standards Cc:

Description

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()

Change History (3)

This ticket was mentioned in PR #8749 on WordPress/wordpress-develop by @dilipbheda.


3 weeks ago
#1

#2 @SergeyBiryukov
3 weeks ago

  • Milestone changed from Awaiting Review to 6.9

#3 @SergeyBiryukov
3 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 60206:

Cache API: Consistently pass the $expire value as an integer in cache functions.

Follow-up to [52700].

Props dilipbheda.
Fixes #63364.

Note: See TracTickets for help on using tickets.