[Bb-trac] [bbPress] #727: BB_Query has no method to append WHERE -
proposal for fix
bbPress
bb-trac at lists.bbpress.org
Fri Aug 10 06:22:31 GMT 2007
#727: BB_Query has no method to append WHERE - proposal for fix
----------------------+-----------------------------------------------------
Reporter: _ck_ | Owner:
Type: defect | Status: new
Priority: high | Milestone:
Component: Back-end | Version: 1.0-alpha (trunk)
Severity: normal | Keywords:
----------------------+-----------------------------------------------------
I've started to study the trunk and by changing all queries to BB_Query,
you've now stripped the ability to pre-filter results and everything must
be post-filtered, reducing result count (ie. front page topics, requested
50 but then post-filtering reduces it to 32, but if WHERE filter was used
for pre-filtering, a full 50 would be returned properly)
For example 0.8.2.1 function get_latest_topics has this
{{{
$where = apply_filters('get_latest_topics_where', $where);
}}}
But no such ability exists in the new trunk.
However here's a simple proposal to fix this:
Within BB_Query you could setup an apply_filters for whatever $id is
passed and change the query as appropriate. This actually would maintain
backwards compatibility too!
For example get_latest_topics() has the $id='get_latest_topics' so inside
BB_Query it would get applied appropriately:
{{{
(parse out $where from existing $query inside BB_Query)
if ($id) {$where = apply_filters($id.'_where', $where);}
(insert $where back into $query inside BB_Query and continue)
}}}
(of course it's not that simple given that the WHERE has already been
merged into the query passed to BB_Query but with some easy parsing, this
could be fixed)
The bonus is that now any $id passed can have a WHERE filter, even queries
that under 0.8.2.1 never had their own filter.
Hope you like it, I really, really, really would like to see it happen. If
need be, I can try to make the code for it.
--
Ticket URL: <http://trac.bbpress.org/ticket/727>
bbPress <http://bbpress.org/>
Innovative forum development
More information about the Bb-trac
mailing list