View Issue Details

IDProjectCategoryView StatusLast Update
0009746mantisbtbugtrackerpublic2009-01-15 11:26
Reporterolegos Assigned Tovboctor  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.0a2 
Fixed in Version1.2.0a3 
Summary0009746: Bugnotes are messed up when some are invisible (private)
Description

When some notes are private & invisible to current user, the notes are incorrectly displayed (some that are displayed are blank with id 0 and bogus other info, some that should be displayed aren't).

The problem is because in bugnote_api.php, bugnote_get_all_visible_bugnotes(), when $t_bugnotes[] is created, the indexes in the array aren't going to be sequential, while the loop in bugnote_view_inc.php will access the elements sequentially starting with 0.

For example, if there are 3 notes, with note 2 not being visible, the array will have elements 0 and 2, but bugnote_view_inc.php will be printing elements 0 and 1.

A patch fixing this problem is attached.

TagsNo tags attached.
Attached Files
bug9746.patch (847 bytes)   
Index: core/bugnote_api.php
===================================================================
--- core/bugnote_api.php	(revision 5719)
+++ core/bugnote_api.php	(working copy)
@@ -304,7 +304,8 @@
 	$t_time_tracking_visible = access_compare_level( $t_user_access_level, config_get( 'time_tracking_view_threshold' ) );
 
 	$t_bugnotes = array();
-	foreach( $t_all_bugnotes as $t_note_index => $t_bugnote ) {
+	$t_note_index = 0;
+	foreach( $t_all_bugnotes as $t_bugnote ) {
 		if( $t_private_bugnote_visible || $t_bugnote->reporter_id == $t_user_id || ( VS_PUBLIC == $t_bugnote->view_state ) ) {
 
 			# If the access level specified is not enough to see time tracking information
@@ -313,7 +314,7 @@
 				$t_bugnote->time_tracking = 0;
 			}
 
-			$t_bugnotes[$t_note_index] = $t_bugnote;
+			$t_bugnotes[$t_note_index++] = $t_bugnote;
 		}
 	}
 
bug9746.patch (847 bytes)   

Activities

olegos

olegos

2008-10-24 18:20

reporter   ~0019676

I'm not sure if my patch doesn't break the order of bug notes. Is foreach guaranteed to iterate in the right order? In my few tests the order was ok.

Related Changesets

MantisBT: master 5974c4a6

2008-10-25 15:07

vboctor


Details Diff
Fixes 0009746: Bugnotes are messed up when some are invisible (private)

git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@5732 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9
Affected Issues
0009746
mod - core/bugnote_api.php Diff File