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
This commit is contained in:
hellofromTonya 2022-02-17 18:47:02 +00:00
parent 8f904628e9
commit 2b94ffdbc9
2 changed files with 3 additions and 3 deletions

View File

@ -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'] ) &&

View File

@ -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.