mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-03 16:50:13 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@38513 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -303,8 +303,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
function test_prepare_setting_validity_for_js() {
|
||||
$this->assertTrue( $this->manager->prepare_setting_validity_for_js( true ) );
|
||||
$error = new WP_Error();
|
||||
$error->add( 'bad_letter', 'Bad letter' );
|
||||
$error->add( 'bad_letter', 'Bad letra' );
|
||||
$error->add( 'bad_letter', 'Bad letter', 'A' );
|
||||
$error->add( 'bad_letter', 'Bad letra', 123 );
|
||||
$error->add( 'bad_number', 'Bad number', array( 'number' => 123 ) );
|
||||
$validity = $this->manager->prepare_setting_validity_for_js( $error );
|
||||
$this->assertInternalType( 'array', $validity );
|
||||
@@ -313,7 +313,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
|
||||
$this->assertInternalType( 'array', $validity[ $code ] );
|
||||
$this->assertEquals( join( ' ', $messages ), $validity[ $code ]['message'] );
|
||||
$this->assertArrayHasKey( 'data', $validity[ $code ] );
|
||||
$this->assertArrayHasKey( 'from_server', $validity[ $code ]['data'] );
|
||||
$this->assertEquals( $validity[ $code ]['data'], $error->get_error_data( $code ) );
|
||||
}
|
||||
$this->assertArrayHasKey( 'number', $validity['bad_number']['data'] );
|
||||
$this->assertEquals( 123, $validity['bad_number']['data']['number'] );
|
||||
|
||||
Reference in New Issue
Block a user