View Issue Details

IDProjectCategoryView StatusLast Update
0024600mantisbtfilterspublic2020-03-15 15:23
Reporterfman Assigned Tocproensa  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.14.0 
Target Version2.24.0Fixed in Version2.24.0 
Summary0024600: BugFilterQuery - issue? - trying to add join & where conditions
Description

I need to do a customization on the query used to extract rows for the bug listing (view feature).

Because I was not able (my fault) to understand where the query is build and setted, the best solution I've found was to do changes on function filter_get_bug_rows()

I've tried to use $t_filter_query->add_join() and $t_filter_query->add_where() after :

# build a filter query, here for counting results
$t_filter_query = new BugFilterQuery(
        $t_filter,
        array(
            'query_type' => BugFilterQuery::QUERY_TYPE_LIST,
            'project_id' => $p_project_id,
            'user_id' => $p_user_id,
            'use_sticky' => $p_show_sticky
            )
        ); 

Everything OK retrieving COUNT, but when doing $t_rows = $t_filter_query->fetch_all() it seems that the pieces I've added via ->add_join(); and ->add_where() were ignored.

Do you have any tip/hint/pointer to some documentation?
Right now IMHO it seems a bug

best regards

TagsNo tags attached.

Activities

cproensa

cproensa

2018-07-10 16:16

developer   ~0060237

try:
$t_filter_query->set_query_type( BugFilterQuery::QUERY_TYPE_LIST )
after adding your "join" and "where" parts, to rebuild the inner sql

if it works, probably we could give it a thought to be smarter and rebuild the internal query, automatically, at some point after adding external parts and before the actual execute

cproensa

cproensa

2018-07-10 16:20

developer   ~0060238

Because I was not able (my fault) to understand where the query is build and setted

if you follow the BugFilterQuery class, it's build_main() method where all the filter properties are evaluated and added one by one

fman

fman

2018-07-10 16:30

reporter   ~0060239

Thanks a lot for your fast answer.
I'm going to try what is explained on note 60237 and provide feedback

cproensa

cproensa

2018-12-23 10:21

developer   ~0061093

@fman
Can you try this branch: https://github.com/cproensa/mantisbt/tree/0024600_bugfilterquery_rebuild
The 2 latest commits:
https://github.com/mantisbt/mantisbt/compare/master...cproensa:0024600_bugfilterquery_rebuild?expand=1

and report if that fixes it?

Related Changesets

MantisBT: master ec75a98d

2020-01-19 06:49

cproensa

Committer: dregad


Details Diff
BugFilterQuery check for later modifications

The internal sql query is built and ready after the constructor method,
and regenerated after changing query type with set_query_type().
However, if externally adding clauses throguh add_join(), add_where(),
etc, those new parts are not translated to the final query
automatically.

Add a flag that keeps track of the modified state, so if the query is
executed after modifications, the internal sql is rebuilt.

Fixes: 0024600
Affected Issues
0024600
mod - core/classes/BugFilterQuery.class.php Diff File