Changeset 48642
- Timestamp:
- 07/27/2020 06:44:14 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-request.php
r48102 r48642 409 409 410 410 foreach ( $order as $type ) { 411 if ( array_key_exists( $key, $this->params[ $type ] ) ) {411 if ( is_array( $this->params[ $type ] ) && array_key_exists( $key, $this->params[ $type ] ) ) { 412 412 return true; 413 413 } … … 434 434 435 435 foreach ( $order as $type ) { 436 if ( 'defaults' !== $type && array_key_exists( $key, $this->params[ $type ] ) ) {436 if ( 'defaults' !== $type && is_array( $this->params[ $type ] ) && array_key_exists( $key, $this->params[ $type ] ) ) { 437 437 $this->params[ $type ][ $key ] = $value; 438 438 $found_key = true; -
trunk/tests/phpunit/tests/rest-api/rest-request.php
r47559 r48642 766 766 $this->assertEquals( array( 'param' => 'new_value' ), $request->get_query_params() ); 767 767 } 768 769 /** 770 * @ticket 50786 771 */ 772 public function test_set_param_with_invalid_json() { 773 $request = new WP_REST_Request(); 774 $request->add_header( 'content-type', 'application/json' ); 775 $request->set_method( 'POST' ); 776 $request->set_body( '' ); 777 $request->set_param( 'param', 'value' ); 778 779 $this->assertTrue( $request->has_param( 'param' ) ); 780 $this->assertEquals( 'value', $request->get_param( 'param' ) ); 781 } 768 782 }
Note: See TracChangeset
for help on using the changeset viewer.