Make WordPress Core


Ignore:
Timestamp:
09/02/2016 10:34:48 PM (8 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/tests/phpunit/tests/customize/manager.php

    r37942 r38513  
    304304        $this->assertTrue( $this->manager->prepare_setting_validity_for_js( true ) );
    305305        $error = new WP_Error();
    306         $error->add( 'bad_letter', 'Bad letter' );
    307         $error->add( 'bad_letter', 'Bad letra' );
     306        $error->add( 'bad_letter', 'Bad letter', 'A' );
     307        $error->add( 'bad_letter', 'Bad letra', 123 );
    308308        $error->add( 'bad_number', 'Bad number', array( 'number' => 123 ) );
    309309        $validity = $this->manager->prepare_setting_validity_for_js( $error );
     
    314314            $this->assertEquals( join( ' ', $messages ), $validity[ $code ]['message'] );
    315315            $this->assertArrayHasKey( 'data', $validity[ $code ] );
    316             $this->assertArrayHasKey( 'from_server', $validity[ $code ]['data'] );
     316            $this->assertEquals( $validity[ $code ]['data'], $error->get_error_data( $code ) );
    317317        }
    318318        $this->assertArrayHasKey( 'number', $validity['bad_number']['data'] );
Note: See TracChangeset for help on using the changeset viewer.