Permalink
Browse files

Fix handling custom date fields with value `{now}`

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 5, 2017
1 parent 03db938 commit 8b9b2a3227ff908265f492a31a3d60a2172ab7aa
Showing with 9 additions and 1 deletion.
  1. +2 −1 bug_report.php
  2. +7 −0 core/cfdefs/cfdef_standard.php
View
@@ -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 );
}
@@ -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 );
}
}

0 comments on commit 8b9b2a3

Please sign in to comment.