Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#11439 closed defect (bug) (fixed)

get_body_class() does unnecessary work

Reported by: filosofo's profile filosofo Owned by: ryan's profile ryan
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9
Component: Template Keywords: has-patch tested
Focuses: Cc:


get_blog_class() calls setup_postdata() unnecessarily, when there's an API in WP_Query for exactly this purpose.

Patch fixes.

Attachments (3)

11439.patch (1.8 KB) - added by hakre 13 years ago.
Patch without SQL modification
11439.diff (2.5 KB) - added by Denis-de-Bernardy 13 years ago.
unnecessary_global_tampering.11439.diff (1.7 KB) - added by filosofo 13 years ago.
use Denis's approach to the private page issue

Download all attachments as: .zip

Change History (13)

#1 @hakre
13 years ago

  • Keywords tested added

Tested against current head. Works. Then I reviewed the code and AND post_status != 'private' looks to me like this fixes some other bug. I have created an additional patch w/o that segment. If applied, a new ticket might be created based on the finding by filosofo.

13 years ago

Patch without SQL modification

#2 @hakre
13 years ago

  • Keywords get_body_class removed

#3 @hakre
13 years ago

  • Keywords tested removed

My patch is wrong, global $wpdb is still needed and should not be removed.

#4 @Denis-de-Bernardy
13 years ago

I like the first patch, though I'd suggest using get_queried_object() directly.

#5 @Denis-de-Bernardy
13 years ago

  • Keywords needs-patch added; has-patch removed

I also get a fatal error when I apply it.

13 years ago

use Denis's approach to the private page issue

#6 @filosofo
13 years ago

I incorporated Denis's suggestion for handling private pages, fixed the fatal error, but left out the unrelated stuff that Denis has in 11439.diff.

unnecessary_global_tampering.11439.diff should be the best patch now. Agreed?

#7 @Denis-de-Bernardy
13 years ago

agreed. marking as tested, too. played around with static pages, attachment pages, and so on. nothing crept up.

I'll open a separate ticket related to the rest.

#8 @filosofo
13 years ago

  • Keywords has-patch tested added; needs-patch removed

#10 @ryan
13 years ago

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

(In [12877]) Avoid call to setup_postdata(). Use get_queried_object_id(). Props filosofo. fixes #11439

Note: See TracTickets for help on using tickets.