Make WordPress Core


Ignore:
Timestamp:
09/02/2016 10:34:48 PM (9 years ago)
Author:
westonruter
Message:

Customize: Fix php warning due to WP_Customize_Manager::prepare_setting_validity_for_js() incorrectly assuming that WP_Error will only ever have arrays in its $error_data.

  • Eliminates the server mutating the a WP_Error's $error_data to merge-in a $from_server flag (since it may not be an array to begin with). Instead it defers to the client to add a fromServer param on any Notification instances created from server-sent errors.
  • Ensures that notifications will be re-rendered if a notification's message changes but the data and type remain the same.
  • Adds explicit support for the Notification class to have a setting property, ensuring that the property is set whereas previously it was dropped.

Fixes #37890.
Props westonruter, dlh.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r38470 r38513  
    10471047            $notification = array();
    10481048            foreach ( $validity->errors as $error_code => $error_messages ) {
    1049                 $error_data = $validity->get_error_data( $error_code );
    1050                 if ( is_null( $error_data ) ) {
    1051                     $error_data = array();
    1052                 }
    1053                 $error_data = array_merge(
    1054                     $error_data,
    1055                     array( 'from_server' => true )
    1056                 );
    10571049                $notification[ $error_code ] = array(
    10581050                    'message' => join( ' ', $error_messages ),
    1059                     'data' => $error_data,
     1051                    'data' => $validity->get_error_data( $error_code ),
    10601052                );
    10611053            }
Note: See TracChangeset for help on using the changeset viewer.