From 63e80d513cb08db9c2f18355d98bd7ab5df057ad Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Wed, 23 Nov 2005 18:59:09 +0000 Subject: [PATCH] =?utf8?q?Bug=20315339:=20User::match=5Ffield()=20now=20le?= =?utf8?q?aves=20fields=20undefined=20instead=20of=20as=20empty=20strings?= =?utf8?q?=20when=20no=20value=20is=20passed=20(for=20type=20eq=20"single"?= =?utf8?q?=20only)=20-=20My=20previous=20patch=20was=20buggy=20as=20fields?= =?utf8?q?=20accepting=20only=20one=20user=20and=20those=20accepting=20sev?= =?utf8?q?eral=20users=20must=20be=20considered=20differently.=20Patch=20b?= =?utf8?q?y=20Fr=C3=A9d=C3=A9ric=20Buclin=20=20r/a=3Dju?= =?utf8?q?stdave?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Bugzilla/User.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 87b82171bd..681bd5f5fa 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -858,10 +858,13 @@ sub match_field { # the field here, and not set it to '', so that we will add # things to an empty list, and not to a list containing one # empty string. - # If no match or more than one match is found for this field, + # If the field accepts only one match (type eq "single") and + # no match or more than one match is found for this field, # we will set it back to '' so that the field remains defined # outside this function (it was if we came here; else we would - # have returned ealier above). + # have returned earlier above). + # If the field accepts several matches (type eq "multi") and no match + # is found, we leave this field undefined (= empty array). $cgi->delete($field); my @queries = (); @@ -947,10 +950,14 @@ sub match_field { } } # Above, we deleted the field before adding matches. If no match - # or more than one match has been found, we set it back to '' so + # or more than one match has been found for a field expecting only + # one match (type eq "single"), we set it back to '' so # that the caller of this function can still check whether this # field was defined or not (and it was if we came here). - $cgi->param($field, '') unless defined $cgi->param($field); + if (!defined $cgi->param($field) + && $fields->{$field}->{'type'} eq 'single') { + $cgi->param($field, ''); + } } my $retval; -- 2.47.2