View Issue Details

IDProjectCategoryView StatusLast Update
0003537mantisbtcustom fieldspublic2004-02-29 07:20
Reporterdrdoctor Assigned Tovboctor  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
OSLinux 
Product Version0.18.0 
Summary0003537: Rewriting custom values with 0 when updating a bug
Description

If you update a bug with existing custom fields, which fields are not contained in the simple update bug page (for example: "milestone" field is an advanced custom field, with a value setted already - M3), the old value is lost after update.

Additional Information

1.
just update a field if the custom_field_x was posted through the form!!!
bug_resolve.php,v 1.39 2004/01/11 07:16:06 vboctor
make an additional if statement
foreach( $t_related_custom_field_ids as $t_id ) {

Do not set custom field value if user has no write access.

    if( !custom_field_has_write_access( $t_id, $f_bug_id ) ) {
        continue;
    }
    # return back with the row belonging to the custom id (id, name, type, possible values, default value, ...)
        # we need only need it to get the default value
    $t_def = custom_field_get_definition( $t_id );

#check if the custom_field was transferred!!
if (gpc_get_string( "customfield$t_id", $t_def['default_value'] )) {
if ( !custom_field_set_value( $t_id, $f_bug_id, gpc_get_string( "customfield$t_id", $t_def['default_value'] ) ) ) {
trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
}
}
}

TagsNo tags attached.
Attached Files
3537_advanced_custom_values_reset_on_simple_update.diff (1,138 bytes)   
Index: bug_update.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/bug_update.php,v
retrieving revision 1.60
diff -u -r1.60 bug_update.php
--- bug_update.php	13 Jan 2004 12:23:50 -0000	1.60
+++ bug_update.php	7 Feb 2004 11:56:29 -0000
@@ -64,13 +64,20 @@
 
 	$t_related_custom_field_ids = custom_field_get_linked_ids( $t_bug_data->project_id );
 	foreach( $t_related_custom_field_ids as $t_id ) {
+		$t_custom_field_value = gpc_get_string( "custom_field_$t_id", null );
+
+		# Only update the field if it is posted
+		if ( $t_custom_field_value === null ) {
+			continue;
+		}
+		
 		# Do not set custom field value if user has no write access.
 		if( !custom_field_has_write_access( $t_id, $f_bug_id ) ) {
 			continue;
 		}
 
 		$t_def = custom_field_get_definition( $t_id );
-		if ( !custom_field_set_value( $t_id, $f_bug_id, gpc_get_string( "custom_field_$t_id", $t_def['default_value'] ) ) ) {
+		if ( !custom_field_set_value( $t_id, $f_bug_id, $t_custom_field_value ) ) {
 			trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
 		}
 	}

Activities

vboctor

vboctor

2004-02-07 07:02

manager   ~0004974

Patch attached and fixed in CVS. Will be available in the next release.