[wp-trac] [WordPress Trac] #24684: posts_clauses Query filter should have array as argument

WordPress Trac noreply at wordpress.org
Thu Jul 4 13:13:06 UTC 2013


#24684: posts_clauses Query filter should have array as argument
-------------------------+-----------------------------
 Reporter:  F J Kaiser   |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Query        |    Version:  3.5.2
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 Proposal to make it easier to modify the main, core-built query string.

 In its current state, the `posts_clauses` filter and its siblings
 (`posts_where`, etc.) all have a string to modify. This can be really
 tough as one has to

  * use a Regex
  * consider every possible (edge) case

 just to replace, add or remove parts of the SQL query. The reason for this
 is that `get_posts()` concatenates to the strings.

 What I'd like to propose is exchanging the `$where .= 'foobar';` string
 concatenations with an array core would add to: `$where[] = 'foobar';`.
 This would make it ''much'' easier to search through the different parts
 and replace/add/remove parts of it before the final query string is built.

 I'd like to propose this as two step process:

 1. I'd add a patch that replaces the string concatenations with the array
 building process. The current arguments would stay in place, but the
 arrays would be `implode()`d for the filter calls. Then we could add
 another, temporary filter that's named `posts_clauses_arrays`, that would
 hold all those arrays as subarrays of `$pieces`.
 2. If every developer is familiar with this, we could change the arguments
 for the sibling filters and possibly remove the `posts_clauses`-filter in
 favor of the `posts_clauses_array`-filter.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/24684>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list