View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0007657 | mantisbt | relationships | public | 2006-12-14 06:28 | 2014-11-05 01:53 |
| Reporter | polzin | Assigned To | vboctor | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | duplicate | ||
| Product Version | 1.0.6 | ||||
| Summary | 0007657: Relationships are not sorted correctly | ||||
| Description | Currently, relationships should be sorted by "relation_type", "id". There is one bug and one suggestion:
The attached patch solves both. | ||||
| Tags | No tags attached. | ||||
| Attached Files | patch.txt (5,071 bytes)
Index: core/relationship_api.php
===================================================================
RCS file: /cvs/TPS/mantis/core/relationship_api.php,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 relationship_api.php
--- core/relationship_api.php 28 Jun 2005 11:04:06 -0000 1.1.1.7
+++ core/relationship_api.php 14 Dec 2006 11:22:26 -0000
@@ -242,13 +242,13 @@
$t_mantis_bug_relationship_table = config_get( 'mantis_bug_relationship_table' );
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
+ # ording will be done later
$query = "SELECT $t_mantis_bug_relationship_table.id, $t_mantis_bug_relationship_table.relationship_type,
$t_mantis_bug_relationship_table.source_bug_id, $t_mantis_bug_relationship_table.destination_bug_id,
$t_mantis_bug_table.project_id
FROM $t_mantis_bug_relationship_table
INNER JOIN $t_mantis_bug_table ON $t_mantis_bug_relationship_table.destination_bug_id = $t_mantis_bug_table.id
- WHERE source_bug_id='$c_src_bug_id'
- ORDER BY relationship_type, $t_mantis_bug_relationship_table.id";
+ WHERE source_bug_id='$c_src_bug_id'";
$result = db_query( $query );
$t_src_project_id = bug_get_field( $p_src_bug_id, 'project_id' );
@@ -257,14 +257,15 @@
$t_relationship_count = db_num_rows( $result );
for ( $i = 0 ; $i < $t_relationship_count ; $i++ ) {
$row = db_fetch_array( $result );
- $t_bug_relationship_data[$i]->id = $row['id'];
- $t_bug_relationship_data[$i]->src_bug_id = $row['source_bug_id'];
- $t_bug_relationship_data[$i]->src_project_id = $t_src_project_id;
- $t_bug_relationship_data[$i]->dest_bug_id = $row['destination_bug_id'];
- $t_bug_relationship_data[$i]->dest_project_id = $row['project_id'];
- $t_bug_relationship_data[$i]->type = $row['relationship_type'];
+ $key = $row['relationship_type'] * 2000000 + $row['destination_bug_id'];
+ $t_bug_relationship_data[$key]->id = $row['id'];
+ $t_bug_relationship_data[$key]->src_bug_id = $row['source_bug_id'];
+ $t_bug_relationship_data[$key]->src_project_id = $row['project_id'];
+ $t_bug_relationship_data[$key]->dest_bug_id = $row['destination_bug_id'];
+ $t_bug_relationship_data[$key]->dest_project_id = $t_dest_project_id;
+ $t_bug_relationship_data[$key]->type = $row['relationship_type'];
}
- unset( $t_bug_relationship_data[$t_relationship_count] );
+ unset( $t_bug_relationship_data[0] );
return $t_bug_relationship_data;
}
@@ -276,13 +277,13 @@
$t_mantis_bug_relationship_table = config_get( 'mantis_bug_relationship_table' );
$t_mantis_bug_table = config_get( 'mantis_bug_table' );
+ # ording will be done later
$query = "SELECT $t_mantis_bug_relationship_table.id, $t_mantis_bug_relationship_table.relationship_type,
$t_mantis_bug_relationship_table.source_bug_id, $t_mantis_bug_relationship_table.destination_bug_id,
$t_mantis_bug_table.project_id
FROM $t_mantis_bug_relationship_table
INNER JOIN $t_mantis_bug_table ON $t_mantis_bug_relationship_table.source_bug_id = $t_mantis_bug_table.id
- WHERE destination_bug_id='$c_dest_bug_id'
- ORDER BY relationship_type, $t_mantis_bug_relationship_table.id";
+ WHERE destination_bug_id='$c_dest_bug_id'";
$result = db_query( $query );
$t_dest_project_id = bug_get_field( $p_dest_bug_id, 'project_id' );
@@ -291,14 +292,16 @@
$t_relationship_count = db_num_rows( $result );
for ( $i = 0 ; $i < $t_relationship_count ; $i++ ) {
$row = db_fetch_array( $result );
- $t_bug_relationship_data[$i]->id = $row['id'];
- $t_bug_relationship_data[$i]->src_bug_id = $row['source_bug_id'];
- $t_bug_relationship_data[$i]->src_project_id = $row['project_id'];
- $t_bug_relationship_data[$i]->dest_bug_id = $row['destination_bug_id'];
- $t_bug_relationship_data[$i]->dest_project_id = $t_dest_project_id;
- $t_bug_relationship_data[$i]->type = $row['relationship_type'];
+ $key = $row['relationship_type'] * 2000000 +
+ ( $row['relationship_type'] != BUG_RELATED ? 1000000 : 0 ) + $row['source_bug_id'];
+ $t_bug_relationship_data[$key]->id = $row['id'];
+ $t_bug_relationship_data[$key]->src_bug_id = $row['source_bug_id'];
+ $t_bug_relationship_data[$key]->src_project_id = $row['project_id'];
+ $t_bug_relationship_data[$key]->dest_bug_id = $row['destination_bug_id'];
+ $t_bug_relationship_data[$key]->dest_project_id = $t_dest_project_id;
+ $t_bug_relationship_data[$key]->type = $row['relationship_type'];
}
- unset( $t_bug_relationship_data[$t_relationship_count] );
+ unset( $t_bug_relationship_data[0] );
return $t_bug_relationship_data;
}
@@ -307,7 +310,13 @@
function relationship_get_all( $p_bug_id, &$p_is_different_projects ) {
$t_src = relationship_get_all_src( $p_bug_id );
$t_dest = relationship_get_all_dest( $p_bug_id );
- $t_all = array_merge( $t_src, $t_dest );
+ # merge
+ $t_all = $t_src + $t_dest;
+ # sort keys
+ ksort( $t_all );
+ # throw away keys
+ $t_all = array_merge( $t_all );
+
$p_is_different_projects = false;
for ( $i = 0 ; $i < count( $t_all ) ; $i++ ) {
| ||||