Dependency Graph

Dependency Graph
related to related to child of child of duplicate of duplicate of

View Issue Details

IDProjectCategoryView StatusLast Update
0008380mantisbtadministrationpublic2007-10-04 01:37
Reporterdreadnaught Assigned Tovboctor  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
OSSuSE SLESOS Version10.0 
Product Version1.1.0a4 
Fixed in Version1.1.0rc1 
Summary0008380: Deleting old user Account results in Database inconsistency
Description

Deleting old user Account results in Database inconsistency.

When deleting an old mantis user account, all references to this deleted user result in application errors like "APPLICATION ERROR 0000801 - Benutzer nicht gefunden"!!!

The administration panel does NOT warn before deleting a user nor it does describe the consequences!

You are not able to delete the issue any more (=> application error)! In other words: deleting a user heavily damages the data!

Steps To Reproduce

1) create a temporary user account
2) Report a testbug with this account
3) Add a notice to this bug with this account
4) delete the temporary user
5) now try to read the added notice (-> Application error)
6) now try to delete the testbug (-> Application error)

Additional Information

How can we repair this damage? please tell us a solution as soon as possible!
Thank you for your effort!

TagsNo tags attached.
Attached Files
8380.patch (3,378 bytes)   
Index: bugnote_view_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bugnote_view_inc.php,v
retrieving revision 1.45
diff -u -r1.45 bugnote_view_inc.php
--- bugnote_view_inc.php	12 Aug 2007 22:43:48 -0000	1.45
+++ bugnote_view_inc.php	26 Sep 2007 02:36:28 -0000
@@ -115,10 +115,12 @@
 		<?php
 			echo print_user( $v3_reporter_id );
 		?>
-		<span class="small">(<?php
-			$t_access_level = access_get_project_level( null, $v3_reporter_id );
-			echo get_enum_element( 'access_levels', $t_access_level ); 
-		?>)</span>
+		<span class="small"><?php
+			if ( user_exists( $v3_reporter_id ) ) {
+				$t_access_level = access_get_project_level( null, $v3_reporter_id );
+				echo '(', get_enum_element( 'access_levels', $t_access_level ), ')';
+			} 
+		?></span>
 		<?php if ( VS_PRIVATE == $v3_view_state ) { ?>
 		<span class="small">[ <?php echo lang_get( 'private' ) ?> ]</span>
 		<?php } ?>
Index: core/email_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/email_api.php,v
retrieving revision 1.138
diff -u -r1.138 email_api.php
--- core/email_api.php	28 Jul 2007 21:36:50 -0000	1.138
+++ core/email_api.php	26 Sep 2007 02:34:27 -0000
@@ -1027,10 +1027,16 @@
 				$t_time_tracking = '';
 			}
 
-			$t_access_level = access_get_project_level( null,  $t_bugnote->reporter_id );
+			if ( user_exists( $t_bugnote->reporter_id ) ) {
+				$t_access_level = access_get_project_level( null,  $t_bugnote->reporter_id );
+				$t_access_level_string = ' (' . get_enum_element( 'access_levels', $t_access_level ) . ') - '; 
+			} else {
+				$t_access_level_string = '';
+			}
+
 			$t_string = ' (' . $t_formatted_bugnote_id . ') ' . 
 				user_get_name( $t_bugnote->reporter_id ) .
-				' (' . get_enum_element( 'access_levels', $t_access_level ) . ') - ' .
+				$t_access_level_string .
 				$t_last_modified . "\n" .
 				$t_time_tracking . ' ' . $t_bugnote_link;
 
Index: core/print_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/print_api.php,v
retrieving revision 1.180
diff -u -r1.180 print_api.php
--- core/print_api.php	24 Aug 2007 19:04:42 -0000	1.180
+++ core/print_api.php	26 Sep 2007 02:29:06 -0000
@@ -108,6 +108,10 @@
 	
 	# Print avatar image for the given user ID
 	function print_avatar( $p_user_id ) {
+		if ( !user_exists( $p_user_id ) ) {
+			return;
+		}
+
 		if ( access_has_project_level( config_get( 'show_avatar_threshold' ), null, $p_user_id ) ) {
 			$t_avatar = user_get_avatar( $p_user_id );
 			$t_avatar_url = $t_avatar[0];
Index: core/user_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/user_api.php,v
retrieving revision 1.112
diff -u -r1.112 user_api.php
--- core/user_api.php	10 Sep 2007 00:29:04 -0000	1.112
+++ core/user_api.php	26 Sep 2007 02:47:10 -0000
@@ -48,11 +48,13 @@
 		$result = db_query( $query );
 
 		if ( 0 == db_num_rows( $result ) ) {
+			$g_cache_user[$c_user_id] = false;
+
 			if ( $p_trigger_errors ) {
 				trigger_error( ERROR_USER_NOT_FOUND, ERROR );
-			} else {
-				return false;
 			}
+			
+			return false;
 		}
 
 		$row = db_fetch_array( $result );
8380.patch (3,378 bytes)   

Relationships

has duplicate 0008434 closedryandesign Issues no longer accessible after deleting the reporting user from the system 

Activities

DGtlRift

DGtlRift

2007-09-21 12:25

reporter   ~0015685

As a workaround you could find the ID of the missing user (I assume that is where the problem is and it's trying to sql join against that ID) and manually add it back into the database using a sql client. This would be to just get you back up and running.

I suspect the long term fix is how to handle references to missing keys in queries.

dreadnaught

dreadnaught

2007-09-25 03:58

reporter   ~0015709

Thaks DGtlRift for your advice!

We have practiced another Workaround: Cloning such a "damaged" ticket will result in a new ticket that is clean, but is lacks its attached notices etc (a fact we can live with, for a while). The "damaged" ticket could be closed (this still works).

vboctor

vboctor

2007-09-25 22:55

manager   ~0015715

Fixed 0008380: Deleting old user Account results in Database inconsistency.

  • Caching lookups for users that no longer exists.
  • Fixed an error in print_avatar() for users that no longer exists.
  • Fixed an error in including access level in bug note view and emails for users who reported issue notes.

Attached is the patch that fixes the problem.