[Rt-commit] rt branch 4.4/customfieldvalue-sortorder-integer-checking created. rt-4.4.5-32-g13d1f9d436
BPS Git Server
git at git.bestpractical.com
Mon Mar 28 20:01:49 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 4.4/customfieldvalue-sortorder-integer-checking has been created
at 13d1f9d4364f819860fd035293dfca5fa9153b82 (commit)
- Log -----------------------------------------------------------------
commit 13d1f9d4364f819860fd035293dfca5fa9153b82
Author: Brian Conry <bconry at bestpractical.com>
Date: Mon Mar 28 14:55:39 2022 -0500
Improve checking of CustomFieldValue SortOrder
Previously there was no proactive validation on the SortOrder for
CustmField values. Some databases are more picky than others and throw
errors for non-integer values. In one case the DBD error message was
even returned to the user.
Now SortOrder is validated to be either empty or contain an integer
value (negative values are fine), plus a (more) user-friendly and
localisable error message is generated.
diff --git a/lib/RT/CustomField.pm b/lib/RT/CustomField.pm
index e449c86bbc..ff4b972fda 100644
--- a/lib/RT/CustomField.pm
+++ b/lib/RT/CustomField.pm
@@ -665,6 +665,11 @@ sub AddValue {
return (0, $self->loc("Can't add a custom field value without a name"));
}
+ # disallow non-integer sort order
+ if ( defined $args{'SortOrder'} and $args{'SortOrder'} !~ /^(?:-?\d+)?$/ ) {
+ return (0, $self->loc("SortOrder must be an integer value."));
+ }
+
my $newval = RT::CustomFieldValue->new( $self->CurrentUser );
return $newval->Create( %args, CustomField => $self->Id );
}
diff --git a/lib/RT/CustomFieldValue.pm b/lib/RT/CustomFieldValue.pm
index 8eac5c7e3e..645c401fd6 100644
--- a/lib/RT/CustomFieldValue.pm
+++ b/lib/RT/CustomFieldValue.pm
@@ -123,6 +123,11 @@ sub _Set {
return (0, $self->loc('Permission Denied'));
}
+ # disallow non-integer sort order
+ if ( $args{Field} eq 'SortOrder' and $args{Value} !~ /^(?:-?\d+)?$/ ) {
+ return (0, $self->loc("SortOrder must be an integer value."));
+ }
+
my ($ret, $msg) = $self->SUPER::_Set( @_ );
if ( $args{Field} eq 'Name' ) {
$cf->CleanupDefaultValues;
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list