From: Frédéric Buclin Date: Tue, 16 Aug 2011 12:31:32 +0000 (+0200) Subject: Fix complains from 012throwables.t due to bug 677901 X-Git-Tag: bugzilla-4.3.1~282 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0fdd3872606a6a51a73fe6dff0d2c0c320f1fba1;p=thirdparty%2Fbugzilla.git Fix complains from 012throwables.t due to bug 677901 --- diff --git a/token.cgi b/token.cgi index d085e88e6c..c43acdbfd0 100755 --- a/token.cgi +++ b/token.cgi @@ -56,27 +56,28 @@ unless ($action eq 'reqpw') { $tokentype || ThrowUserError("token_does_not_exist"); # Make sure the token is the correct type for the action being taken. - my $error; + # The { user_error => 'wrong_token_for_*' } trick is to make 012throwables.t happy. + my $error = {}; if (grep($action eq $_ , qw(cfmpw cxlpw chgpw)) && $tokentype ne 'password') { - $error = 'wrong_token_for_changing_passwd'; + $error = { user_error => 'wrong_token_for_changing_passwd' }; } elsif ($action eq 'cxlem' && ($tokentype ne 'emailold' && $tokentype ne 'emailnew')) { - $error = 'wrong_token_for_cancelling_email_change'; + $error = { user_error => 'wrong_token_for_cancelling_email_change' }; } elsif (grep($action eq $_ , qw(cfmem chgem)) && $tokentype ne 'emailnew') { - $error = 'wrong_token_for_confirming_email_change'; + $error = { user_error => 'wrong_token_for_confirming_email_change' }; } elsif ($action =~ /^(request|confirm|cancel)_new_account$/ && $tokentype ne 'account') { - $error = 'wrong_token_for_creating_account'; + $error = { user_error => 'wrong_token_for_creating_account' }; } - if ($error) { - Bugzilla::Token::Cancel($token, $error); - ThrowUserError($error); + if (my $user_error = $error->{user_error}) { + Bugzilla::Token::Cancel($token, $user_error); + ThrowUserError($user_error); } }