WordPress.org

Make WordPress Core

Opened 22 months ago

Last modified 22 months ago

#24613 new defect (bug)

get_uploaded_header_images returns empty

Reported by: mhzmaster Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5.1
Component: Customize Keywords: reporter-feedback
Focuses: Cc:

Description

Should be a simple fix. I wanted to document a bug I found which causes the built-in Random Header feature to break in WordPress 3.5.1 and trunk.

The call to get_uploaded_header_images() in _get_random_header_data() always returns an empty array, causing get_random_header_image() and get_header_image() to also return null. This results in an empty header image in themes which should support custom headers, including random ones.

I've traced the error to improper arguments to get_post() within the body of get_uploaded_header_images()

wp-includes/theme.php:1003:

	$headers = get_posts( array( 'post_type' => 'attachment', 'meta_key' => '_wp_attachment_is_custom_header', 'meta_value' => get_option('stylesheet'), 'orderby' => 'none', 'nopaging' => true ) );

the 'orderby' => 'none' parameter is not a valid argument and causes the query to fail.
with the 'orderby' parameter removed, get_uploaded_header_images() works as intended and header images are shown properly.

I've patched my install of wordpress successfully. A bugfix would be much appreciated.

Thanks!

Change History (1)

comment:1 @SergeyBiryukov22 months ago

  • Component changed from General to Appearance
  • Keywords reporter-feedback added; needs-patch removed

the 'orderby' => 'none' parameter is not a valid argument and causes the query to fail.

Could not reproduce on a clean install.

'none' is a valid value for orderby parameter: tags/3.5.1/wp-includes/query.php#L2339. It's also documented in Codex.

Note: See TracTickets for help on using tickets.