Skip to content

Commit

Permalink
Fix handling custom date fields with value {now}
Browse files Browse the repository at this point in the history
The issue should be created with custom field set to today's date,
but it gets created with literal string {now} that can't be displayed
later. The fix would be resolve {now} at reporting time and fix display
of existing issues by showing empty date.

This applies to issues created via web ui when the date field is not
visible on reporting page.

Fixes #23594
  • Loading branch information
vboctor committed Nov 10, 2017
1 parent 03db938 commit 8b9b2a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bug_report.php
Expand Up @@ -220,7 +220,8 @@
}

$t_def = custom_field_get_definition( $t_id );
if( !custom_field_set_value( $t_id, $t_bug_id, gpc_get_custom_field( 'custom_field_' . $t_id, $t_def['type'], $t_def['default_value'] ), false ) ) {
if( !custom_field_set_value( $t_id, $t_bug_id, gpc_get_custom_field( 'custom_field_' . $t_id,
$t_def['type'], custom_field_default_to_value( $t_def['default_value'], $t_def['type'] ), false ) ) ) {
error_parameters( lang_get_defaulted( custom_field_get_field( $t_id, 'name' ) ) );
trigger_error( ERROR_CUSTOM_FIELD_INVALID_VALUE, ERROR );
}
Expand Down
7 changes: 7 additions & 0 deletions core/cfdefs/cfdef_standard.php
Expand Up @@ -347,6 +347,13 @@ function cfdef_prepare_email_value( $p_value ) {
*/
function cfdef_prepare_date_value( $p_value ) {
if( $p_value != null ) {
# There is a bug where default dates were being saved as '{now}' rather
# than being evaluated at creation time, so replace them with empty string.
$t_value_length = strlen( $p_value );
if( $t_value_length >= 3 && $p_value[0] == '{' && $p_value[$t_value_length - 1] == '}' ) {
return '';
}

return date( config_get( 'short_date_format' ), $p_value );
}
}
Expand Down

0 comments on commit 8b9b2a3

Please sign in to comment.