From c0b41d8feecc8957f88d52af78c94d1cab2b7ae7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 3 Nov 2016 00:00:32 +0000 Subject: [PATCH] Customize: Prevent PHP warning in applying widget starter content on fresh installs. Fixes PHP warning triggered by calling `max()` on `$widget_numbers` when there are no widget instances of the type yet. Also makes sure that widget instances start at 2 instead of 1. See #38114. Built from https://develop.svn.wordpress.org/trunk@39100 git-svn-id: http://core.svn.wordpress.org/trunk@39042 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-customize-manager.php | 8 ++++++-- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-customize-manager.php b/wp-includes/class-wp-customize-manager.php index f96a220349..c701364149 100644 --- a/wp-includes/class-wp-customize-manager.php +++ b/wp-includes/class-wp-customize-manager.php @@ -928,8 +928,12 @@ final class WP_Customize_Manager { // Find the max widget number for this type. $widget_numbers = array_keys( $settings ); - $widget_numbers[] = 1; - $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers ); + if ( count( $widget_numbers ) > 0 ) { + $widget_numbers[] = 1; + $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers ); + } else { + $max_widget_numbers[ $id_base ] = 1; + } } $max_widget_numbers[ $id_base ] += 1; diff --git a/wp-includes/version.php b/wp-includes/version.php index 6b8d8530fe..5bae15fa8b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta1-39099'; +$wp_version = '4.7-beta1-39100'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.