Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#50496 closed defect (bug) (fixed)

The pages list table uselessly queries post formats

Reported by: chouby's profile Chouby Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.2
Component: Posts, Post Types Keywords: has-patch
Focuses: administration, performance Cc:

Description

On the pages list table, Query Monitor reports unexpectedly this DB query:

SELECT t.*, tt.*
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt
ON t.term_id = tt.term_id
WHERE tt.taxonomy IN ('post_format')
AND tt.count > 0
ORDER BY t.name ASC

As the 'post_format' taxonomy is not defined for the 'page' post type, there should be no need to query post formats.

Attachments (1)

50496.diff (1.1 KB) - added by Chouby 4 years ago.

Download all attachments as: .zip

Change History (5)

@Chouby
4 years ago

#1 @Chouby
4 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
4 years ago

  • Component changed from Administration to Posts, Post Types
  • Focuses administration added

#3 @SergeyBiryukov
4 years ago

  • Milestone changed from Awaiting Review to 5.5

#4 @SergeyBiryukov
4 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 48203:

Posts, Post Types: Return early from WP_Posts_List_Table::formats_dropdown() if the post type does not support post formats.

This avoids an unnecessary database query for the post_format taxonomy.

Props Chouby.
Fixes #50496.

Note: See TracTickets for help on using tickets.