Changeset 64527 for trunk/src/wp-includes/rest-api/class-wp-rest-server.php
- Timestamp:
- 10/19/2026 05:39:57 PM (33 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/class-wp-rest-server.php
r64490 r64527 21 21 * @since 4.4.0 22 22 * 23 * @phpstan-import-type Target_Hints from WP_REST_Response 24 * 23 25 * @phpstan-type Endpoint_Arg array{ 24 26 * required?: bool, … … 33 35 * callback?: callable|null, 34 36 * permission_callback?: callable|null, 37 * validate_callback?: callable|null, 35 38 * args: array<non-empty-string, Endpoint_Arg>, 36 39 * accept_json: bool, … … 271 274 * @param int|null $status Optional. HTTP status code to send. Default null. 272 275 * @return string JSON representation of the error. 276 * 277 * @phpstan-param int<100, 599>|null $status 273 278 */ 274 279 protected function json_error( $code, $message, $status = null ) { … … 532 537 * OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4xx response code. 533 538 */ 534 if ( $send_no_cache_headers || ( true === $method_overridden && str_starts_with( $code, '4' )) ) {539 if ( $send_no_cache_headers || ( true === $method_overridden && $code >= 400 && $code < 500 ) ) { 535 540 foreach ( wp_get_nocache_headers() as $header => $header_value ) { 536 541 if ( empty( $header_value ) ) { … … 702 707 * @since 6.7.0 703 708 * 704 * @param array $link The link to get target hints for. 705 * @return array|null 709 * @param array<string, mixed> $link The link to get target hints for. 710 * @return array<string, string[]>|null Map of hint name to list of values, which is empty if the route 711 * allows no methods. Null if the link already has an `allow` hint, 712 * or its URL does not resolve to a valid REST API request. 713 * 714 * @phpstan-param array{ 715 * href: non-falsy-string, 716 * targetHints?: Target_Hints, 717 * ...<string, mixed> 718 * } $link 719 * @phpstan-return array<lowercase-string, list<string>>|null 706 720 */ 707 721 protected static function get_target_hints_for_link( $link ) { … … 1214 1228 * 1215 1229 * @param WP_REST_Request $request The request object. 1216 * @return array|WP_Error The route and request handler on success or a WP_Error instance if no handler was found. 1230 * @return array<int, string|array<string, mixed>>|WP_Error The route and request handler on success or a WP_Error instance if no handler was found. 1231 * 1232 * @phpstan-return array{non-empty-string, Route_Handler}|WP_Error 1217 1233 */ 1218 1234 protected function match_request_to_handler( $request ) { … … 1295 1311 * @since 5.6.0 1296 1312 * 1297 * @param WP_REST_Request $request The request object.1298 * @param string $route The matched route regex.1299 * @param array $handler The matched route handler.1300 * @param WP_Error|null $response The current error object if any.1313 * @param WP_REST_Request $request The request object. 1314 * @param string $route The matched route regex. 1315 * @param array<string, mixed> $handler The matched route handler. 1316 * @param WP_Error|null $response The current error object if any. 1301 1317 * @return WP_REST_Response 1318 * 1319 * @phpstan-param Route_Handler $handler 1302 1320 */ 1303 1321 protected function respond_to_request( $request, $route, $handler, $response ) { … … 1316 1334 * @param WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response Result to send to the client. 1317 1335 * Usually a WP_REST_Response or WP_Error. 1318 * @param array $handler Route handler used for the request.1336 * @param array<string, mixed> $handler Route handler used for the request. 1319 1337 * @param WP_REST_Request $request Request used to generate the response. 1338 * 1339 * @phpstan-param Route_Handler $handler 1320 1340 */ 1321 1341 $response = apply_filters( 'rest_request_before_callbacks', $response, $handler, $request ); … … 1345 1365 * @since 4.5.0 Added `$route` and `$handler` parameters. 1346 1366 * 1347 * @param mixed $dispatch_result Dispatch result, will be used if not empty. 1348 * @param WP_REST_Request $request Request used to generate the response. 1349 * @param string $route Route matched for the request. 1350 * @param array $handler Route handler used for the request. 1367 * @param mixed $dispatch_result Dispatch result, will be used if not empty. 1368 * @param WP_REST_Request $request Request used to generate the response. 1369 * @param string $route Route matched for the request. 1370 * @param array<string, mixed> $handler Route handler used for the request. 1371 * 1372 * @phpstan-param Route_Handler $handler 1351 1373 */ 1352 1374 $dispatch_result = apply_filters( 'rest_dispatch_request', null, $request, $route, $handler ); … … 1378 1400 * @param WP_REST_Response|WP_HTTP_Response|WP_Error|mixed $response Result to send to the client. 1379 1401 * Usually a WP_REST_Response or WP_Error. 1380 * @param array $handler Route handler used for the request.1402 * @param array<string, mixed> $handler Route handler used for the request. 1381 1403 * @param WP_REST_Request $request Request used to generate the response. 1404 * 1405 * @phpstan-param Route_Handler $handler 1382 1406 */ 1383 1407 $response = apply_filters( 'rest_request_after_callbacks', $response, $handler, $request ); … … 1988 2012 * 1989 2013 * @param int $code HTTP status. 2014 * 2015 * @phpstan-param int<100, 599> $code 1990 2016 */ 1991 2017 protected function set_status( $code ) { … … 2018 2044 * @since 4.4.0 2019 2045 * 2020 * @param array $headers Map of header name to header value.2046 * @param array<string, string> $headers Map of header name to header value. 2021 2047 */ 2022 2048 public function send_headers( $headers ) {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)