Changeset 59886
- Timestamp:
- 02/27/2025 11:17:38 PM (8 hours ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r59457 r59886 431 431 } 432 432 433 // Return an error message if query_var is not a string. 434 if ( ! is_string( $GLOBALS['wp']->query_vars['rest_route'] ) ) { 435 $rest_type_error = new WP_Error( 436 'rest_path_invalid_type', 437 __( 'The rest route parameter must be a string.' ), 438 array( 'status' => 400 ) 439 ); 440 wp_die( $rest_type_error ); 441 } 442 433 443 /** 434 444 * Whether this is a REST Request. -
trunk/tests/phpunit/tests/rest-api.php
r59457 r59886 2559 2559 $this->assertTrue( $registered ); 2560 2560 } 2561 2562 /** 2563 * @ticket 62932 2564 */ 2565 public function test_should_return_error_if_rest_route_not_string() { 2566 global $wp; 2567 2568 $wp = new stdClass(); 2569 2570 $wp->query_vars = array( 2571 'rest_route' => array( 'invalid' ), 2572 ); 2573 2574 $this->expectException( WPDieException::class ); 2575 2576 try { 2577 rest_api_loaded(); 2578 } catch ( WPDieException $e ) { 2579 $this->assertStringContainsString( 2580 'The rest route parameter must be a string.', 2581 $e->getMessage() 2582 ); 2583 throw $e; // Re-throw to satisfy expectException 2584 } 2585 } 2561 2586 }
Note: See TracChangeset
for help on using the changeset viewer.