get_pages() may be run before init
|Reported by:||nacin||Owned by:|
A friend is using a theme that blew up in 3.0-beta. The theme called get_pages() deep in some options factory before post types were initialized, which causes get_pages() to return false as no (hierarchical) post types were registered.
The theme expected get_pages() to return an array. Our checks for a hierarchical post type and valid post status are both new, and they both would cause get_pages() to return false. Problem is, the results from get_pages() were immediately thrown into a foreach without casting it to an array (it always returned an array previously), which caused an E_WARNING and stopped redirection headers from being sent (i.e. login).
I wanted to ticket this because there's a lot going on here. Simple back compat fix would be to return array() instead of false in get_pages(), but that doesn't help actually return the pages that would have been returned in 2.9.