Make WordPress Core

Changeset 52764


Ignore:
Timestamp:
02/17/2022 06:54:37 PM (3 years ago)
Author:
hellofromTonya
Message:

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.
Merges [52763] to the 5.9 branch.
Fixes #55161.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-includes/class-wp-theme-json.php

    r52759 r52764  
    10931093
    10941094                $value = '';
    1095                 if ( isset( $preset_metadata['value_key'] ) ) {
     1095                if ( isset( $preset_metadata['value_key'], $preset[ $preset_metadata['value_key'] ] ) ) {
    10961096                    $value_key = $preset_metadata['value_key'];
    10971097                    $value     = $preset[ $value_key ];
     
    18381838                    ) {
    18391839                        $value = null;
    1840                         if ( isset( $preset_metadata['value_key'] ) ) {
     1840                        if ( isset( $preset_metadata['value_key'], $preset[ $preset_metadata['value_key'] ] ) ) {
    18411841                            $value = $preset[ $preset_metadata['value_key'] ];
    18421842                        } elseif (
Note: See TracChangeset for help on using the changeset viewer.