Skip to content

Commit

Permalink
Fix Bug #9979 where fields were not required properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daryn Warriner committed Dec 30, 2008
1 parent 17b4e54 commit bd435b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions bug_report.php
Expand Up @@ -98,11 +98,14 @@
$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_def = custom_field_get_definition( $t_id );
if ( $t_def['require_report'] && !gpc_isset( "custom_field_$t_id" ) ) {
$t_cf_value = gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL );
if ( $t_def['require_report'] && ( !gpc_isset( "custom_field_$t_id" ) || empty( $t_cf_value ) ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
} else if ( empty( $t_cf_value ) ) {
$t_cf_value = $t_def['default_value'];
}
if ( !custom_field_validate( $t_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], $t_def['default_value'] ) ) ) {
if ( !custom_field_validate( $t_id, $t_cf_value ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
}
Expand Down
5 changes: 3 additions & 2 deletions bug_update.php
Expand Up @@ -132,7 +132,8 @@
continue;
}

if ( $t_def['require_' . $t_custom_status_label] && !gpc_isset( "custom_field_$t_id" ) ) {
$t_cf_value = gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], NULL );
if ( $t_def['require_' . $t_custom_status_label] && ( !gpc_isset( "custom_field_$t_id" ) || empty( $t_cf_value ) ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_EMPTY_FIELD, ERROR );
}
Expand All @@ -142,7 +143,7 @@
continue;
}

if ( !custom_field_set_value( $t_id, $f_bug_id, gpc_get_custom_field( "custom_field_$t_id", $t_def['type'], null ) ) ) {
if ( !custom_field_set_value( $t_id, $f_bug_id, $t_cf_value ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
}
Expand Down

0 comments on commit bd435b9

Please sign in to comment.