- Timestamp:
- 10/12/2023 03:14:45 PM (14 months ago)
- Location:
- branches/5.8
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.8
- Property svn:mergeinfo changed
/trunk merged: 56833-56838
- Property svn:mergeinfo changed
-
branches/5.8/src/wp-includes/rest-api/class-wp-rest-server.php
r51317 r56884 332 332 333 333 /** 334 * Filters whether to send nocache headers on a REST API request.335 *336 * @since 4.4.0337 *338 * @param bool $rest_send_nocache_headers Whether to send no-cache headers.339 */340 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );341 if ( $send_no_cache_headers ) {342 foreach ( wp_get_nocache_headers() as $header => $header_value ) {343 if ( empty( $header_value ) ) {344 $this->remove_header( $header );345 } else {346 $this->send_header( $header, $header_value );347 }348 }349 }350 351 /**352 334 * Filters whether the REST API is enabled. 353 335 * … … 403 385 * header. 404 386 */ 387 $method_overridden = false; 405 388 if ( isset( $_GET['_method'] ) ) { 406 389 $request->set_method( $_GET['_method'] ); 407 390 } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { 408 391 $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); 392 $method_overridden = true; 409 393 } 410 394 … … 464 448 */ 465 449 $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); 450 451 /** 452 * Filters whether to send nocache headers on a REST API request. 453 * 454 * @since 4.4.0 455 * @since 6.x.x Moved the block to catch the filter added on rest_cookie_check_errors() from rest-api.php 456 * 457 * @param bool $rest_send_nocache_headers Whether to send no-cache headers. 458 */ 459 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); 460 461 // send no cache headers if the $send_no_cache_headers is true 462 // OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4xx response code. 463 if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) { 464 foreach ( wp_get_nocache_headers() as $header => $header_value ) { 465 if ( empty( $header_value ) ) { 466 $this->remove_header( $header ); 467 } else { 468 $this->send_header( $header, $header_value ); 469 } 470 } 471 } 466 472 467 473 if ( ! $served ) {
Note: See TracChangeset
for help on using the changeset viewer.