Make WordPress Core

Ticket #62126: cache-wp-theme-json-sanitize-input.diff

File cache-wp-theme-json-sanitize-input.diff, 751 bytes (added by josephscott, 14 months ago)
  • wp-includes/class-wp-theme-json.php

    diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php
    index cbe266b..b7d903f 100644
    a b class WP_Theme_JSON { 
    938938         * @return array The sanitized output.
    939939         */
    940940        protected static function sanitize( $input, $valid_block_names, $valid_element_names, $valid_variations ) {
     941                static $input_cache = array();
     942
     943                $input_cache_key = md5( wp_json_encode( $input ) );
     944                if ( isset( $input_cache[ $input_cache_key ] ) ) {
     945                        return $input_cache[ $input_cache_key ];
     946                }
    941947
    942948                $output = array();
    943949
    class WP_Theme_JSON { 
    10581064                        }
    10591065                }
    10601066
     1067                $input_cache[ $input_cache_key ] = $output;
    10611068                return $output;
    10621069        }
    10631070