- Timestamp:
- 03/02/2025 10:05:08 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
r59630 r59899 254 254 } 255 255 256 $is_head_request = $request->is_method( 'HEAD' ); 257 256 258 if ( wp_revisions_enabled( $parent ) ) { 257 259 $registered = $this->get_collection_params(); … … 286 288 if ( isset( $args['orderby'] ) && 'date' === $args['orderby'] ) { 287 289 $args['orderby'] = 'date ID'; 290 } 291 292 if ( $is_head_request ) { 293 // Force the 'fields' argument. For HEAD requests, only post IDs are required to calculate pagination. 294 $args['fields'] = 'ids'; 295 // Disable priming post meta for HEAD requests to improve performance. 296 $args['update_post_term_cache'] = false; 297 $args['update_post_meta_cache'] = false; 288 298 } 289 299 … … 336 346 } 337 347 338 $response = array(); 339 340 foreach ( $revisions as $revision ) { 341 $data = $this->prepare_item_for_response( $revision, $request ); 342 $response[] = $this->prepare_response_for_collection( $data ); 343 } 344 345 $response = rest_ensure_response( $response ); 348 if ( ! $is_head_request ) { 349 $response = array(); 350 351 foreach ( $revisions as $revision ) { 352 $data = $this->prepare_item_for_response( $revision, $request ); 353 $response[] = $this->prepare_response_for_collection( $data ); 354 } 355 356 $response = rest_ensure_response( $response ); 357 } else { 358 $response = new WP_REST_Response(); 359 } 346 360 347 361 $response->header( 'X-WP-Total', (int) $total_revisions ); … … 574 588 575 589 setup_postdata( $post ); 590 591 // Don't prepare the response body for HEAD requests. 592 if ( $request->is_method( 'HEAD' ) ) { 593 /** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php */ 594 return apply_filters( 'rest_prepare_revision', new WP_REST_Response(), $post, $request ); 595 } 576 596 577 597 $fields = $this->get_fields_for_response( $request );
Note: See TracChangeset
for help on using the changeset viewer.