]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1446236 - Allow customizing the name of the "nobody" user (nobody@mozilla.org...
authorVladimir Panteleev <CyberShadow@users.noreply.github.com>
Sun, 18 Oct 2020 16:29:04 +0000 (16:29 +0000)
committerGitHub <noreply@github.com>
Sun, 18 Oct 2020 16:29:04 +0000 (18:29 +0200)
* t/sqlite-memory.t: Fix test

* Ensure params are initialized with defaults when mocked

* Bug 1446236 - Allow customizing the name of the "nobody" user (nobody@mozilla.org)

* Move nobody_user from params to localconfig

27 files changed:
Bugzilla/Install/DB.pm
Bugzilla/Install/Localconfig.pm
Bugzilla/Test/MockParams.pm
extensions/BMO/Extension.pm
extensions/BMO/bin/bug_1093952.pl
extensions/BMO/bin/migrate-github-pull-requests.pl
extensions/BMO/template/en/default/pages/group_admins.html.tmpl
extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
extensions/ComponentWatching/Extension.pm
extensions/PhabBugz/lib/Util.pm
extensions/Review/bin/migrate_mentor_from_whiteboard.pl
extensions/Review/lib/WebService.pm
extensions/SecureMail/bin/tct [changed mode: 0644->0755]
extensions/TrackingFlags/bin/bug_825946.pl
extensions/TrackingFlags/bin/bulk_flag_clear.pl
scripts/disable-stale-users.pl
scripts/eject-users-from-groups.pl
scripts/generate_bmo_data.pl
scripts/move_os.pl
scripts/movebugs.pl
scripts/nagios_blocker_checker.pl
scripts/remove_idle_group_members.pl
scripts/reset_default_user.pl
t/bmo/comments.t
t/sqlite-memory.t
template/en/default/attachment/create.html.tmpl
template/en/default/setup/strings.txt.pl

index b2155d057e972301a6c87a8ff87be65597e50645..dedadd279242a47d500333b06b373136f63c3740 100644 (file)
@@ -4227,7 +4227,7 @@ sub _migrate_group_owners {
   my $dbh = Bugzilla->dbh;
   return if $dbh->bz_column_info('groups', 'owner_user_id');
   $dbh->bz_add_column('groups', 'owner_user_id', {TYPE => 'INT3'});
-  my $nobody = Bugzilla::User->check('nobody@mozilla.org');
+  my $nobody = Bugzilla::User->check(Bugzilla->localconfig->nobody_user);
   $dbh->do('UPDATE groups SET owner_user_id = ?', undef, $nobody->id);
 }
 
index fdb1a0d0c0cb40437f4121e0e5931a640b58f446..c4c249709d2b8565ea5455157e16c7c5d4092ec1 100644 (file)
@@ -97,6 +97,7 @@ use constant LOCALCONFIG_VARS => (
   {name => 'memcached_namespace', default => "bugzilla:",},
   {name => 'urlbase',             default => '',},
   {name => 'canonical_urlbase',   lazy => 1},
+  {name => 'nobody_user',         default => 'nobody@mozilla.org'},
   {name => 'attachment_base',     default => '',},
   {name => 'ses_username',        default => '',},
   {name => 'ses_password',        default => '',},
index 8ad21920c9fefdb3a16740df4d076679495279b5..5f5abbff0fd2cd02e892661471f5ad90368fccac 100644 (file)
@@ -54,13 +54,14 @@ sub import {
   $answers{user_info_class}   //= 'GitHubAuth,CGI';
   $answers{user_verify_class} //= 'GitHubAuth,DB';
 
-  if ($first_time++) {
+  if ($first_time++ == 0) {
     capture_merged {
       Bugzilla::Config::update_params();
     };
   }
   else {
     Bugzilla::Config::SetParam($_, $answers{$_}) for keys %answers;
+    Bugzilla::Config::write_params();
   }
 }
 
index c46438f99deee93a6a355675ed5d6b62838781e0..a63cd9996e8b9081ad546555c26b1b15af60ea03 100644 (file)
@@ -972,7 +972,8 @@ sub object_end_of_create {
     # Add default searches to new user's footer
     my $dbh = Bugzilla->dbh;
 
-    my $sharer = Bugzilla::User->new({name => 'nobody@mozilla.org'}) or return;
+    my $sharer = Bugzilla::User->new({name => Bugzilla->localconfig->nobody_user})
+      or return;
     my $group = Bugzilla::Group->new({name => 'everyone'}) or return;
 
     foreach my $definition (@default_named_queries) {
@@ -1012,7 +1013,7 @@ sub _bug_reporters_hw_os {
 sub _bug_is_unassigned {
   my ($self) = @_;
   my $assignee = $self->assigned_to->login;
-  return $assignee eq 'nobody@mozilla.org' || $assignee =~ /@(?!invalid).+\.bugs$/;
+  return $assignee eq Bugzilla->localconfig->nobody_user || $assignee =~ /@(?!invalid).+\.bugs$/;
 }
 
 sub _bug_has_current_patch {
@@ -1192,7 +1193,7 @@ sub object_start_of_update {
 
   # and the assignee isn't a real person
   return
-    unless $new_bug->assigned_to->login eq 'nobody@mozilla.org'
+    unless $new_bug->assigned_to->login eq Bugzilla->localconfig->nobody_user
     || $new_bug->assigned_to->login =~ /@(?!invalid).+\.bugs$/;
 
   # and the user can set the status to NEW
@@ -1927,7 +1928,8 @@ sub _post_employee_incident_bug {
   my ($investigate_bug, $ssh_key_bug);
   my $old_user = Bugzilla->user;
   eval {
-    Bugzilla->set_user(Bugzilla::User->new({name => 'nobody@mozilla.org'}));
+    Bugzilla->set_user(Bugzilla::User->new(
+      {name => Bugzilla->localconfig->nobody_user}));
     my $new_user = Bugzilla->user;
 
     # HACK: User needs to be in the editbugs and primary bug's group to allow
index 20a9d10daa3e7e2781543c18a45c868bb2af753a..937c5bd2f82c57eff754aba5c69eff567321ec2b 100755 (executable)
@@ -55,7 +55,7 @@ printf "About to fix %s bugs\n", scalar(@$bugs);
 print "Press <Ctrl-C> to stop or <Enter> to continue...\n";
 getc();
 
-my $nobody = Bugzilla::User->check({name => 'nobody@mozilla.org'});
+my $nobody = Bugzilla::User->check({name => Bugzilla->localconfig->nobody_user});
 my $field = Bugzilla::Field->check({name => 'status_whiteboard'});
 my $when = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
 
index b7bdd0d680f218c41fd5e54608f6a0612c88bbff..82603b0fdfc37a3b7173c2ee23aa3abf7d4a3394 100755 (executable)
@@ -23,7 +23,7 @@ use Bugzilla::User;
 use Bugzilla::Util qw(trim);
 
 my $dbh    = Bugzilla->dbh;
-my $nobody = Bugzilla::User->check({name => 'nobody@mozilla.org'});
+my $nobody = Bugzilla::User->check({name => Bugzilla->localconfig->nobody_user});
 my $field  = Bugzilla::Field->check({name => 'attachments.mimetype'});
 
 # grab list of suitable attachments
index 7921da071a16328d43386a6cc5935fb204793ba1..db29fb44a62c2a38c4916f05b0427c7cf7f6e33c 100644 (file)
@@ -41,7 +41,7 @@
             [% group.name FILTER html %]</span>
         </td>
         <td nowrap>
-          [% IF group.owner.login == 'nobody@mozilla.org' %]
+          [% IF group.owner.login == Bugzilla.localconfig.nobody_user %]
             &ndash;
           [% ELSE %]
             [% INCLUDE global/user.html.tmpl who = group.owner %]
index 504dbcd1aeb036ddd4b185574ef77735cb7ba4ee..de0ccb1f603e481014fbe1dd59cb469c70e12aaf 100644 (file)
@@ -19,7 +19,7 @@
 
   # these are used in a few places
   is_cced = bug.cc.contains(user.login);
-  unassigned = (bug.assigned_to.login == "nobody@mozilla.org")
+  unassigned = (bug.assigned_to.login == Bugzilla.localconfig.nobody_user)
                || (bug.assigned_to.login.search('@(?!invalid).+\.bugs$'));
 
   # custom fields that have custom rendering, or should not be rendered
index 1f4c64da5c724aa79bac0e495443efedc91bad91..9bd6a7fcf59a0b1c5ab698f3ec83d7907adf4911 100644 (file)
@@ -23,7 +23,6 @@ use Bugzilla::Util qw(detaint_natural trim);
 our $VERSION = '2';
 
 use constant REQUIRE_WATCH_USER => 1;
-use constant DEFAULT_ASSIGNEE   => 'nobody@mozilla.org';
 
 use constant REL_COMPONENT_WATCHER => 15;
 
@@ -100,7 +99,7 @@ sub template_before_create {
 sub template_before_process {
   my ($self, $args) = @_;
   return unless $args->{file} eq 'admin/components/create.html.tmpl';
-  $args->{vars}{comp}{default_assignee}{login} = DEFAULT_ASSIGNEE;
+  $args->{vars}{comp}{default_assignee}{login} = Bugzilla->localconfig->nobody_user;
 }
 
 #
index 3c1bd2640356ae34d98d24d4724e79806fe8f4a9..f6d469001916883227ad8486246ac4323c450003 100644 (file)
@@ -129,7 +129,7 @@ sub get_bug_role_phids {
 }
 
 sub is_bug_assigned {
-  return $_[0]->assigned_to->email ne 'nobody@mozilla.org';
+  return $_[0]->assigned_to->email ne Bugzilla->localconfig->nobody_user;
 }
 
 sub is_attachment_phab_revision {
index e9a623096339899b49d037528abf04cf7cc72c7c..e807ffd7d7019c3a09492be054883e687632be0b 100755 (executable)
@@ -36,7 +36,7 @@ EOF
 <>;
 
 # we need to be logged in to do user searching and update bugs
-my $nobody = Bugzilla::User->check({name => 'nobody@mozilla.org'});
+my $nobody = Bugzilla::User->check({name => Bugzilla->localconfig->nobody_user});
 $nobody->{groups} = [Bugzilla::Group->get_all];
 Bugzilla->set_user($nobody);
 
index 6f3183c9dd3faaa1d0175b0d4e057d323d30dd1f..b6681c456c36a031d26760e31a76ad0a8bf77a03 100644 (file)
@@ -53,7 +53,8 @@ sub suggestions {
     # we always need to be authenticated to perform user matching
     my $user = Bugzilla->user;
     if (!$user->id) {
-      Bugzilla->set_user(Bugzilla::User->check({name => 'nobody@mozilla.org'}));
+      Bugzilla->set_user(Bugzilla::User->check(
+        {name => Bugzilla->localconfig->nobody_user}));
       push @reviewers, @{$bug->mentors};
       Bugzilla->set_user($user);
     }
old mode 100644 (file)
new mode 100755 (executable)
index 055cec19384750564502b557f826fc06ab0f8dfe..9eb75d36776725cbd0e708c1869903232682dae6 100755 (executable)
@@ -24,7 +24,7 @@ use Bugzilla::Bug qw(LogActivityEntry);
 
 Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
 my $dbh = Bugzilla->dbh;
-my $user = Bugzilla::User->check({name => 'nobody@mozilla.org'});
+my $user = Bugzilla::User->check({name => Bugzilla->localconfig->nobody_user});
 
 my $tf_vis = $dbh->selectall_arrayref(<<SQL);
     SELECT
index 72558a89b9a2658ec7937d1db9b447da51df26db..7b3be9ea990486d579c777fba88fed15eb6fbc86 100755 (executable)
@@ -104,7 +104,7 @@ if (!$config->{update_db}) {
 
 # update bugs
 
-my $nobody = Bugzilla::User->check({name => 'nobody@mozilla.org'});
+my $nobody = Bugzilla::User->check({name => Bugzilla->localconfig->nobody_user});
 
 # put our nobody user into all groups to avoid permissions issues
 $nobody->{groups} = [Bugzilla::Group->get_all];
index d289ef01ed1d480b3b41040c42d451254ea5ee16..d2cd133559cde2515302e0ce55762c6387bc3999 100755 (executable)
@@ -66,7 +66,7 @@ FROM
     components
     ON components.watch_user = profiles.userid
 WHERE
-  profiles.login_name != 'nobody@mozilla.org'
+  profiles.login_name != ?
   AND components.id IS NULL
   AND NOT profiles.login_name LIKE '%.bugs'
   AND NOT profiles.login_name LIKE '%.tld'
@@ -77,14 +77,16 @@ ORDER BY
   profiles.userid
 EOF
 
+my $nobody = Bugzilla->localconfig->nobody_user;
 if ($dump_sql) {
+  $sql =~ s/[?]/"$nobody"/;
   $sql =~ s/[?]/$date/g;
   print $sql;
   exit;
 }
 
 say STDERR "looking for users inactive since $date";
-my $users = $dbh->selectall_arrayref($sql, {Slice => {}}, $date, $date);
+my $users = $dbh->selectall_arrayref($sql, {Slice => {}}, $nobody, $date, $date);
 my $total = scalar @$users;
 die "no matching users found.\n" unless $total;
 
index be41b876265060047a18c6d430db1d2407129e30..98e3b20a0b2170bd5cc8f5c5042de1aa18957e18 100755 (executable)
@@ -22,7 +22,7 @@ Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
 
 my $dbh = Bugzilla->dbh;
 my @remove_group_names;
-my $nobody_name = 'nobody@mozilla.org';
+my $nobody_name = Bugzilla->localconfig->nobody_user;
 my $admin_name  = 'automation@bmo.tld';
 
 GetOptions(
index c4860617b4370b0dfc07ec084f6912975e9d3c2a..886f6680b5222ffe184c4f3dd88fbe81823da431 100755 (executable)
@@ -147,7 +147,7 @@ $group->update();
 
 my @users = (
   {
-    login    => 'nobody@mozilla.org',
+    login    => Bugzilla->localconfig->nobody_user,
     realname => 'Nobody; OK to take it and work on it',
     password => '*'
   },
@@ -232,7 +232,7 @@ my @products = (
       name        => 'General',
       description => 'For bugs in Firefox which do not fit into '
         . 'other more specific Firefox components',
-      initialowner   => 'nobody@mozilla.org',
+      initialowner   => Bugzilla->localconfig->nobody_user,
       initialqaowner => '',
       initial_cc     => [],
       watch_user     => 'general@firefox.bugs'
@@ -251,7 +251,7 @@ my @products = (
       description =>
         'This is the component for issues specific to bugzilla.mozilla.org '
         . 'that do not belong in other components.',
-      initialowner   => 'nobody@mozilla.org',
+      initialowner   => Bugzilla->localconfig->nobody_user,
       initialqaowner => '',
       initial_cc     => [],
       watch_user     => 'general@bugzilla.bugs'
index 0117551cf88996b6e1c5422fcfe8d0749e7c3aad..08200395164fa5ea6f8a3df886f02c0baa5c0425 100755 (executable)
@@ -42,7 +42,8 @@ my $bug_ids
   = $dbh->selectcol_arrayref(q{SELECT bug_id FROM bugs WHERE bugs.op_sys = ?},
   undef, $from_os);
 my $field = Bugzilla::Field->check({name => 'op_sys', cache => 1});
-my $nobody = Bugzilla::User->check({name => 'nobody@mozilla.org', cache => 1});
+my $nobody = Bugzilla::User->check(
+  {name => Bugzilla->localconfig->nobody_user, cache => 1});
 
 my $bug_count = @$bug_ids;
 if ($bug_count == 0) {
index 376e9a8fff539be52bac168e205e6e84b01a3385..1cebda59166ba613ec9b1ccc9e6b44c7daa7ff33 100755 (executable)
@@ -69,9 +69,11 @@ my $component_field_id
   = $dbh->selectrow_array("SELECT id FROM fielddefs WHERE name = 'component'");
 $component_field_id or die "Can't find field ID for 'component' field\n";
 
-my $user_id = $dbh->selectrow_array(
-  "SELECT userid FROM profiles WHERE login_name='nobody\@mozilla.org'");
-$user_id or die "Can't find user ID for 'nobody\@mozilla.org'\n";
+my $nobody = Bugzilla->localconfig->nobody_user;
+my $user_id
+  = $dbh->selectrow_array("SELECT userid FROM profiles WHERE login_name=?",
+  undef, $nobody);
+$user_id or die "Can't find user ID for '$nobody'\n";
 
 $dbh->bz_start_transaction();
 
index 795acc7cccea5d713488ec154c2681ff2f832199..7d04f01f6049a44130997a241457460cd7bdf40a 100755 (executable)
@@ -29,7 +29,7 @@ my $config = {
   assignee   => '',
   product    => '',
   component  => '',
-  unassigned => 'nobody@mozilla.org',
+  unassigned => Bugzilla->localconfig->nobody_user,
 
   # severities
   severity => 'major,critical,blocker',
index 1840d9b9f9ee40063166c58fe44a426c9a06ac4b..3aa357914ee50d42ef18f737f12ea4c9b66de010 100755 (executable)
@@ -77,7 +77,7 @@ foreach my $group_id (keys %remove_data) {
   $dbh->bz_commit_transaction();
 
   # nobody@mozilla.org cannot receive email
-  next if $group->owner->login eq 'nobody@mozilla.org';
+  next if $group->owner->login eq Bugzilla->localconfig->nobody_user;
 
   _send_email($group, \@users_removed);
 }
index 99d9a31c9c96b9eaf9b5f75d6d25e48fbac5e083..5afe9e6da757f328d88495665c045809d6e855d8 100755 (executable)
@@ -54,7 +54,7 @@ if (!$product
 }
 
 # We will need these for entering into bugs_activity
-my $who = Bugzilla::User->new({name => 'nobody@mozilla.org'});
+my $who = Bugzilla::User->new({name => Bugzilla->localconfig->nobody_user});
 my $field = Bugzilla::Field->new({name => $field_name});
 
 my $product_id = $dbh->selectrow_array("SELECT id FROM products WHERE name = ?",
index 08badc3f8af2cc6110b54584b5e2358428238abb..7a6cfe1f17c5048d6a0a24efffe1e9b2c0f4a68c 100644 (file)
@@ -36,7 +36,7 @@ my $bug_1 = Bugzilla::Bug->create({
   keywords     => [],
   cc           => [],
   comment      => 'This is a brand new bug',
-  assigned_to  => 'nobody@mozilla.org',
+  assigned_to  => Bugzilla->localconfig->nobody_user,
 });
 ok($bug_1->id, "got a new bug");
 
@@ -56,7 +56,7 @@ my $bug_2    = Bugzilla::Bug->create({
   keywords     => [],
   cc           => [],
   comment      => "This is related to ${urlbase}show_bug.cgi?id=$bug_1_id",
-  assigned_to  => 'nobody@mozilla.org',
+  assigned_to  => Bugzilla->localconfig->nobody_user,
 });
 
 my $bug_2_id = $bug_2->id;
index 6b5d8bfd6325092ae8cc91ca1b6038d2dc7e4ddc..8079f9525b8268fef4f8634273772aefae29ee29 100644 (file)
@@ -12,7 +12,6 @@ use Test::More;
 use Test2::Tools::Mock;
 use Try::Tiny;
 use Capture::Tiny qw(capture_merged);
-use Bugzilla::Test::MockParams;
 
 BEGIN {
   $ENV{LOCALCONFIG_ENV} = 'BMO';
@@ -20,6 +19,7 @@ BEGIN {
   $ENV{BMO_db_name}     = ':memory:';
 }
 use Bugzilla;
+use Bugzilla::Test::MockParams;
 BEGIN { Bugzilla->extensions }
 
 
index 1fc876d60e808b337e04a3fa2c929a5a9dc2ce98..d591eca527530cded53c365255edacad91c57689 100644 (file)
@@ -74,7 +74,7 @@
         <td>
           <em>If you want to assign this [% terms.bug %] to yourself,
               check the box below.</em><br>
-          [% IF bug.assigned_to.login == "nobody@mozilla.org" || bug.assigned_to.login.search('@(?!invalid).+\.bugs$') %]
+          [% IF bug.assigned_to.login == Bugzilla.localconfig.nobody_user || bug.assigned_to.login.search('@(?!invalid).+\.bugs$') %]
             [% take_if_patch = 1 %]
           [% END %]
           <input type="checkbox" id="takebug" name="takebug" value="1" [% IF take_if_patch %] data-take-if-patch="1" [% END %]>
index 03acdf07aed836a00de7566b6bdd069714143730..2b47653bffdd5853bcaf10aca07a1e2c9eefad42 100644 (file)
@@ -239,6 +239,10 @@ END
   localconfig_canonical_urlbase => <<'END',
 The URL that is the canonical initial leading part of all URLs.
 This will be the production URL for a dev site, for instance.
+END
+  localconfig_nobody_user => <<'END',
+This is the email address of the "nobody" user, which is used as e.g. the
+default user that bugs are assigned to.
 END
   localconfig_use_suexec => <<'END',
 Set this to 1 if Bugzilla runs in an Apache SuexecUserGroup environment.