Ticket #13965 (closed defect (bug): fixed)

Opened 2 years ago

Last modified 19 months ago

wp_get_nocache_headers should always return an array

Reported by: filosofo Owned by: filosofo
Priority: normal Milestone: 3.1
Component: General Version: 3.0
Severity: normal Keywords: has-patch
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

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

Change History

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?

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.

  • Owner set to filosofo
  • Status changed from new to accepted
  • Status changed from accepted to closed
  • Resolution set to wontfix
  • Milestone Awaiting Triage deleted
  • Status changed from closed to reopened
  • Resolution wontfix deleted
  • Milestone set to 3.1

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

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

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

Note: See TracTickets for help on using tickets.