From cfd8911bdc6e48c0b5dd94bf8a82d72c7fda03dc Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 13 Oct 2014 19:45:17 +0400 Subject: [PATCH] Do not export anything from Bugzilla::User --- Bugzilla/Auth/Verify.pm | 2 +- Bugzilla/Auth/Verify/LDAP.pm | 2 +- Bugzilla/BugMail.pm | 14 +++++++------- Bugzilla/Component.pm | 2 +- Bugzilla/Flag.pm | 2 +- Bugzilla/Install.pm | 3 +-- Bugzilla/Search.pm | 10 +++++----- Bugzilla/User.pm | 2 +- contrib/sendbugmail.pl | 2 +- editparams.cgi | 2 +- editwhines.cgi | 2 +- extensions/Example/Extension.pm | 2 +- token.cgi | 6 +++--- userprefs.cgi | 12 ++++++------ 14 files changed, 31 insertions(+), 32 deletions(-) diff --git a/Bugzilla/Auth/Verify.pm b/Bugzilla/Auth/Verify.pm index 7e404fe85..f3383b1b1 100644 --- a/Bugzilla/Auth/Verify.pm +++ b/Bugzilla/Auth/Verify.pm @@ -48,7 +48,7 @@ sub create_or_update_user { # A passed-in user_id always overrides anything else, for determining # what account we should return. if (!$user_id) { - my $username_user_id = login_to_id($username || ''); + my $username_user_id = Bugzilla::User::login_to_id($username || ''); my $extern_user_id; if ($extern_id) { trick_taint($extern_id); diff --git a/Bugzilla/Auth/Verify/LDAP.pm b/Bugzilla/Auth/Verify/LDAP.pm index cdc802ca0..ef2dc2735 100644 --- a/Bugzilla/Auth/Verify/LDAP.pm +++ b/Bugzilla/Auth/Verify/LDAP.pm @@ -123,7 +123,7 @@ sub check_credentials { # Cycle through the adresses and check if they're Bugzilla logins. # Use the first one that returns a valid id. foreach my $email (@emails) { - if ( login_to_id($email) ) { + if ( Bugzilla::User::login_to_id($email) ) { $params->{bz_username} = $email; last; } diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index ed3f76f2a..cc8d2f595 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -235,19 +235,19 @@ sub Send my $changer = $forced->{changer}; if ($forced->{owner}) { - push @assignees, login_to_id($forced->{owner}, THROW_ERROR); + push @assignees, Bugzilla::User::login_to_id($forced->{owner}, THROW_ERROR); } if ($forced->{qacontact}) { - push @qa_contacts, login_to_id($forced->{qacontact}, THROW_ERROR); + push @qa_contacts, Bugzilla::User::login_to_id($forced->{qacontact}, THROW_ERROR); } if ($forced->{cc}) { foreach my $cc (@{$forced->{cc}}) { - push @ccs, login_to_id($cc, THROW_ERROR); + push @ccs, Bugzilla::User::login_to_id($cc, THROW_ERROR); } } @@ -429,18 +429,18 @@ sub Send { foreach my $cc_user (split(/[\s,]+/, $diff->{removed})) { - my $uid = login_to_id($cc_user); + my $uid = Bugzilla::User::login_to_id($cc_user); $recipients{$uid}->{+REL_CC} = BIT_DIRECT if $uid; } } elsif ($diff->{fielddesc} eq "QAContact") { - my $uid = login_to_id($diff->{removed}); + my $uid = Bugzilla::User::login_to_id($diff->{removed}); $recipients{$uid}->{+REL_QA} = BIT_DIRECT if $uid; } elsif ($diff->{fielddesc} eq "AssignedTo") { - my $uid = login_to_id($diff->{removed}); + my $uid = Bugzilla::User::login_to_id($diff->{removed}); $recipients{$uid}->{+REL_ASSIGNEE} = BIT_DIRECT if $uid; } } @@ -470,7 +470,7 @@ sub Send my @watchers = split(/[,\s]+/, Bugzilla->params->{globalwatchers}); foreach (@watchers) { - my $watcher_id = login_to_id($_); + my $watcher_id = Bugzilla::User::login_to_id($_); next unless $watcher_id; $recipients{$watcher_id}->{+REL_GLOBAL_WATCHER} = BIT_DIRECT; } diff --git a/Bugzilla/Component.pm b/Bugzilla/Component.pm index 9894a9bb8..dae4a25f4 100644 --- a/Bugzilla/Component.pm +++ b/Bugzilla/Component.pm @@ -289,7 +289,7 @@ sub _check_cc_list my %cc_ids; foreach my $cc (@$cc_list) { - my $id = login_to_id($cc, THROW_ERROR); + my $id = Bugzilla::User::login_to_id($cc, THROW_ERROR); $cc_ids{$id} = 1; } return [ keys %cc_ids ]; diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index 96abc0e30..9f67b996e 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -1028,7 +1028,7 @@ sub show_flag_reminders $flag = Bugzilla::Flag->new({ id => $2 }); $flag->{status} = $ARGS->{$_}; if (($login = trim($ARGS->{"requestee-".$flag->{id}})) && - ($login = login_to_id($login))) + ($login = Bugzilla::User::login_to_id($login))) { $flag->{requestee_id} = $login; } diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm index 2635253da..362f5c464 100644 --- a/Bugzilla/Install.pm +++ b/Bugzilla/Install.pm @@ -285,8 +285,7 @@ sub make_admin { my ($user) = @_; my $dbh = Bugzilla->dbh; - $user = ref($user) ? $user - : new Bugzilla::User(login_to_id($user, THROW_ERROR)); + $user = ref($user) ? $user : Bugzilla::User->check($user); my $admin_group = new Bugzilla::Group({ name => 'admin' }); diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index d0e7d0c84..cf4ae0c8b 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -1251,7 +1251,7 @@ sub init foreach my $name (@guessed) { $name = trim($name); - if ($name && lc $name ne '%user%' && !login_to_id($name)) + if ($name && lc $name ne '%user%' && !Bugzilla::User::login_to_id($name)) { # Do a match on user login or name my $u = Bugzilla::User::match_name($name, 1)->[0]; @@ -2296,7 +2296,7 @@ sub _cc_nonchanged sub _long_desc_changedby { my $self = shift; - my $id = login_to_id($self->{value}, THROW_ERROR); + my $id = Bugzilla::User::login_to_id($self->{value}, THROW_ERROR); my @priv = $self->{user}->is_insider ? () : "longdescs.isprivate=0"; $self->{term} = { base_table => "longdescs", @@ -2494,7 +2494,7 @@ sub _longdescs_isprivate sub _work_time_changedby { my $self = shift; - my $id = login_to_id($self->{value}, THROW_ERROR); + my $id = Bugzilla::User::login_to_id($self->{value}, THROW_ERROR); my @priv = $self->{user}->is_insider ? () : "longdescs.isprivate=0"; $self->{term} = { base_table => "longdescs", @@ -3034,7 +3034,7 @@ sub _changedby ThrowUserError("invalid_activity_field", { field => $self->{field} }); } $fieldid = $fieldid->id; - my $id = login_to_id($self->{value}, THROW_ERROR); + my $id = Bugzilla::User::login_to_id($self->{value}, THROW_ERROR); $self->{term} = { base_table => 'bugs_activity', where => [ "bugs_activity.fieldid = $fieldid", @@ -3053,7 +3053,7 @@ sub _in_search_results { # Allow to match on shared searches via 'SearchName ' syntax $v = $1; - $sharer = login_to_id(trim($2), THROW_ERROR); + $sharer = Bugzilla::User::login_to_id(trim($2), THROW_ERROR); } my $query = Bugzilla::Search::Saved->check({ name => trim($v), diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 63d701fb5..6d7b04d50 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -55,7 +55,7 @@ use DateTime::TimeZone; use Scalar::Util qw(blessed); use Storable qw(dclone); -use base qw(Bugzilla::Object Exporter); +use base qw(Bugzilla::Object); # FIXME Remove procedural APIs @Bugzilla::User::EXPORT = qw( is_available_username login_to_id validate_password diff --git a/contrib/sendbugmail.pl b/contrib/sendbugmail.pl index f4bebabc6..ae587ea59 100644 --- a/contrib/sendbugmail.pl +++ b/contrib/sendbugmail.pl @@ -56,7 +56,7 @@ if ($changer !~ /$match/) { print STDERR "Changer \"$changer\" doesn't match email regular expression.\n"; usage(); } -if(!login_to_id($changer)) { +if(!Bugzilla::User::login_to_id($changer)) { print STDERR "\"$changer\" is not a login ID.\n"; usage(); } diff --git a/editparams.cgi b/editparams.cgi index f5a22f0f2..2b2ceba10 100755 --- a/editparams.cgi +++ b/editparams.cgi @@ -151,7 +151,7 @@ if ($action eq 'save' && $current_module) # can not use Bugzilla::User foreach my $watcher (split(/[,\s]+/, $value)) { - unless (login_to_id($watcher)) + unless (Bugzilla::User::login_to_id($watcher)) { ThrowUserError('invalid_parameter', { name => $name, err => "no such user $watcher" }); } diff --git a/editwhines.cgi b/editwhines.cgi index e68179725..1a0770b9c 100755 --- a/editwhines.cgi +++ b/editwhines.cgi @@ -189,7 +189,7 @@ if ($ARGS->{update}) { if ($mailto_type == MAILTO_USER) { - $mailto_id = login_to_id($mailto); + $mailto_id = Bugzilla::User::login_to_id($mailto); } elsif ($mailto_type == MAILTO_GROUP) { diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm index 2289ff533..b574b6c2c 100644 --- a/extensions/Example/Extension.pm +++ b/extensions/Example/Extension.pm @@ -254,7 +254,7 @@ sub email_in_after_parse { my $dbh = Bugzilla->dbh; # No other check needed if this is a valid regular user. - return if login_to_id($reporter); + return if Bugzilla::User::login_to_id($reporter); # The reporter is not a regular user. We create an account for him, # but he can only comment on existing bugs. diff --git a/token.cgi b/token.cgi index 4e1e7ac94..633f85c5e 100755 --- a/token.cgi +++ b/token.cgi @@ -201,7 +201,7 @@ sub changePassword my $password = delete $ARGS->{password}; my $matchpassword = delete $ARGS->{matchpassword}; defined $password && defined $matchpassword || ThrowUserError('require_new_password'); - validate_password($password, $matchpassword); + Bugzilla::User::validate_password($password, $matchpassword); my $dbh = Bugzilla->dbh; @@ -250,7 +250,7 @@ sub changeEmail } # The new email address should be available as this was # confirmed initially so cancel token if it is not still available - if (!is_available_username($new_email, $old_email)) + if (!Bugzilla::User::is_available_username($new_email, $old_email)) { $vars->{email} = $new_email; # Needed for Bugzilla::Token::Cancel's mail Bugzilla::Token::Cancel($token, "account_exists", $vars); @@ -349,7 +349,7 @@ sub confirm_create_account my (undef, undef, $login_name) = Bugzilla::Token::GetTokenData($token); my $password = delete $ARGS->{passwd1} || ''; - validate_password($password, delete $ARGS->{passwd2} || ''); + Bugzilla::User::validate_password($password, delete $ARGS->{passwd2} || ''); my $otheruser = Bugzilla::User->create({ login_name => $login_name, diff --git a/userprefs.cgi b/userprefs.cgi index 4cb4f288d..86f854254 100755 --- a/userprefs.cgi +++ b/userprefs.cgi @@ -100,7 +100,7 @@ sub SaveAccount if ($pwd1 ne "" || $pwd2 ne "") { $pwd1 || ThrowUserError("new_password_missing"); - validate_password($pwd1, $pwd2); + Bugzilla::User::validate_password($pwd1, $pwd2); if ($oldpassword ne $pwd1) { @@ -130,7 +130,7 @@ sub SaveAccount # Before changing an email address, confirm one does not exist. validate_email_syntax($new_login_name) || ThrowUserError('illegal_email_address', { addr => $new_login_name }); - is_available_username($new_login_name) + Bugzilla::User::is_available_username($new_login_name) || ThrowUserError("account_exists", { email => $new_login_name }); Bugzilla::Token::IssueEmailChangeToken($user, $old_login_name, $new_login_name); @@ -321,13 +321,13 @@ sub SaveEmail # New watched users push @$add_wdwr, - map { [ login_to_id(trim($_), THROW_ERROR), $userid ] } + map { [ Bugzilla::User::login_to_id(trim($_), THROW_ERROR), $userid ] } split /[,\s]+/, join(',', $ARGS->{new_watchedusers}) || ''; # New watchers push @$add_wdwr, - map { [ $userid, login_to_id(trim($_), THROW_ERROR) ] } + map { [ $userid, Bugzilla::User::login_to_id(trim($_), THROW_ERROR) ] } split /[,\s]+/, join(',', $ARGS->{new_watchers}) || ''; @@ -335,7 +335,7 @@ sub SaveEmail { # User wants to remove selected watched users push @$del_wdwr, - map { [ login_to_id(trim($_), THROW_ERROR), $userid ] } + map { [ Bugzilla::User::login_to_id(trim($_), THROW_ERROR), $userid ] } $ARGS->{watched_by_you}; } @@ -343,7 +343,7 @@ sub SaveEmail { # User wants to remove selected watchers push @$del_wdwr, - map { [ $userid, login_to_id(trim($_), THROW_ERROR) ] } + map { [ $userid, Bugzilla::User::login_to_id(trim($_), THROW_ERROR) ] } $ARGS->{watchers}; }