[Rt-commit] [svn] r1980 - in rt/branches/3.3-TESTING: .
html/Elements lib/RT/Interface
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Thu Dec 9 02:33:59 EST 2004
Author: jesse
Date: Thu Dec 9 02:33:58 2004
New Revision: 1980
Modified:
rt/branches/3.3-TESTING/ (props changed)
rt/branches/3.3-TESTING/html/Elements/EditCustomFieldFreeform
rt/branches/3.3-TESTING/lib/RT/Interface/Web.pm
Log:
r1990 at hualien: jesse | 2004-12-09T07:32:26.670652Z
This actually covers several bugs in the custom field processing in 3.3.
12. Each time I fixed a bug, another one was uncovered. I think I've
finished now.
You can see the problems if you create a ticket with "Enter multiple
values", "Fill in one text area" and "upload a file" CFs. The go to the
Basics page, don't change anything and hit submit. All hell breaks loose
-
1) the multi-value & text area fields get screwed up.
2) a message appears telling you the file upload CF has been deleted,
although it apparently hasn't.
Here's the idea behind what I did:
- Multi-value CFs should be stored with no \n or \r characters.
- Fill-in-a-text-area CFs should have \r removed before storing in
the database (but \n should remain).
There are a couple of other related changes - free form multi value CFs
are no longer identified by type "FreeformMultiple". Also there's a
"next if" statement in the wrong place which was causing the file upload
bug.
--Steve Turner
Modified: rt/branches/3.3-TESTING/html/Elements/EditCustomFieldFreeform
==============================================================================
--- rt/branches/3.3-TESTING/html/Elements/EditCustomFieldFreeform (original)
+++ rt/branches/3.3-TESTING/html/Elements/EditCustomFieldFreeform Thu Dec 9 02:33:58 2004
@@ -52,7 +52,7 @@
if ($Multiple and $Values) {
$Default = '';
while (my $value = $Values->Next ) {
- $Default .= $value->Content;
+ $Default .= $value->Content."\n";
}
}
</%INIT>
Modified: rt/branches/3.3-TESTING/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.3-TESTING/lib/RT/Interface/Web.pm (original)
+++ rt/branches/3.3-TESTING/lib/RT/Interface/Web.pm Thu Dec 9 02:33:58 2004
@@ -321,11 +321,15 @@
my $cf = RT::CustomField->new( $session{'CurrentUser'});
$cf->Load($cfid);
- if ($cf->Type eq 'FreeformMultiple') {
+ if ( $cf->Type eq 'Freeform' && ! $cf->SingleValue) {
$ARGS{$arg} =~ s/\r\n/\n/g;
$ARGS{$arg} = [split('\n', $ARGS{$arg})];
}
+ if ( $cf->Type eq 'Text') {
+ $ARGS{$arg} =~ s/\r//g;
+ }
+
if ( $arg =~ /-Upload$/ ) {
$create_args{"CustomField-".$cfid} = _UploadedFile($arg);
}
@@ -1114,6 +1118,9 @@
$CustomFieldObj->LoadById($cf);
foreach my $arg ( keys %{$ARGSRef} ) {
+ # Only interested in args for the current CF:
+ next unless ( $arg =~ /^Object-$class-(?:$id)?-CustomField-$cf-/ );
+
# since http won't pass in a form element with a null value, we need
# to fake it
if ($arg =~ /^(.*?)-Values-Magic$/ ) {
@@ -1127,11 +1134,23 @@
$ARGSRef->{$1."-Values"} = undef;
}
- next unless ( $arg =~ /^Object-$class-(?:$id)?-CustomField-$cf-/ );
- my @values =
- ( ref( $ARGSRef->{$arg} ) eq 'ARRAY' )
- ? @{ $ARGSRef->{$arg} }
- : split /\n/, $ARGSRef->{$arg} ;
+ my @values = ();
+ if (ref( $ARGSRef->{$arg} ) eq 'ARRAY' ) {
+ @values = @{ $ARGSRef->{$arg} };
+ } elsif ($CustomFieldObj->Type eq 'Text') {
+ @values = ($ARGSRef->{$arg});
+ } else {
+ @values = split /\n/, $ARGSRef->{$arg};
+ }
+
+ if ( ($CustomFieldObj->Type eq 'Freeform'
+ && ! $CustomFieldObj->SingleValue) ||
+ $CustomFieldObj->Type eq 'Text') {
+ foreach my $val (@values) {
+ $val =~ s/\r//g;
+ }
+ }
+
if ( ( $arg =~ /-AddValue$/ ) || ( $arg =~ /-Value$/ ) ) {
foreach my $value (@values) {
next unless length($value);
More information about the Rt-commit
mailing list