[wp-trac] [WordPress Trac] #23833: Add a unique ID or NAME to target queries .

WordPress Trac noreply at wordpress.org
Fri Apr 12 13:28:52 UTC 2013


#23833: Add a unique ID or NAME to target queries .
-------------------------+------------------------------
 Reporter:  krembo99     |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Query        |     Version:
 Severity:  normal       |  Resolution:
 Keywords:               |
-------------------------+------------------------------
Changes (by prettyboymp):

 * cc: mpretty@… (added)


Comment:

 I don't like the idea of names or context being referenced within WP_Query
 (or even query filters) because a name or context isn't explicit.  It's
 already bad enough that WP_Query checks globals to modify the query for
 is_admin and is_main_query.  The query_vars passed to wp_query should be
 modified before the WP_Query instance is created.

 At this layer in the platform, the query_vars for a WP_Query instance
 should be explicit about what data the query will return.  When a WP_Query
 instance is made with a set of query_vars it should ALWAYS return the same
 data, regardless of the context.

 Ideally, there should be a factory method for WP_Query.  With this, a
 factory could accept a context and append/modify the query_vars before
 creating the WP_Query instance.  This would allow plugin authors to watch
 for a specific context in the factory method, apply query_vars that
 explicitly say how they're modifying the query, and add filters that react
 to those query_vars.

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


More information about the wp-trac mailing list