Make WordPress Core

Opened 15 years ago

Closed 12 years ago

#11630 closed defect (bug) (fixed)

0 is not a valid cache key for posts

Reported by: hakre's profile hakre Owned by: ryan's profile ryan
Milestone: 3.5 Priority: normal
Severity: normal Version: 2.9
Component: Cache API Keywords:
Focuses: Cc:

Description

input sanitization just in case.

Attachments (3)

11630.patch (531 bytes) - added by hakre 15 years ago.
11630.2.patch (1.5 KB) - added by hakre 15 years ago.
Alternate patch allowing 0 to better reflect the API. various comment and naming-consistency improvements.
11630.3.patch (595 bytes) - added by hakre 15 years ago.
pre-cache-get validation (based on feedback by DD32)

Download all attachments as: .zip

Change History (12)

@hakre
15 years ago

@hakre
15 years ago

Alternate patch allowing 0 to better reflect the API. various comment and naming-consistency improvements.

@hakre
15 years ago

pre-cache-get validation (based on feedback by DD32)

#1 @hakre
15 years ago

Reviewed the core code now for appeareances. Found only one where this applies (can not speak for third party code and this is an API function).

the .2 + .3 patch could be merged for an overall improvement.

#2 @hakre
15 years ago

  • Keywords dev-feedback added

Would like to see some developer feedback on this one.

#3 @Denis-de-Bernardy
15 years ago

  • Component changed from General to Cache
  • Keywords dev-feedback removed
  • Milestone changed from Future Release to 3.0
  • Owner set to ryan

how does 0 ever get fetched in the first place?

#4 @nacin
14 years ago

  • Keywords reporter-feedback close added
  • Milestone changed from 3.0 to Unassigned

#5 @nacin
14 years ago

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

Re-open with steps to reproduce etc.

#6 @Denis-de-Bernardy
14 years ago

  • Milestone set to 3.1
  • Resolution worksforme deleted
  • Status changed from closed to reopened

This is not per reproduce, this is per spec. We make the assumption, in the object cache in general, and memcached in particular, that a key is not empty. Zero is empty.

#7 @wpmuguru
14 years ago

Both 0 and '0' are valid array keys. The built in object cache uses isset() not empty() to determine if the requested object is stored in cache.

Recommending close.

#8 @ryan
14 years ago

  • Milestone changed from 3.1 to Future Release

Wouldn't we also want to avoid the useless query while we're at it?

#9 @nacin
12 years ago

  • Keywords has-patch reporter-feedback close removed
  • Milestone changed from Future Release to 3.5
  • Resolution set to fixed
  • Status changed from reopened to closed

This is now handled by WP_Post, which returns false in get_instance() if $post evaluates to false. See #21559.

Note: See TracTickets for help on using tickets.