Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#13965 closed defect (bug) (fixed)

wp_get_nocache_headers should always return an array

Reported by: filosofo's profile filosofo Owned by: filosofo's profile filosofo
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0
Component: General Keywords: has-patch
Focuses: Cc:

Description

Apparently sometimes plugins use its filter and don't return an array.

WP should instead cast filtered results to array, so it always returns an array.

Attachments (1)

ensure_headers_array.13965.diff (658 bytes) - added by filosofo 13 years ago.

Download all attachments as: .zip

Change History (7)

#1 @johnbillion
13 years ago

It's up to plugins to return a correctly formatted value. Why cast the return value of this one particular filter? Is it any different to the others?

#2 @filosofo
13 years ago

The net number of casts to array is unchanged, just moved to make it more reliable.

In general, I think it's better to try to handle plugins' runtime errors (like this) gracefully, as opposed to say more "compile"-time errors (including the wrong file or using the wrong protocol, etc.).

That's because the latter kind of error is more likely to appear consistently during development and therefore get corrected. But the former might occur only in particular conditions.

#3 @filosofo
13 years ago

  • Owner set to filosofo
  • Status changed from new to accepted

#4 @filosofo
13 years ago

  • Milestone Awaiting Triage deleted
  • Resolution set to wontfix
  • Status changed from accepted to closed

#5 @nacin
13 years ago

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

The wontfix brought me to look at the patch. Looks solid. Definitely a better place for the cast.

#6 @nacin
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [16093]) Move an array cast further down the stack. props filosofo, fixes #13965.

Note: See TracTickets for help on using tickets.