Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove generated history events for unchanged custom fields #1930

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions bug_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ function get_valid_version( BugData $p_bug, $p_field ) {
$t_new_custom_field_value = gpc_get_custom_field( 'custom_field_' . $t_cf_id, $t_cf_def['type'], '' );
$t_old_custom_field_value = custom_field_get_value( $t_cf_id, $f_bug_id );

if( $t_new_custom_field_value == $t_old_custom_field_value ) {
continue;
}

# Validate the value of the field against current validation rules.
# This may cause an error if validation rules have recently been
# modified such that old values that were once OK are now considered
Expand Down
4 changes: 4 additions & 0 deletions core/custom_field_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,10 @@ function custom_field_set_value( $p_field_id, $p_bug_id, $p_value, $p_log_insert
$t_value_field = ( $t_type == CUSTOM_FIELD_TYPE_TEXTAREA ) ? 'text' : 'value';
$t_value = custom_field_value_to_database( $p_value, $t_type );

if( $t_type == CUSTOM_FIELD_TYPE_MULTILIST || $t_type == CUSTOM_FIELD_TYPE_CHECKBOX ) {
$t_value = trim( $t_value, '|' );
}

# Determine whether an existing value needs to be updated or a new value inserted
db_param_push();
$t_query = 'SELECT ' . $t_value_field . '
Expand Down
15 changes: 9 additions & 6 deletions core/gpc_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ function gpc_get_custom_field( $p_var_name, $p_custom_field_type, $p_default = n
}
$t_values = gpc_get_string_array( $p_var_name, $p_default );
if( is_array( $t_values ) ) {
return implode( '|', $t_values );
$t_value = trim( implode( '|', $t_values ), '|' );
} else {
return '';
$t_value = '';
}
break;
case CUSTOM_FIELD_TYPE_DATE:
Expand All @@ -223,17 +223,20 @@ function gpc_get_custom_field( $p_var_name, $p_custom_field_type, $p_default = n
$t_year = gpc_get_int( $p_var_name . '_year', 0 );
if( ( $t_year == 0 ) || ( $t_month == 0 ) || ( $t_day == 0 ) ) {
if( $p_default == null ) {
return '';
$t_value = '';
} else {
return $p_default;
$t_value = $p_default;
}
} else {
return strtotime( $t_year . '-' . $t_month . '-' . $t_day );
$t_value = strtotime( $t_year . '-' . $t_month . '-' . $t_day );
}
break;
default:
return gpc_get_string( $p_var_name, $p_default );
$t_value = gpc_get_string( $p_var_name, $p_default );
break;
}

return $t_value;
}

/**
Expand Down