Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#15322 closed defect (bug) (fixed)

Skip category and tag queries on non posts in get_post_class()

Reported by: mfields's profile mfields Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.1
Component: Template Keywords: dev-feedback has-patch
Focuses: Cc:

Description

Where post_class() is used in a loop that iterates over an array of non-post objects get_post_class() will query for categories and tags regardless. Most times, these taxonomies are not registered with the post_type. This bug results in 2 additional queries per iteration. Please see attached (post-class-test.php) for an example using attachments.

Attachments (2)

post-class-test.php (1.8 KB) - added by mfields 13 years ago.
How to reproduce
15322.patch (1.1 KB) - added by mfields 13 years ago.

Download all attachments as: .zip

Change History (10)

@mfields
13 years ago

How to reproduce

@mfields
13 years ago

#1 @scribu
13 years ago

  • Milestone changed from Awaiting Review to 3.1

#2 @scribu
13 years ago

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

(In [16204]) Skip category/tag queries if post type doesn't support them. Props mfields. Fixes #15322

#3 @mfields
13 years ago

Scribu. No problem! Been trying to find ways to help out in here. What could I have been done better with the patch?

#4 @scribu
13 years ago

Well, the patch was made relative to the wp-includes folder, when it should have been made relative to the wp folder.

Less importantly, if( should have been if ( as per the coding standards.

#5 @mfields
13 years ago

I thought that might be the issue. I used Tortoise SVN to create the patch and there was not an option for anything like this. I have yet to use svn via the command line, but I can definitely learn.

Could you please explain how to do this?

I'll reread the coding standards.
I missed that bit before.

#6 @scribu
13 years ago

Unfortunately, there's no command line version of svn for Windows.

And I'm on Ubuntu, so I don't know how you should do it via TortoiseSVN.

#7 @nacin
13 years ago

mfields: Navigate to the site root, then right-click inside the directory (no file in particular), then create a patch from there. You'll get a diff relative to the root for all files modified.

#8 @mfields
13 years ago

nacin: That's easy. Thanks! Will definitely do this next time.

Note: See TracTickets for help on using tickets.