Changeset 59899 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
- 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-global-styles-revisions-controller.php
r59630 r59899 164 164 } 165 165 166 $is_head_request = $request->is_method( 'HEAD' ); 167 166 168 if ( wp_revisions_enabled( $parent ) ) { 167 169 $registered = $this->get_collection_params(); … … 185 187 $query_args[ $wp_param ] = $request[ $api_param ]; 186 188 } 189 } 190 191 if ( $is_head_request ) { 192 // Force the 'fields' argument. For HEAD requests, only post IDs are required to calculate pagination. 193 $query_args['fields'] = 'ids'; 194 // Disable priming post meta for HEAD requests to improve performance. 195 $query_args['update_post_term_cache'] = false; 196 $query_args['update_post_meta_cache'] = false; 187 197 } 188 198 … … 229 239 } 230 240 231 $response = array(); 232 233 foreach ( $revisions as $revision ) { 234 $data = $this->prepare_item_for_response( $revision, $request ); 235 $response[] = $this->prepare_response_for_collection( $data ); 236 } 237 238 $response = rest_ensure_response( $response ); 241 if ( ! $is_head_request ) { 242 $response = array(); 243 244 foreach ( $revisions as $revision ) { 245 $data = $this->prepare_item_for_response( $revision, $request ); 246 $response[] = $this->prepare_response_for_collection( $data ); 247 } 248 249 $response = rest_ensure_response( $response ); 250 } else { 251 $response = new WP_REST_Response(); 252 } 239 253 240 254 $response->header( 'X-WP-Total', (int) $total_revisions ); … … 276 290 */ 277 291 public function prepare_item_for_response( $post, $request ) { 292 // Don't prepare the response body for HEAD requests. 293 if ( $request->is_method( 'HEAD' ) ) { 294 return new WP_REST_Response(); 295 } 296 278 297 $parent = $this->get_parent( $request['parent'] ); 279 298 $global_styles_config = $this->get_decoded_global_styles_json( $post->post_content );
Note: See TracChangeset
for help on using the changeset viewer.