View Issue Details

IDProjectCategoryView StatusLast Update
0000805mantisbtsqlpublic2001-08-26 16:09
ReporterAJC Assigned Toprescience  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Summary0000805: Search results have wrong bug ID's
Description

Another bug found since I manually changed the bug_table id numbers to be the same as our current bugs list...

The search results use the bug_text_table id numbers rather than the bug_table id numbers for the bug links.

Additional Information

This can be fixed by only including the bug_table id column in the result from MySQL. Change the query in line 108 of view_all_bug_page.php to:
$query = "SELECT $g_mantis_bug_table.*, $g_mantis_bug_text_table.description FROM $g_mantis_bug_table, $g_mantis_bug_text_table " . $t_where_clause;

TagsNo tags attached.

Activities

prescience

prescience

2001-08-17 14:14

reporter   ~0001161

I don't quite follow. Can you provide a larger code snippet?

AJC

AJC

2001-08-20 01:59

reporter   ~0001165

The current code builds the search query to give:

SELECT * FROM $g_mantis_bug_table,$g_mantis_bug_text_table WHERE ...

When listing the results from the search, the hyperlinked bug number uses the "id" field from the result from the above SQL query. But there are two "id" fields in the result, one from each table.

The problem occurs when the bug_table id numbers to not coincide with the corresponding text table id numbers (which probably only happens if someone like me fiddles the bug id numbers). In this situation it seems to be the bug_text_table id number rather than the bug_table id number that is used for the link - so it links to the wrong bug.

The current code only works when bug_text_table.id = bug_table.id for every bug(which it normally is).

My modification is to build the SQL to have

SELECT $g_mantis_bug_table., $g_mantis_bug_text_table.description FROM ...
insead of
SELECT
FROM ...

as the only field we need from the bug_text_table is the decription. By making this change we only get one "id" field in the result, which is the bug_table.id - the one we want.

AJC

AJC

2001-08-20 02:00

reporter   ~0001166

New code looks like:

build our query string based on our viewing criteria

$query = "SELECT * FROM $g_mantis_bug_table";

$t_where_clause = " WHERE project_id='$g_project_cookie_val'";

$t_clo_val = CLOSED;
if (( $f_hide_closed=="on"  )&&( $f_show_status!="closed" )) {
    $t_where_clause = $t_where_clause." AND status<>'$t_clo_val'";
}

if ( $f_show_category != "any" ) {
    $t_where_clause = $t_where_clause." AND category='$f_show_category'";
}
if ( $f_show_severity != "any" ) {
    $t_where_clause = $t_where_clause." AND severity='$f_show_severity'";
}
if ( $f_show_status != "any" ) {
    $t_where_clause = $t_where_clause." AND status='$f_show_status'";
}

   ### Simple Text Search - Thx to  Alan Knowles
   if ($f_search_text) {
        $t_where_clause .= " AND ( summary LIKE '%".addslashes($f_search_text)."%'
                                           OR (description LIKE '%".addslashes($f_search_text)."%')
                                           OR (steps_to_reproduce LIKE '%".addslashes($f_search_text)."%')
                                           OR (additional_information LIKE '%".addslashes($f_search_text)."%')
                                           OR ($g_mantis_bug_table.id LIKE '%".addslashes($f_search_text)."%'))
                                           AND $g_mantis_bug_text_table.id = $g_mantis_bug_table.bug_text_id";
         $query = "SELECT $g_mantis_bug_table.*, $g_mantis_bug_text_table.description FROM $g_mantis_bug_table, $g_mantis_bug_text_table  " . $t_where_clause;
   } else {
         $query = $query.$t_where_clause;
   }
prescience

prescience

2001-08-20 08:59

reporter   ~0001167

Thanks AJC, I'll take a look when I get home.

prescience

prescience

2001-08-23 18:37

reporter   ~0001211

Fixed in CVS. Will be in 0.15.5