Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#33226 closed defect (bug) (invalid)

wrong $key utilization on WP_Object_Cache::add()

Reported by: lotti's profile Lotti Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2.3
Component: General Keywords:
Focuses: multisite Cc:

Description

Hello!
I noticed that the $key parameter is modified (in all of this class methods) in order to work with a multisite installation. that's fine.

But inside the add() method (differently from all the others), this modification is not reassigned to $key but to a new var called $id. $id is tested in _exists method (that's fine too), but suddendly is not used in set method! Instead is replaced by $key var, losing the multisite context (if applied)!

Thank you.

Change History (1)

#1 @jeremyfelt
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi @Lotti, thanks for the report.

In the add() method, the assignment of $key to $id is temporary and only used to check if data is already set for that key before passing it to set().

When $key is passed to set(), it is unaltered. set() then uses the same process to build the final key for multisite if necessary.

This avoids confusion from anyone calling add() or set() directly, as they only need to pass the original key.

Note: See TracTickets for help on using tickets.