- Timestamp:
- 10/12/2023 03:12:09 PM (14 months ago)
- Location:
- branches/5.6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.6
- Property svn:mergeinfo changed
/trunk merged: 56833-56838
- Property svn:mergeinfo changed
-
branches/5.6/src/wp-includes/rest-api/class-wp-rest-server.php
r49610 r56882 346 346 347 347 /** 348 * Send nocache headers on authenticated requests.349 *350 * @since 4.4.0351 *352 * @param bool $rest_send_nocache_headers Whether to send no-cache headers.353 */354 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );355 if ( $send_no_cache_headers ) {356 foreach ( wp_get_nocache_headers() as $header => $header_value ) {357 if ( empty( $header_value ) ) {358 $this->remove_header( $header );359 } else {360 $this->send_header( $header, $header_value );361 }362 }363 }364 365 /**366 348 * Filters whether the REST API is enabled. 367 349 * … … 429 411 * header. 430 412 */ 413 $method_overridden = false; 431 414 if ( isset( $_GET['_method'] ) ) { 432 415 $request->set_method( $_GET['_method'] ); 433 416 } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) { 434 417 $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ); 418 $method_overridden = true; 435 419 } 436 420 … … 490 474 */ 491 475 $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this ); 476 477 /** 478 * Filters whether to send nocache headers on a REST API request. 479 * 480 * @since 4.4.0 481 * @since 6.x.x Moved the block to catch the filter added on rest_cookie_check_errors() from rest-api.php 482 * 483 * @param bool $rest_send_nocache_headers Whether to send no-cache headers. 484 */ 485 $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() ); 486 487 // send no cache headers if the $send_no_cache_headers is true 488 // OR if the HTTP_X_HTTP_METHOD_OVERRIDE is used but resulted a 4xx response code. 489 if ( $send_no_cache_headers || ( true === $method_overridden && strpos( $code, '4' ) === 0 ) ) { 490 foreach ( wp_get_nocache_headers() as $header => $header_value ) { 491 if ( empty( $header_value ) ) { 492 $this->remove_header( $header ); 493 } else { 494 $this->send_header( $header, $header_value ); 495 } 496 } 497 } 492 498 493 499 if ( ! $served ) {
Note: See TracChangeset
for help on using the changeset viewer.