From 2b94ffdbc9eb54acd31683078421315837f3ec09 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Thu, 17 Feb 2022 18:47:02 +0000 Subject: [PATCH] Editor: Adds an additional check to guard against incompete presets. Adds an additional guard to ensure the value of `$preset_metadata['value_key']` actually exists as a key in the `$preset` array. Fixes `Warning: Undefined array key` error. Intentionally adds the check into the existing `isset()` as it's native to PHP, more efficient, and a good pattern. Follow-up [52049]. Props jeherve, swissspidy, sergeybiryukov, jrf. Fixes #55161. Built from https://develop.svn.wordpress.org/trunk@52763 git-svn-id: http://core.svn.wordpress.org/trunk@52352 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme-json.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index 50552e68b7..06dd33e43c 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -1092,7 +1092,7 @@ class WP_Theme_JSON { $slug = _wp_to_kebab_case( $preset['slug'] ); $value = ''; - if ( isset( $preset_metadata['value_key'] ) ) { + if ( isset( $preset_metadata['value_key'], $preset[ $preset_metadata['value_key'] ] ) ) { $value_key = $preset_metadata['value_key']; $value = $preset[ $value_key ]; } elseif ( @@ -1837,7 +1837,7 @@ class WP_Theme_JSON { sanitize_html_class( $preset['slug'] ) === $preset['slug'] ) { $value = null; - if ( isset( $preset_metadata['value_key'] ) ) { + if ( isset( $preset_metadata['value_key'], $preset[ $preset_metadata['value_key'] ] ) ) { $value = $preset[ $preset_metadata['value_key'] ]; } elseif ( isset( $preset_metadata['value_func'] ) && diff --git a/wp-includes/version.php b/wp-includes/version.php index 5476ef92eb..aa1c1cd7c4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-52760'; +$wp_version = '6.0-alpha-52763'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.