posts_clauses Query filter should have array as argument
|Reported by:||F J Kaiser||Owned by:|
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:
- 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.
- 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.