[Rt-commit] rt branch, 4.2/date-cf-validation, created. rt-4.2.1rc1-3-g7df793e
Alex Vandiver
alexmv at bestpractical.com
Mon Nov 18 04:41:10 EST 2013
The branch, 4.2/date-cf-validation has been created
at 7df793efdbcdbd44552937ca31e7b50c40fd579d (commit)
- Log -----------------------------------------------------------------
commit 28a7109e4cdfbe439f9562b7d58430f626e17a87
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Nov 18 04:11:13 2013 -0500
Ensure that Date and DateTime CF values validate using current values
Date and DateTime CFs, for historical reasons, do not place their
defaults in the CF entry box. Thus, and update where no value is
submitted for such a CF is equivalent to leaving that CF unchanged.
While the CF update code (see RT::Interface::Web line 3088) implements
this, the vlaidation code was not aware. Thus, a "mandatory" date CF
would not pass validation if left unchanged.
In RT 4.0, this led to silent errors on the Modify page, and did not
prevent other updates. In RT 4.2, thanks to 16ddc81, failing to enter
the current value explicitly into Date and DateTime CFs causes them to
fail to validate, and thus prevents all other updates of the page.
Alter the validation code to be aware that Date and DateTime CFs, if
empty, should take their values from the current CF values.
diff --git a/share/html/Elements/ValidateCustomFields b/share/html/Elements/ValidateCustomFields
index ae63fbf..9acba17 100644
--- a/share/html/Elements/ValidateCustomFields
+++ b/share/html/Elements/ValidateCustomFields
@@ -74,6 +74,14 @@ while ( my $CF = $CustomFields->Next ) {
CustomField => $CF,
Value => $submitted->{Values} || $submitted->{Value} || $submitted->{Upload},
);
+ if ($CF->Type =~ /^Date(?:Time)?$/) {
+ if (not @values) {
+ my $values = $Object->CustomFieldValues($CF->Id);
+ while (my $ocfv = $values->Next) {
+ push @values, $ocfv->Content;
+ }
+ }
+ }
push @values, '' unless @values;
for my $value( @values ) {
commit 806345a5fe01072ba2a6e5548cfc216f4f11a297
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Nov 18 04:15:52 2013 -0500
Make validation code aware that 1970 for date CFs is "not set"
For the purposes of CF validation, 1970-01-01 is equivalent to no OCVF
value. Thus, entering 1970-01-01 as a Date value should only be allowed
if the CF is not mandatory.
diff --git a/share/html/Elements/ValidateCustomFields b/share/html/Elements/ValidateCustomFields
index 9acba17..175982b 100644
--- a/share/html/Elements/ValidateCustomFields
+++ b/share/html/Elements/ValidateCustomFields
@@ -81,6 +81,15 @@ while ( my $CF = $CustomFields->Next ) {
push @values, $ocfv->Content;
}
}
+ @values = grep {
+ my $DateObj = RT::Date->new ( $session{'CurrentUser'} );
+ $DateObj->Set(
+ Format => 'unknown',
+ Value => $_,
+ ($CF->Type eq "Date" ? (Timezone => 'utc') : ())
+ );
+ $DateObj->Unix > 0
+ } @values;
}
push @values, '' unless @values;
commit 7df793efdbcdbd44552937ca31e7b50c40fd579d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Nov 18 04:17:42 2013 -0500
Use defined-or instead of || to not lose "0" as a CF value for validation
The value "0" for a Date or DateTime CF is also equivalent to
1970-01-01, and thus invalid for mandatory CFs. However, due to the use
of || rather than //, the CF was viewed as "empty" and thus was
validated against its _old_ value, and not the "not set" value.
diff --git a/share/html/Elements/ValidateCustomFields b/share/html/Elements/ValidateCustomFields
index 175982b..67a8267 100644
--- a/share/html/Elements/ValidateCustomFields
+++ b/share/html/Elements/ValidateCustomFields
@@ -72,7 +72,7 @@ while ( my $CF = $CustomFields->Next ) {
my @values = _NormalizeObjectCustomFieldValue(
CustomField => $CF,
- Value => $submitted->{Values} || $submitted->{Value} || $submitted->{Upload},
+ Value => ($submitted->{Values} // $submitted->{Value} // $submitted->{Upload}),
);
if ($CF->Type =~ /^Date(?:Time)?$/) {
if (not @values) {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list