[wp-trac] [WordPress Trac] #15063: Add a "context" property to WP_Query as a 2nd param to its constructor

WordPress Trac wp-trac at lists.automattic.com
Sat Oct 9 00:36:39 UTC 2010


#15063: Add a "context" property to  WP_Query as a 2nd param to its constructor
--------------------------+-------------------------------------------------
 Reporter:  mikeschinkel  |        Owner:                 
     Type:  enhancement   |       Status:  closed         
 Priority:  normal        |    Milestone:  Awaiting Review
Component:  Post Types    |      Version:                 
 Severity:  normal        |   Resolution:  wontfix        
 Keywords:                |  
--------------------------+-------------------------------------------------

Comment(by mikeschinkel):

 Replying to [comment:9 Denis-de-Bernardy]:
 > Well, if it's the main loop, yipou can always check for $wp_query ===
 $wp_the_query. For everything else, assume it's a plugin, and not yours,
 unless the context, or ID, or whatever, is specified.

 Yes, there is (almost) always ''something'' I can check.  The problem is
 '''''reliably''''' discovering what that ''"something"'' is in each case.

 Currently you have to program ''by artifact'' and ''by assumption'', i.e.
 ''"I'll check for `$pagenow=-'edit.php'` and `$post_type=='movie'` that'll
 be good enough, right?"'' only to find out that after the site is deployed
 I also needed to check for something else.

 The current situation is much like trying to prove there is not a needle
 in that haystack vs. just finding it.

 In a blog world, this isn't a big issue because there are only a few use-
 case patterns and WordPress has mostly nailed them. But with WordPress
 being used as a CMS the number of patterns to address are at least an
 order of magnitude greater, if not two and WordPress is a long way from
 having nailed them.

 It doesn't create a very good impression of WordPress when I tell my
 clients ''"Well, I can't be 100% sure that the code I wrote won't have an
 issue until after you've used it for a while to see if I missed any
 assumptions."''  I want to be able to say ''"I know that code works,
 period"'' but without some sort of explicit context to inspect that's not
 possible. (Note, I'd be happy to see other implementations than what I
 proposed, but we need ''something.'')

 Said another way, it's why local variables are useful vs. everything being
 global. There once was a time when programming languages didn't have local
 variable scope; what a nightmare that was.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15063#comment:10>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list