Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#36332 closed defect (bug) (fixed)

Custom Logo: PHP warnings in add_theme_support

Reported by: obenland's profile obenland Owned by: obenland's profile obenland
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.6
Component: Themes Keywords: commit has-patch
Focuses: Cc:

Description

From the support forums: https://wordpress.org/support/topic/custom-logo-with-no-args-causing-php-warnings

Hi,

I'm testing the new WP4.5 development releases. Since current 4.5-RC1-37079 update I get these PHP warnings:

Warning: array_intersect_key(): Argument #1 is not an array in /srv/www/wordpress-default/wp-includes/theme.php on line 1570`

Warning: Cannot use a scalar value as an array in /srv/www/wordpress-default/wp-includes/theme.php on line 1570

Warning: Cannot use a scalar value as an array in /srv/www/wordpress-default/wp-includes/theme.php on line 1574

Warning: Cannot use a scalar value as an array in /srv/www/wordpress-default/wp-includes/theme.php on line 1575

I was able to trace these down to add_theme_support( 'custom-logo' );. When I use it in plain with no additional args, the PHP warnings above are thrown.

If I set custom logo with args, it works fine:

add_theme_support( 'custom-logo', array(
        'height'      => 160,
        'width'       => 160,
        'flex-height' => true,
        'flex-width'  => true,
) );

Is it required to set the args? Shouldn't it work without the args? What happens if no args are passed, will it take the full size of the uploaded image?

Thanks for addressing this issue!

Attachments (1)

36332.diff (405 bytes) - added by obenland 8 years ago.

Download all attachments as: .zip

Change History (6)

#1 @obenland
8 years ago

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

@obenland
8 years ago

#2 @obenland
8 years ago

  • Keywords commit has-patch added

36332.diff solves this problem like custom-header and custom-background do a few lines below.

#3 @ocean90
8 years ago

36332.diff makes sense.

This ticket was mentioned in Slack in #core by mike. View the logs.


8 years ago

#5 @jorbin
8 years ago

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

In 37092:

Prevent PHP Warnings when using Custom Logo with no params

The parsing of defaults assumes that $args will be an array. This solves it for Custom Logo the same way it is solved for custom-header and custom-background.

Props obenland.
Fixes #36332.

Note: See TracTickets for help on using tickets.