Make WordPress Core


Ignore:
Timestamp:
12/01/2025 03:01:27 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Options, Meta APIs: Revert additional request validity handling that was added to the /wp/v2/settings REST API route. This change needs more work to account for URL query parameters used in place of body data.

This reverts [60357] and [60301].

Reviewed by johnbillion, SergeyBiryukov.
Merges [61324] to the 6.9 branch.

See #41604.

Location:
branches/6.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.9

  • branches/6.9/tests/phpunit/tests/rest-api/rest-settings-controller.php

    r61178 r61335  
    386386
    387387    /**
    388      * Settings can't be created
     388     * @doesNotPerformAssertions
    389389     */
    390390    public function test_create_item() {
    391         wp_set_current_user( self::$administrator );
    392 
    393         $request = new WP_REST_Request( 'POST', '/wp/v2/settings' );
    394         $request->set_param( 'new_setting', 'New value' );
    395         $response = rest_get_server()->dispatch( $request );
    396 
    397         $this->assertSame( 400, $response->get_status() );
    398     }
    399 
    400     /**
    401      * @ticket 41604
    402      */
     391        // Controller does not implement create_item().
     392    }
     393
    403394    public function test_update_item() {
    404395        wp_set_current_user( self::$administrator );
    405 
    406396        $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
    407397        $request->set_param( 'title', 'The new title!' );
     
    412402        $this->assertSame( 'The new title!', $data['title'] );
    413403        $this->assertSame( get_option( 'blogname' ), $data['title'] );
    414     }
    415 
    416     /**
    417      * @ticket 41604
    418      */
    419     public function test_update_item_with_global_parameters_present() {
    420         wp_set_current_user( self::$administrator );
    421 
    422         $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
    423         $request->set_param( 'title', 'The new title!' );
    424         $request->set_url_params( array( '_locale' => 'user' ) );
    425         $response = rest_get_server()->dispatch( $request );
    426         $data     = $response->get_data();
    427 
    428         $this->assertSame( 200, $response->get_status() );
    429         $this->assertSame( 'The new title!', $data['title'] );
    430         $this->assertSame( get_option( 'blogname' ), $data['title'] );
    431     }
    432 
    433     /**
    434      * @ticket 41604
    435      */
    436     public function test_update_item_with_empty_body() {
    437         wp_set_current_user( self::$administrator );
    438 
    439         $request  = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
    440         $response = rest_get_server()->dispatch( $request );
    441         $data     = $response->get_data();
    442 
    443         $this->assertSame( 400, $response->get_status() );
    444     }
    445 
    446     /**
    447      * @ticket 41604
    448      */
    449     public function test_update_nonexistent_item() {
    450         wp_set_current_user( self::$administrator );
    451 
    452         $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
    453         $request->set_param( 'i_do_no_exist', 'New value' );
    454         $response = rest_get_server()->dispatch( $request );
    455 
    456         $this->assertSame( 400, $response->get_status() );
    457     }
    458 
    459     /**
    460      * @ticket 41604
    461      */
    462     public function test_update_partially_valid_items() {
    463         wp_set_current_user( self::$administrator );
    464 
    465         $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' );
    466         $request->set_param( 'title', 'The new title!' );
    467         $request->set_param( 'i_do_no_exist', 'New value' );
    468         $response = rest_get_server()->dispatch( $request );
    469 
    470         $this->assertSame( 400, $response->get_status() );
    471404    }
    472405
Note: See TracChangeset for help on using the changeset viewer.