]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
no bug - turn Bugzilla->localconfig into an object to make use of lazy attributes...
authorDylan William Hardison <dylan@hardison.net>
Thu, 13 Jun 2019 14:25:02 +0000 (10:25 -0400)
committerGitHub <noreply@github.com>
Thu, 13 Jun 2019 14:25:02 +0000 (10:25 -0400)
55 files changed:
Bugzilla.pm
Bugzilla/App/Plugin/Glue.pm
Bugzilla/App/Plugin/Hostage.pm
Bugzilla/App/Plugin/OAuth2.pm
Bugzilla/App/Plugin/SizeLimit.pm
Bugzilla/Attachment/PatchReader.pm
Bugzilla/Auth/Login/CGI.pm
Bugzilla/BugMail.pm
Bugzilla/BugUrl/Bugzilla/Local.pm
Bugzilla/CGI.pm
Bugzilla/Config.pm
Bugzilla/Constants.pm
Bugzilla/DB.pm
Bugzilla/DB/Mysql.pm
Bugzilla/DB/Oracle.pm
Bugzilla/Install/Filesystem.pm
Bugzilla/Install/Localconfig.pm
Bugzilla/Install/Requirements.pm
Bugzilla/Localconfig.pm [new file with mode: 0644]
Bugzilla/Mailer.pm
Bugzilla/Memcached.pm
Bugzilla/Search/Quicksearch.pm
Bugzilla/Template.pm
Bugzilla/Token.pm
Bugzilla/Util.pm
Bugzilla/WebService/Server/JSONRPC.pm
Bugzilla/WebService/Server/REST.pm
attachment.cgi
editparams.cgi
extensions/Bitly/lib/WebService.pm
extensions/BugModal/lib/ActivityStream.pm
extensions/BzAPI/lib/Resources/Bugzilla.pm
extensions/BzAPI/lib/Util.pm
extensions/GitHubAuth/lib/Client.pm
extensions/GitHubAuth/lib/Login.pm
extensions/InlineHistory/Extension.pm
extensions/Push/lib/Config.pm
extensions/Push/lib/Connector.disabled/AMQP.pm
extensions/Push/lib/Connector.disabled/ServiceNow.pm
extensions/Push/lib/Connector/Spark.pm
extensions/SecureMail/Extension.pm
extensions/SiteMapIndex/Extension.pm
extensions/SiteMapIndex/lib/Util.pm
github.cgi
index.cgi
reports.cgi
scripts/addcustomfield.pl
scripts/convert_datetime.pl
scripts/remove-non-public-data.pl
scripts/secbugsreport.pl
showdependencygraph.cgi
t/bmo/comments.t
t/hash-sig.t
t/mojo-oauth2.t
testserver.pl

index 8ab2f48c49735a37d91115cc22256e9a89f9b768..8fcbcb624f8486b3a0c62cd8282404d70a258bcf 100644 (file)
@@ -28,6 +28,7 @@ use Bugzilla::Field;
 use Bugzilla::Flag;
 use Bugzilla::Hook;
 use Bugzilla::Install::Localconfig qw(read_localconfig);
+use Bugzilla::Localconfig;
 use Bugzilla::Install::Util qw(init_console include_languages);
 use Bugzilla::Memcached;
 use Bugzilla::Template;
@@ -163,16 +164,17 @@ sub input_params {
 }
 
 sub localconfig {
-  return $_[0]->process_cache->{localconfig} ||= read_localconfig();
+  return $_[0]->process_cache->{localconfig} ||= Bugzilla::Localconfig->new(read_localconfig());
 }
 
+
 sub params {
   return request_cache->{params} ||= Bugzilla::Config::read_param_file();
 }
 
 sub get_param_with_override {
   my ($class, $name) = @_;
-  return $class->localconfig->{param_override}{$name} // $class->params->{$name};
+  return $class->localconfig->param_override->{$name} // $class->params->{$name};
 }
 
 sub user {
@@ -449,7 +451,7 @@ sub job_queue {
 sub jwt {
   my ($class, @args) = @_;
   require Mojo::JWT;
-  return Mojo::JWT->new(@args, secret => $class->localconfig->{jwt_secret});
+  return Mojo::JWT->new(@args, secret => $class->localconfig->jwt_secret);
 }
 
 sub dbh {
@@ -751,8 +753,8 @@ sub memcached {
 # Connector to the Datadog metrics collection daemon.
 sub datadog {
   my ($class, $namespace) = @_;
-  my $host = $class->localconfig->{datadog_host};
-  my $port = $class->localconfig->{datadog_port};
+  my $host = $class->localconfig->datadog_host;
+  my $port = $class->localconfig->datadog_port;
 
   $namespace //= '';
 
index 45c9721c745ca834cd5ad5a94b3c3c712dd5c546..2c80507c29611652f06dbbd16946a01cc80f137a 100644 (file)
@@ -44,7 +44,7 @@ sub register {
     }
   );
 
-  $app->secrets([Bugzilla->localconfig->{side_wide_secret}]);
+  $app->secrets([Bugzilla->localconfig->site_wide_secret]);
 
   $app->renderer->add_handler(
     'bugzilla' => sub {
@@ -73,7 +73,7 @@ sub register {
       my ($c, $type) = @_;
 
       if ($type == LOGIN_REQUIRED) {
-        $c->redirect_to(Bugzilla->localconfig->{basepath} . 'login');
+        $c->redirect_to(Bugzilla->localconfig->basepath . 'login');
         return undef;
       }
       else {
@@ -146,7 +146,7 @@ sub register {
     'url_is_attachment_base' => sub {
       my ($c, $id) = @_;
       return 0 unless Bugzilla::Util::use_attachbase();
-      my $attach_base = Bugzilla->localconfig->{'attachment_base'};
+      my $attach_base = Bugzilla->localconfig->attachment_base;
 
       # If we're passed an id, we only want one specific attachment base
       # for a particular bug. If we're not passed an ID, we just want to
index 62ce7d01d8cd735ababa0caf5d40f890562735a6..fdf044e49b84e847966dbe50d29085e4a63b50e1 100644 (file)
@@ -30,11 +30,11 @@ sub register {
 
 sub _before_routes {
   my ($c) = @_;
-  state $urlbase               = Bugzilla->localconfig->{urlbase};
+  state $urlbase               = Bugzilla->localconfig->urlbase;
   state $urlbase_uri           = URI->new($urlbase);
   state $urlbase_host          = $urlbase_uri->host;
   state $urlbase_host_regex    = qr/^bug(\d+)\.\Q$urlbase_host\E$/;
-  state $attachment_base       = Bugzilla->localconfig->{attachment_base};
+  state $attachment_base       = Bugzilla->localconfig->attachment_base;
   state $attachment_root       = _attachment_root($attachment_base);
   state $attachment_host_regex = _attachment_host_regex($attachment_base);
 
index e49278c8d762ecf0fbf484aa835dafba37226500..ab1fdf1e16b7946efa972a10213b1007c06e2834 100644 (file)
@@ -34,7 +34,7 @@ sub register {
   $conf->{verify_auth_code}          = \&_verify_auth_code;
   $conf->{store_access_token}        = \&_store_access_token;
   $conf->{verify_access_token}       = \&_verify_access_token;
-  $conf->{jwt_secret}                = Bugzilla->localconfig->{jwt_secret};
+  $conf->{jwt_secret}                = Bugzilla->localconfig->jwt_secret;
   $conf->{jwt_claims}                = sub {
     my $args = shift;
     if (!$args->{user_id}) {
index 7fdc8cbc4f26e9c955fc8353cd2bb49ccdef6744..6ac068f255a3f8d6646b59d0d9e04e0f5af3adbf 100644 (file)
@@ -40,7 +40,7 @@ sub register {
   my ($self, $app, $conf) = @_;
 
   if (HAVE_BSD_RESOURCE) {
-    my $setrlimit = decode_json(Bugzilla->localconfig->{setrlimit});
+    my $setrlimit = decode_json(Bugzilla->localconfig->setrlimit);
 
     # This trick means the master process will not a size limit.
     Mojo::IOLoop->next_tick(sub {
@@ -55,7 +55,7 @@ sub register {
   }
 
   if (HAVE_LINUX_SMAPS_TINY) {
-    my $size_limit = Bugzilla->localconfig->{size_limit};
+    my $size_limit = Bugzilla->localconfig->size_limit;
     return unless $size_limit;
 
     if ($size_limit < MIN_SIZE_LIMIT) {
index 0ae70d3f4cfd813c2798cd766b357795fdac04cd..3db2d6d45aac6923d0be7cf123c838084257ccb6 100644 (file)
@@ -275,14 +275,14 @@ sub setup_patch_readers {
 
   # Add in cvs context if we have the necessary info to do it
   if ( $context ne 'patch'
-    && Bugzilla->localconfig->{cvsbin}
+    && Bugzilla->localconfig->cvsbin
     && Bugzilla->params->{'cvsroot_get'})
   {
     require Bugzilla::PatchReader::AddCVSContext;
 
     # We need to set $cvsbin as global, because PatchReader::CVSClient
     # needs it in order to find 'cvs'.
-    $main::cvsbin = Bugzilla->localconfig->{cvsbin};
+    $main::cvsbin = Bugzilla->localconfig->cvsbin;
     $last_reader->sends_data_to(new Bugzilla::PatchReader::AddCVSContext(
       $context, Bugzilla->params->{'cvsroot_get'}
     ));
@@ -310,7 +310,7 @@ sub setup_template_patch_reader {
   $vars->{'collapsed'} = $cgi->param('collapsed');
   $vars->{'context'}   = $context;
   $vars->{'do_context'}
-    = Bugzilla->localconfig->{cvsbin}
+    = Bugzilla->localconfig->cvsbin
     && Bugzilla->params->{'cvsroot_get'}
     && !$vars->{'newid'};
 
index 1b3b1f69e57a1aa4f3d165e07b53f72e21022457..6c6c493d12a09e50cf5aa1895e104b55303b1ab0 100644 (file)
@@ -54,7 +54,7 @@ sub get_login_info {
   # Attachments are served from a separate host (ideally), and so
   # an evil attachment cannot abuse this check with a redirect.
   elsif (my $referer = $cgi->referer) {
-    my $urlbase = Bugzilla->localconfig->{urlbase};
+    my $urlbase = Bugzilla->localconfig->urlbase;
     $valid = 1 if $referer =~ /^\Q$urlbase\E/;
   }
 
index 28ff871dae9e5fa79da34b164aa1a7021cd3bedf..6becbc9a66bbea688c8252ac2e1ebfa7582553e4 100644 (file)
@@ -673,7 +673,7 @@ sub _get_new_bugmail_fields {
 
 sub _parse_see_also {
   my (@links) = @_;
-  my $urlbase = Bugzilla->localconfig->{urlbase};
+  my $urlbase = Bugzilla->localconfig->urlbase;
   my $bug_link_re = qr/^\Q$urlbase\Eshow_bug\.cgi\?id=(\d+)$/;
 
   return grep { /^\d+$/ } map { /$bug_link_re/ ? int($1) : () } @links;
index 9d3dda685257b5318a45af84c55764ba357c4584..b3606468a51024f90f738daf6ad29779ce3fffd2 100644 (file)
@@ -93,7 +93,7 @@ sub _check_value {
 sub local_uri {
   my ($self, $bug_id) = @_;
   $bug_id ||= '';
-  return Bugzilla->localconfig->{urlbase} . "show_bug.cgi?id=$bug_id";
+  return Bugzilla->localconfig->urlbase . "show_bug.cgi?id=$bug_id";
 }
 
 sub bug {
index f2404b8b66f9414ef140f4b27c64808b923d4bb8..e6da5a2a2487d361d329e3ca4030923f232ba377 100644 (file)
@@ -126,7 +126,7 @@ sub new {
 sub target_uri {
   my ($self) = @_;
 
-  my $base = Bugzilla->localconfig->{urlbase};
+  my $base = Bugzilla->localconfig->urlbase;
   if (my $request_uri = $self->request_uri) {
     my $base_uri = URI->new($base);
     $base_uri->path('');
@@ -386,7 +386,7 @@ sub _prevent_unsafe_response {
 
     # Note that urlbase must end with a /.
     # It almost certainly does, but let's be extra careful.
-    my $urlbase = Bugzilla->localconfig->{urlbase};
+    my $urlbase = Bugzilla->localconfig->urlbase;
     $urlbase =~ s{/$}{};
     qr{
             # Begins with literal urlbase
@@ -616,7 +616,7 @@ sub send_cookie {
   }
 
   # Add the default path and the domain in.
-  state $uri = URI->new(Bugzilla->localconfig->{urlbase});
+  state $uri = URI->new(Bugzilla->localconfig->urlbase);
   $paramhash{'-path'} = $uri->path;
 
   # we don't set the domain.
@@ -710,7 +710,7 @@ sub redirect_search_url {
 
 sub redirect_to_https {
   my $self    = shift;
-  my $urlbase = Bugzilla->localconfig->{'urlbase'};
+  my $urlbase = Bugzilla->localconfig->urlbase;
 
   # If this is a POST, we don't want ?POSTDATA in the query string.
   # We expect the client to re-POST, which may be a violation of
@@ -733,14 +733,14 @@ sub redirect_to_https {
 sub redirect_to_urlbase {
   my $self = shift;
   my $path = $self->url('-path_info' => 1, '-query' => 1, '-relative' => 1);
-  print $self->redirect('-location' => Bugzilla->localconfig->{urlbase} . $path);
+  print $self->redirect('-location' => Bugzilla->localconfig->urlbase . $path);
   exit;
 }
 
 sub base_redirect {
   my ($self, $path, $is_perm) = @_;
   print $self->redirect(
-    -location => Bugzilla->localconfig->{basepath} . ($path || ''),
+    -location => Bugzilla->localconfig->basepath . ($path || ''),
     -status   => $is_perm ? '301 Moved Permanently' : '302 Found'
   );
   exit;
index 39c7b228f59a73679944533a5578f685aca59086..60faa2fbc8ebc5a5056a0636e0c6ba77112e5855 100644 (file)
@@ -255,7 +255,7 @@ sub write_params {
   local $Data::Dumper::Sortkeys = 1;
 
   my %params = %$param_data;
-  $params{urlbase} = Bugzilla->localconfig->{urlbase};
+  $params{urlbase} = Bugzilla->localconfig->urlbase;
   __PACKAGE__->_write_file(Data::Dumper->Dump([\%params], ['*param']));
 
   # And now we have to reset the params cache so that Bugzilla will re-read
index fe01e99098bf07da353f7e5fc7f6a808a78503b9..45c84ace2c5772810d8c984fc859c138906ec72e 100644 (file)
@@ -779,7 +779,7 @@ sub DEFAULT_CSP {
 # Because show_bug code lives in many different .cgi files,
 # we needed a centralized place to define the policy.
 # normally the policy would just live in one .cgi file.
-# Additionally, Bugzilla->localconfig->{urlbase} cannot be called at compile time, so this can't be a constant.
+# Additionally, Bugzilla->localconfig->urlbase cannot be called at compile time, so this can't be a constant.
 sub SHOW_BUG_MODAL_CSP {
   my ($bug_id) = @_;
   my %policy = (
@@ -811,7 +811,7 @@ sub SHOW_BUG_MODAL_CSP {
     worker_src => ['none',],
   );
   if (Bugzilla::Util::use_attachbase() && $bug_id) {
-    my $attach_base = Bugzilla->localconfig->{'attachment_base'};
+    my $attach_base = Bugzilla->localconfig->attachment_base;
     $attach_base =~ s/\%bugid\%/$bug_id/g;
     push @{$policy{img_src}}, $attach_base;
     push @{$policy{media_src}}, $attach_base;
index 543549293086bf49b7bbafa8100d3e65a111602f..a4bc54a33827d4813fd12a3a68da0587d561d89c 100644 (file)
@@ -162,11 +162,11 @@ sub connect_shadow {
   $connect_params->{db_port} = Bugzilla->get_param_with_override('shadowdbport');
   $connect_params->{db_sock} = Bugzilla->get_param_with_override('shadowdbsock');
 
-  if ( Bugzilla->localconfig->{'shadowdb_user'}
-    && Bugzilla->localconfig->{'shadowdb_pass'})
+  if ( Bugzilla->localconfig->shadowdb_user
+    && Bugzilla->localconfig->shadowdb_pass)
   {
-    $connect_params->{db_user} = Bugzilla->localconfig->{'shadowdb_user'};
-    $connect_params->{db_pass} = Bugzilla->localconfig->{'shadowdb_pass'};
+    $connect_params->{db_user} = Bugzilla->localconfig->shadowdb_user;
+    $connect_params->{db_pass} = Bugzilla->localconfig->shadowdb_pass;
   }
   return $shadow_dbh = _connect($connect_params);
 }
@@ -292,7 +292,7 @@ sub bz_create_database {
 
   # See if we can connect to the actual Bugzilla database.
   my $conn_success = eval { $dbh = connect_main() };
-  my $db_name      = Bugzilla->localconfig->{db_name};
+  my $db_name      = Bugzilla->localconfig->db_name;
 
   if (!$conn_success) {
     $dbh = _get_no_db_connection();
@@ -511,7 +511,7 @@ sub bz_server_version {
 sub bz_last_key {
   my ($self, $table, $column) = @_;
 
-  return $self->last_insert_id(Bugzilla->localconfig->{db_name},
+  return $self->last_insert_id(Bugzilla->localconfig->db_name,
     undef, $table, $column);
 }
 
index 5f0ebbb7474432ad69927e526d43de193a93a63f..cde571dcaf97de201cc0c5ad02b7c96c88aa24ae 100644 (file)
@@ -289,7 +289,7 @@ sub bz_check_server_version {
   my $self = shift;
 
   my $lc = Bugzilla->localconfig;
-  if (lc(Bugzilla->localconfig->{db_name}) eq 'mysql') {
+  if (lc(Bugzilla->localconfig->db_name) eq 'mysql') {
     die "It is not safe to run Bugzilla inside a database named 'mysql'.\n"
       . " Please pick a different value for \$db_name in localconfig.\n";
   }
@@ -381,7 +381,7 @@ sub bz_setup_database {
   }
 
   # Upgrade tables from MyISAM to InnoDB
-  my $db_name       = Bugzilla->localconfig->{db_name};
+  my $db_name       = Bugzilla->localconfig->db_name;
   my $myisam_tables = $self->selectcol_arrayref(
     'SELECT TABLE_NAME FROM information_schema.TABLES
           WHERE TABLE_SCHEMA = ? AND ENGINE = ?', undef, $db_name, 'MyISAM'
@@ -823,7 +823,7 @@ sub default_row_format {
 
 sub _alter_db_charset_to_utf8 {
   my $self    = shift;
-  my $db_name = Bugzilla->localconfig->{db_name};
+  my $db_name = Bugzilla->localconfig->db_name;
   my $charset = $self->utf8_charset;
   my $collate = $self->utf8_collate;
   $self->do("ALTER DATABASE $db_name CHARACTER SET $charset COLLATE $collate");
index aa53b53433e76ae78abccbdb2b1e64e66fdf7a01..db8932c9e4f169bcc75159f512c932cdb5f30c20 100644 (file)
@@ -54,7 +54,7 @@ sub BUILDARGS {
 
   # You can never connect to Oracle without a DB name,
   # and there is no default DB.
-  $dbname ||= Bugzilla->localconfig->{db_name};
+  $dbname ||= Bugzilla->localconfig->db_name;
 
   # Set the language enviroment
   $ENV{'NLS_LANG'} = '.AL32UTF8' if Bugzilla->params->{'utf8'};
@@ -646,7 +646,7 @@ sub bz_setup_database {
   # Create a WORLD_LEXER named BZ_LEX for multilingual fulltext search
   my $lexer = $self->selectcol_arrayref(
     "SELECT pre_name FROM CTXSYS.CTX_PREFERENCES WHERE pre_name = ? AND
-          pre_owner = ?", undef, 'BZ_LEX', uc(Bugzilla->localconfig->{db_user})
+          pre_owner = ?", undef, 'BZ_LEX', uc(Bugzilla->localconfig->db_user)
   );
   if (!@$lexer) {
     $self->do(
index fe5602637f8d78410fb0b9402e219fae6cd2e058..4fad160f4ef22286e94ac1f5dc9f42e2b8e9f6c4 100644 (file)
@@ -60,8 +60,8 @@ use constant HTTPD_ENV => qw(
 ###############
 
 # Used by the permissions "constants" below.
-sub _suexec { Bugzilla->localconfig->{'use_suexec'} }
-sub _group  { Bugzilla->localconfig->{'webservergroup'} }
+sub _suexec { Bugzilla->localconfig->use_suexec }
+sub _group  { Bugzilla->localconfig->webservergroup }
 
 # Writeable by the owner only.
 use constant OWNER_WRITE => 0600;
@@ -773,7 +773,7 @@ sub _fix_perms_recursively {
 sub _check_web_server_group {
   my ($output) = @_;
 
-  my $group    = Bugzilla->localconfig->{'webservergroup'};
+  my $group    = Bugzilla->localconfig->webservergroup;
   my $filename = bz_locations()->{'localconfig'};
   my $group_id;
 
index aa93709a799a5d3ef984f386ee35787cb8bea1f4..0dcba2f5141732849fa5c06e843e679e6f44719a 100644 (file)
@@ -39,6 +39,7 @@ use parent qw(Exporter);
 our @EXPORT_OK = qw(
   read_localconfig
   update_localconfig
+  LOCALCONFIG_VARS
 );
 
 # might want to change this for upstream
@@ -96,7 +97,7 @@ use constant LOCALCONFIG_VARS => (
   {name => 'memcached_servers',   default => '',},
   {name => 'memcached_namespace', default => "bugzilla:",},
   {name => 'urlbase',             default => '',},
-  {name => 'canonical_urlbase',   default => '',},
+  {name => 'canonical_urlbase',   lazy => 1},
   {name => 'attachment_base',     default => '',},
   {name => 'ses_username',        default => '',},
   {name => 'ses_password',        default => '',},
@@ -192,16 +193,6 @@ sub read_localconfig {
     ? _read_localconfig_from_env()
     : _read_localconfig_from_file($include_deprecated);
 
-  # Use the site's URL as the default Canonical URL
-  $config->{canonical_urlbase} //= $config->{urlbase};
-
-  # Get the absolute path of the URLBase value
-  $config->{basepath} = do {
-    my $path = $config->{urlbase};
-    $path =~ s/^https?:\/\/.*?\//\//;
-    $path;
-  };
-
   return $config;
 }
 
@@ -264,7 +255,7 @@ sub update_localconfig {
     }
   }
 
-  if (!$localconfig->{'interdiffbin'} && $output) {
+  if (!$localconfig->{interdiffbin} && $output) {
     print "\n", install_string('patchutils_missing'), "\n";
   }
 
index 6a82a1bf8d6ed1f4cb9fb4ae2231190e965a626e..e0176fcb25a7019537edcf70c14bc6af7d25140a 100644 (file)
@@ -209,7 +209,7 @@ sub _get_apachectl {
 sub check_webdotbase {
   my ($output) = @_;
 
-  my $webdotbase = Bugzilla->localconfig->{'webdotbase'};
+  my $webdotbase = Bugzilla->localconfig->webdotbase;
   return 1 if $webdotbase =~ /^https?:/;
 
   my $return;
@@ -241,7 +241,7 @@ sub check_webdotbase {
 sub check_font_file {
   my ($output) = @_;
 
-  my $font_file = Bugzilla->localconfig->{'font_file'};
+  my $font_file = Bugzilla->localconfig->font_file;
 
   my $readable;
   $readable = 1 if -r $font_file;
diff --git a/Bugzilla/Localconfig.pm b/Bugzilla/Localconfig.pm
new file mode 100644 (file)
index 0000000..abbbed0
--- /dev/null
@@ -0,0 +1,39 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+package Bugzilla::Localconfig;
+use 5.10.1;
+use Moo;
+use MooX::StrictConstructor;
+
+use Bugzilla::Install::Localconfig qw(LOCALCONFIG_VARS);
+
+foreach my $var (LOCALCONFIG_VARS) {
+  if ($var->{lazy}) {
+    has $var->{name} => (is => 'lazy');
+  }
+  else {
+    has $var->{name} => (is => 'ro', required => 1);
+  }
+}
+
+has 'basepath' => (is => 'lazy');
+
+# Use the site's URL as the default Canonical URL
+sub _build_canonical_urlbase {
+  my ($self) = @_;
+  $self->urlbase;
+}
+
+sub _build_basepath {
+  my ($self) = @_;
+  my $path = $self->urlbase;
+  $path =~ s/^https?:\/\/.*?\//\//;
+  return $path;
+}
+
+1;
index 9a2023a8c7df1116cfade656b0c2c04588005b73..bd02bc1ccf2151b799ab5f9d490e8de11e948f27 100644 (file)
@@ -106,7 +106,7 @@ sub MessageToMTA {
   # We add this header to uniquely identify all email that we
   # send as coming from this Bugzilla installation.
   #
-  $email->header_set('X-Bugzilla-URL', Bugzilla->localconfig->{urlbase});
+  $email->header_set('X-Bugzilla-URL', Bugzilla->localconfig->urlbase);
 
   # We add this header to mark the mail as "auto-generated" and
   # thus to hopefully avoid auto replies.
@@ -157,7 +157,7 @@ sub MessageToMTA {
   else {
     # Sendmail will automatically append our hostname to the From
     # address, but other mailers won't.
-    my $urlbase = Bugzilla->localconfig->{urlbase};
+    my $urlbase = Bugzilla->localconfig->urlbase;
     $urlbase =~ m|//([^:/]+)[:/]?|;
     $hostname = $1;
     $from .= "\@$hostname" if $from !~ /@/;
@@ -273,7 +273,7 @@ sub build_thread_marker {
     $user_id = Bugzilla->user->id;
   }
 
-  my $sitespec = '@' . Bugzilla->localconfig->{urlbase};
+  my $sitespec = '@' . Bugzilla->localconfig->urlbase;
   $sitespec =~ s/:\/\//\./;    # Make the protocol look like part of the domain
   $sitespec =~ s/^([^:\/]+):(\d+)/$1/;    # Remove a port number, to relocate
   if ($2) {
index 10a45caeea160a22f05d9729eaad8f7ba30ab819..aa9fbf70983c322bf5963a7b6bc824190ab973cd 100644 (file)
@@ -34,9 +34,9 @@ sub _new {
 
   # always return an object to simplify calling code when memcached is
   # disabled.
-  my $servers = Bugzilla->localconfig->{memcached_servers};
+  my $servers = Bugzilla->localconfig->memcached_servers;
   if (Bugzilla->feature('memcached') && $servers) {
-    $self->{namespace} = Bugzilla->localconfig->{memcached_namespace};
+    $self->{namespace} = Bugzilla->localconfig->memcached_namespace;
     TRACE("connecting servers: $servers, namespace: $self->{namespace}");
     $self->{memcached} = Cache::Memcached::Fast->new({
       servers         => [_parse_memcached_server_list($servers)],
index 335caedbbcf87ac142fcad6930b718841db11c95..5fb6b07fd109421980d9b5e075f8cbeffb94b82e 100644 (file)
@@ -368,7 +368,7 @@ sub _handle_alias {
     if ($bug_id && Bugzilla->user->can_see_bug($bug_id) && !i_am_webservice()) {
       $alias = url_quote($alias);
       print Bugzilla->cgi->redirect(
-        -uri => Bugzilla->localconfig->{urlbase} . "show_bug.cgi?id=$alias");
+        -uri => Bugzilla->localconfig->urlbase . "show_bug.cgi?id=$alias");
       exit;
     }
   }
index 7489bc5a0c71a2e5c707e44ade56dececa773f01..4893166c66cebf79fe1df7e1c6d28f522e0f0cee 100644 (file)
@@ -196,7 +196,7 @@ sub quoteUrls {
   }
 
   # Provide tooltips for full bug links (Bug 74355)
-  my $urlbase_re = '(' . quotemeta(Bugzilla->localconfig->{urlbase}) . ')';
+  my $urlbase_re = '(' . quotemeta(Bugzilla->localconfig->urlbase) . ')';
   $text =~ s~\b(${urlbase_re}\Qshow_bug.cgi?id=\E([0-9]+)(\#c([0-9]+))?)\b
               ~($things[$count++] = $bug_link_func->($3, $1, { comment_num => $5, user => $user })) &&
                ("\x{FDD2}" . ($count-1) . "\x{FDD3}")
@@ -289,7 +289,7 @@ sub get_attachment_link {
 
     $link_text =~ s/ \[details\]$//;
     $link_text =~ s/ \[diff\]$//;
-    state $basepath = Bugzilla->localconfig->{basepath};
+    state $basepath = Bugzilla->localconfig->basepath;
     my $linkval = "${basepath}attachment.cgi?id=$attachid";
 
     # If the attachment is a patch and patch_viewer feature is
@@ -381,7 +381,7 @@ sub multiline_sprintf {
 sub version_filter {
   my ($file_url) = @_;
   return
-      Bugzilla->localconfig->{basepath}
+      Bugzilla->localconfig->basepath
     . "static/v"
     . Bugzilla->VERSION
     . "/$file_url";
@@ -985,10 +985,10 @@ sub create {
       'sudoer' => sub { return Bugzilla->sudoer; },
 
       # Allow templates to access the "corect" URLBase value
-      'urlbase' => sub { return Bugzilla->localconfig->{urlbase}; },
+      'urlbase' => sub { return Bugzilla->localconfig->urlbase; },
 
       # Allow templates to get the absolute path of the URLBase value
-      'basepath' => sub { return Bugzilla->localconfig->{basepath}; },
+      'basepath' => sub { return Bugzilla->localconfig->basepath; },
 
       # Allow templates to access docs url with users' preferred language
       'docs_urlbase' => sub {
@@ -1093,7 +1093,7 @@ sub create {
         return '' unless @sigs;
 
         # use a URI object to encode the query string part.
-        my $uri = URI->new(Bugzilla->localconfig->{urlbase} . 'page.cgi');
+        my $uri = URI->new(Bugzilla->localconfig->urlbase . 'page.cgi');
         $uri->query_form({'id' => 'socorro-lens.html', 's' => join("\\", @sigs)});
         return $uri;
       },
index 7c9137085d35f0e337997f94f0a27b56acb096de..15697c998a153d3f3542b1f1dbb34a3681ddcd90 100644 (file)
@@ -64,7 +64,7 @@ sub issue_auth_delegation_token {
   my $dbh      = Bugzilla->dbh;
   my $user     = Bugzilla->user;
   my $checksum = hmac_sha256_base64($user->id, $uri,
-    Bugzilla->localconfig->{'site_wide_secret'});
+    Bugzilla->localconfig->site_wide_secret);
 
   return _create_token($user->id, 'auth_delegation', $checksum);
 }
@@ -83,7 +83,7 @@ sub check_auth_delegation_token {
 
   if ($eventdata) {
     my $checksum = hmac_sha256_base64($user->id, $uri,
-      Bugzilla->localconfig->{'site_wide_secret'});
+      Bugzilla->localconfig->site_wide_secret);
     if ($eventdata eq $checksum) {
       delete_token($token);
       return 1;
@@ -241,7 +241,7 @@ sub issue_hash_sig {
   $salt //= generate_random_password(16);
 
   my $hmac = hmac_sha256_base64($salt, $type, $data,
-    Bugzilla->localconfig->{site_wide_secret});
+    Bugzilla->localconfig->site_wide_secret);
   return sprintf("%s|%s|%x", $salt, $hmac, length($data));
 }
 
@@ -272,7 +272,7 @@ sub issue_hash_token {
   # $token needs to be a byte string.
   utf8::encode($token);
   $token
-    = hmac_sha256_base64($token, Bugzilla->localconfig->{'site_wide_secret'});
+    = hmac_sha256_base64($token, Bugzilla->localconfig->site_wide_secret);
   $token =~ s/\+/-/g;
   $token =~ s/\//_/g;
 
index ddeda869ff7eac3600f17dcc2fff837951b819cd..aec096155860fd7b5883e525f8f167e7f5c673ba 100644 (file)
@@ -294,7 +294,7 @@ sub is_webserver_group {
 
   state $web_server_gid;
   if (!defined $web_server_gid) {
-    my $web_server_group = Bugzilla->localconfig->{webservergroup};
+    my $web_server_group = Bugzilla->localconfig->webservergroup;
 
     if ($web_server_group eq '' || ON_WINDOWS) {
       $web_server_gid = $effective_gids[0];
@@ -318,7 +318,7 @@ sub is_webserver_group {
 # (doing so can mess up XML-RPC).
 sub do_ssl_redirect_if_required {
   return if !i_am_cgi();
-  my $uri = URI->new(Bugzilla->localconfig->{'urlbase'});
+  my $uri = URI->new(Bugzilla->localconfig->urlbase);
   return if $uri->scheme ne 'https';
 
   # If we're already running under SSL, never redirect.
@@ -423,8 +423,8 @@ sub is_ipv6 {
 }
 
 sub use_attachbase {
-  my $attachbase = Bugzilla->localconfig->{'attachment_base'};
-  my $urlbase    = Bugzilla->localconfig->{'urlbase'};
+  my $attachbase = Bugzilla->localconfig->attachment_base;
+  my $urlbase    = Bugzilla->localconfig->urlbase;
   return ($attachbase ne '' && $attachbase ne $urlbase);
 }
 
@@ -993,7 +993,7 @@ Bugzilla::Util - Generic utility functions for bugzilla
   # Functions that tell you about your environment
   my $is_cgi   = i_am_cgi();
   my $is_webservice = i_am_webservice();
-  my $urlbase  = Bugzilla->localconfig->{urlbase};
+  my $urlbase  = Bugzilla->localconfig->urlbase;
 
   # Data manipulation
   ($removed, $added) = diff_arrays(\@old, \@new);
index e763831e5b553546470a3ee57937374662f309c2..3d8104f353e8ea298772841c29e6497fe6dd7299 100644 (file)
@@ -155,7 +155,7 @@ sub retrieve_json_from_get {
   # order to throw proper errors. We use the installation's urlbase as
   # the id, in this case.
   else {
-    $id = Bugzilla->localconfig->{urlbase};
+    $id = Bugzilla->localconfig->urlbase;
   }
 
   # Setting _bz_request_id here is required in case we throw errors early,
index f4be301833b1573ad9980d96f2250a2c7ef186af..b64b4f67646290619886931a26b87ec9f2d0ed29 100644 (file)
@@ -92,7 +92,7 @@ sub handle {
   # also set up the correct handler method
   my $obj = {
     version => '1.1',
-    id      => Bugzilla->localconfig->{urlbase},
+    id      => Bugzilla->localconfig->urlbase,
     method  => $self->bz_method_name,
     params  => $params
   };
index 40e042221eeb0e1eb35d17e58fba439c8695c6c4..6f167225064cd6d121f1ee7e3d446382a2ef4b0f 100755 (executable)
@@ -288,7 +288,7 @@ sub get_attachment {
       # make sure we were not going to request credentials on the
       # alternate host.
       Bugzilla->login();
-      my $attachbase = Bugzilla->localconfig->{'attachment_base'};
+      my $attachbase = Bugzilla->localconfig->attachment_base;
 
       # Replace %bugid% by the ID of the bug the attachment
       # belongs to, if present.
index 88121484464153ac1043ab4c0fbb71e73d0c28b6..433f6f7252c374ad3a4546669ab383a88c661a52 100755 (executable)
@@ -45,7 +45,7 @@ $current_panel = $1;
 my $current_module;
 my @panels       = ();
 my $param_panels = Bugzilla::Config::param_panels();
-my $override     = Bugzilla->localconfig->{param_override};
+my $override     = Bugzilla->localconfig->param_override;
 foreach my $panel (keys %$param_panels) {
   my $module = $param_panels->{$panel};
   require_module($module);
index b900e17eeb2c94f7eb31b154709e7e7d74a6b40c..5117cfd4d3c9a141690f4468f33cd0ce96c6e9b5 100644 (file)
@@ -44,7 +44,7 @@ sub _validate_uri {
   my $uri = URI->new($url);
   $uri->query(undef);
   $uri->fragment(undef);
-  if ($uri->as_string ne Bugzilla->localconfig->{urlbase} . 'buglist.cgi') {
+  if ($uri->as_string ne Bugzilla->localconfig->urlbase . 'buglist.cgi') {
     ThrowUserError('bitly_unsupported');
   }
 
@@ -81,7 +81,7 @@ sub list {
 
   # form a bug_id only url, sanity check the length
   $uri
-    = URI->new(Bugzilla->localconfig->{urlbase}
+    = URI->new(Bugzilla->localconfig->urlbase
       . 'buglist.cgi?bug_id='
       . join(',', map { $_->[0] } @$data));
   if (length($uri->as_string) > CGI_URI_LIMIT) {
index 18e3370ccd7f31d18f96ad3f1681c646133912e7..a75a41f88fac45a364146be04128aab304bf4921 100644 (file)
@@ -276,7 +276,7 @@ sub _add_activities_to_stream {
 
       # split see-also
       if ($change->{fieldname} eq 'see_also') {
-        my $url_base = Bugzilla->localconfig->{urlbase};
+        my $url_base = Bugzilla->localconfig->urlbase;
         foreach my $f (qw( added removed )) {
           my @values;
           foreach my $value (split(/, /, $change->{$f})) {
index 8d621cb2579aa8c2f417273d342e11d01ef381dc..b1d58be5ca4eecc9ec70b8f563e3ecf21c4afb01 100644 (file)
@@ -138,7 +138,7 @@ sub get_configuration {
 sub get_empty {
   my ($self) = @_;
   return {
-    ref => $self->type('string', Bugzilla->localconfig->{urlbase} . "bzapi/"),
+    ref => $self->type('string', Bugzilla->localconfig->urlbase . "bzapi/"),
     documentation => $self->type('string', BZAPI_DOC),
     version       => $self->type('string', BUGZILLA_VERSION)
   };
index 6f7e2c0251bb17832b5f44ad4719b8a2790e5b2d..2a37ab073db39c13f42e76de288f969f35398603 100644 (file)
@@ -44,7 +44,7 @@ our @EXPORT = qw(
 # Return an URL base appropriate for constructing a ref link
 # normally required by REST API calls.
 sub ref_urlbase {
-  return Bugzilla->localconfig->{urlbase} . "bzapi";
+  return Bugzilla->localconfig->urlbase . "bzapi";
 }
 
 # convert certain fields within a bug object
index 328bab48fd878585009c6cc321092e7f8d386ccf..772f1dd22d778904bcad3c6db5629c5f48368133 100644 (file)
@@ -40,7 +40,7 @@ sub new {
 sub login_uri {
   my ($class, $target_uri) = @_;
 
-  my $uri = URI->new(Bugzilla->localconfig->{urlbase} . "github.cgi");
+  my $uri = URI->new(Bugzilla->localconfig->urlbase . "github.cgi");
   $uri->query_form(target_uri => $target_uri);
   return $uri;
 }
@@ -53,7 +53,7 @@ sub authorize_uri {
     client_id    => Bugzilla->params->{github_client_id},
     scope        => 'user:email',
     state        => $state,
-    redirect_uri => Bugzilla->localconfig->{urlbase} . "github.cgi",
+    redirect_uri => Bugzilla->localconfig->urlbase . "github.cgi",
   );
 
   return $uri;
@@ -68,7 +68,7 @@ sub get_email_key {
   $digest->add(remote_ip());
   $digest->add($cgi->cookie('Bugzilla_github_token')
       // Bugzilla->request_cache->{github_token} // '');
-  $digest->add(Bugzilla->localconfig->{site_wide_secret});
+  $digest->add(Bugzilla->localconfig->site_wide_secret);
   return $digest->hexdigest;
 }
 
index c0165c5acfa6ec4d0f16696199c06bb8f8bcfe06..15d0cdd4b7aa44c367c17dfd0f7103926491c655 100644 (file)
@@ -219,7 +219,7 @@ sub _mk_choose_email {
 
   return sub {
     my $email = shift;
-    my $uri   = URI->new(Bugzilla->localconfig->{urlbase} . "github.cgi");
+    my $uri   = URI->new(Bugzilla->localconfig->urlbase . "github.cgi");
     $uri->query_form(state => $state, email => $email);
     return $uri;
   };
index 7ccaf31e6792dff8d8ed69dc0b204cb2a68039fd..779ccaf17f475eee287b2f15293aa63ee2f54357 100644 (file)
@@ -134,7 +134,7 @@ sub template_before_process {
 
       # split see-also
       if ($change->{fieldname} eq 'see_also') {
-        my $url_base = Bugzilla->localconfig->{urlbase};
+        my $url_base = Bugzilla->localconfig->urlbase;
         foreach my $f (qw( added removed )) {
           my @values;
           foreach my $value (split(/, /, $change->{$f})) {
index bb0d523ad66d1f2237e5be02613287373ae8ed30..f9f8fcb46bd3765c0353be7ba16d8e804e883392 100644 (file)
@@ -196,7 +196,7 @@ sub _validate_config {
 sub _cipher {
   my ($self) = @_;
   $self->{_cipher} ||= Crypt::CBC->new(
-    -key    => Bugzilla->localconfig->{'site_wide_secret'},
+    -key    => Bugzilla->localconfig->site_wide_secret,
     -cipher => 'DES_EDE3'
   );
   return $self->{_cipher};
index dda73dade28a29829dffde2d9e8dd77cc7eafd19..68f2aabcbd1841e5d091f5cac22c01d089680b46 100644 (file)
@@ -28,7 +28,7 @@ sub init {
     $self->{queue_name} = $self->config->{queue};
   }
   else {
-    my $queue_name = Bugzilla->localconfig->{'urlbase'};
+    my $queue_name = Bugzilla->localconfig->urlbase;
     $queue_name =~ s#^https?://##;
     $queue_name =~ s#/$#|#;
     $queue_name .= generate_random_password(16);
index 8856f481bea38380a2a96d88f789dd793faaaa2f..015a022c78181cc615c7b4a83ebeb24a9c440293 100644 (file)
@@ -239,7 +239,7 @@ sub send {
   $request->authorization_basic($self->config->{service_now_user},
     $self->config->{service_now_pass});
 
-  $self->{lwp} ||= LWP::UserAgent->new(agent => Bugzilla->localconfig->{urlbase});
+  $self->{lwp} ||= LWP::UserAgent->new(agent => Bugzilla->localconfig->urlbase);
   my $result = $self->{lwp}->request($request);
 
   # http level errors
index 1eb6f22c6033679b9f4a019f0450292edc4f29e9..4988fcadfb38bbf1375207fcf6ad9eeb7c67eba5 100644 (file)
@@ -112,7 +112,7 @@ sub send {
         }
       }
     }
-    $text .= Bugzilla->localconfig->{urlbase} . "show_bug.cgi?id=" . $bug->id;
+    $text .= Bugzilla->localconfig->urlbase . "show_bug.cgi?id=" . $bug->id;
 
     my $room_id     = $self->config->{spark_room_id};
     my $message_uri = $self->_spark_uri('messages');
index 719bff0f59bf821ba898ed0b45ea21e031e447d9..b8a22f13c818fbbaa0d1bd7139efb379c609848d 100644 (file)
@@ -130,7 +130,7 @@ sub object_validators {
         # PGP keys must be ASCII-armoured.
         my $tct = Bugzilla::Extension::SecureMail::TCT->new(
           public_key => $value,
-          command    => Bugzilla->localconfig->{tct_bin},
+          command    => Bugzilla->localconfig->tct_bin,
         );
         unless ($tct->is_valid->get) {
           ThrowUserError('securemail_invalid_key',
@@ -480,7 +480,7 @@ sub _make_secure {
 
     my $tct = Bugzilla::Extension::SecureMail::TCT->new(
       public_key => $key,
-      command    => Bugzilla->localconfig->{tct_bin},
+      command    => Bugzilla->localconfig->tct_bin,
     );
 
     if (scalar $email->parts > 1) {
@@ -580,7 +580,7 @@ sub _make_secure {
     my $message;
     my $email_type = $email->header('X-Bugzilla-Type');
     my $vars       = {
-      'urlbase'    => Bugzilla->localconfig->{urlbase},
+      'urlbase'    => Bugzilla->localconfig->urlbase,
       'bug_id'     => $bug_id,
       'maintainer' => Bugzilla->params->{'maintainer'},
       'email_type' => $email_type
@@ -619,7 +619,7 @@ sub _make_secure {
 sub _tct_encrypt {
   my ($tct, $text, $bug_id) = @_;
 
-  my $comment = Bugzilla->localconfig->{urlbase}
+  my $comment = Bugzilla->localconfig->urlbase
     . ($bug_id ? 'show_bug.cgi?id=' . $bug_id : '');
   my $encrypted;
   my $ok = eval { $encrypted = $tct->encrypt($text, $comment)->get; 1 };
index c606702ae0793aad1dcc8d803749e014b8f23629..f02a911245a87b4fa6e314fb3615228aa76c85b1 100644 (file)
@@ -80,7 +80,7 @@ sub page_before_template {
 
 sub install_before_final_checks {
   my ($self) = @_;
-  if (!Bugzilla->localconfig->{urlbase}) {
+  if (!Bugzilla->localconfig->urlbase) {
     print STDERR get_text('sitemap_no_urlbase'), "\n";
     return;
   }
@@ -89,7 +89,7 @@ sub install_before_final_checks {
     return;
   }
 
-  return if (Bugzilla->localconfig->{urlbase} ne 'https://bugzilla.mozilla.org/');
+  return if (Bugzilla->localconfig->urlbase ne 'https://bugzilla.mozilla.org/');
 }
 
 sub install_filesystem {
@@ -126,7 +126,7 @@ EOT
 
 sub before_robots_txt {
   my ($self, $args) = @_;
-  $args->{vars}{SITEMAP_URL} = Bugzilla->localconfig->{urlbase} . SITEMAP_URL;
+  $args->{vars}{SITEMAP_URL} = Bugzilla->localconfig->urlbase . SITEMAP_URL;
 }
 
 __PACKAGE__->NAME;
index fb945e3249953cfbf1a87e980d3ca8ea71423868..3f868cc5b863d4a6667cfd7d14b756fb080eed12 100644 (file)
@@ -149,7 +149,7 @@ END
     $index_xml .= "
   <sitemap>
     <loc>"
-      . Bugzilla->localconfig->{urlbase} . "data/$extension_name/$filename</loc>
+      . Bugzilla->localconfig->urlbase . "data/$extension_name/$filename</loc>
     <lastmod>$timestamp</lastmod>
   </sitemap>
 ";
@@ -172,9 +172,9 @@ END
 sub _generate_sitemap_file {
   my ($extension_name, $filecount, $products, $bugs) = @_;
 
-  my $bug_url = Bugzilla->localconfig->{urlbase} . 'show_bug.cgi?id=';
+  my $bug_url = Bugzilla->localconfig->urlbase . 'show_bug.cgi?id=';
   my $product_url
-    = Bugzilla->localconfig->{urlbase} . 'describecomponents.cgi?product=';
+    = Bugzilla->localconfig->urlbase . 'describecomponents.cgi?product=';
 
   my $sitemap_xml = <<END;
 <?xml version="1.0" encoding="UTF-8"?>
index 2d53f9b9e85e47dbbde071488e23a5dc7c4edf14..e93ae09adbb9edefc5dfb92f0f80516809d67337 100755 (executable)
@@ -26,7 +26,7 @@ BEGIN { Bugzilla->extensions }
 use Bugzilla::Extension::GitHubAuth::Client;
 
 my $cgi     = Bugzilla->cgi;
-my $urlbase = Bugzilla->localconfig->{urlbase};
+my $urlbase = Bugzilla->localconfig->urlbase;
 
 if (lc($cgi->request_method) eq 'post') {
 
index 888f6fc1e7cee6f23f2961f21f796f029d343386..92e947da31e9dee80a4e83ac27b6cdedde5c4e5e 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -80,7 +80,7 @@ else {
   if ($user_id && $user->in_group('admin')) {
 
     # If 'urlbase' is not set, display the Welcome page.
-    unless (Bugzilla->localconfig->{'urlbase'}) {
+    unless (Bugzilla->localconfig->urlbase) {
       $template->process('welcome-admin.html.tmpl')
         or ThrowTemplateError($template->error());
       exit;
index 1589189ac5b56d1ef1f283443eeff34935640251..b45c368498a97910bd21f4ad6a2b8ad726cf2df8 100755 (executable)
@@ -95,7 +95,7 @@ else {
   # the same product names.
   my $project = bz_locations()->{'project'} || '';
   my $image_file = join(':', ($project, $prod_id, @datasets));
-  my $key = Bugzilla->localconfig->{'site_wide_secret'};
+  my $key = Bugzilla->localconfig->site_wide_secret;
   $image_file = hmac_sha256_base64($image_file, $key) . '.png';
   $image_file =~ s/\+/-/g;
   $image_file =~ s/\//_/g;
index f64172848197b19db0444377f181aca0fed0412c..00e4648562afcbe477690e8c37a3fa1e88811846 100755 (executable)
@@ -63,6 +63,6 @@ Bugzilla::Field->create({
 });
 print "Done!\n";
 
-my $urlbase = Bugzilla->localconfig->{urlbase};
+my $urlbase = Bugzilla->localconfig->urlbase;
 print
   "Please visit ${urlbase}editfields.cgi?action=edit&name=$name to finish setting up this field.\n";
index 8cda770966422b9298af5eb8dbfd84426bbe20ec..314c558710f2596f6d254ca44ea5cec6be432610 100755 (executable)
@@ -25,8 +25,8 @@ my $root_mysql_pw = shift;
 defined $root_mysql_pw || die "MySQL root password required.\n";
 
 my $mysql_dbh = Bugzilla::DB::_connect({
-  db_driver => $localconfig->{db_driver},
-  db_host   => $localconfig->{db_host},
+  db_driver => $localconfig->db_driver,
+  db_host   => $localconfig->db_host,
   db_name   => 'mysql',
   db_user   => 'root',
   db_pass   => $root_mysql_pw
@@ -52,7 +52,7 @@ my $rows = $mysql_dbh->selectall_arrayref(
   "SELECT TABLE_NAME, COLUMN_NAME
        FROM INFORMATION_SCHEMA.COLUMNS
       WHERE TABLE_SCHEMA = ?
-            AND DATA_TYPE='datetime'", undef, Bugzilla->localconfig->{db_name}
+            AND DATA_TYPE='datetime'", undef, Bugzilla->localconfig->db_name
 );
 my $total = scalar @$rows;
 
index 4b9d9cc868bab7487a57037c751fff22da3a985d..3961b07cd480338c02b26126170f18f799a10e75 100755 (executable)
@@ -179,7 +179,7 @@ my %whitelist = (
 
 #
 
-my $db_name = Bugzilla->localconfig->{db_name};
+my $db_name = Bugzilla->localconfig->db_name;
 print <<EOF;
 WARNING
 
index 37252437afea85081985b3cdc415d84c8dbf5315..aac1995d1a4277e9a129b3549e589ddb420074df 100644 (file)
@@ -75,7 +75,7 @@ my @sorted_team_names = sort { ## no critic qw(BuiltinFunctions::ProhibitReverse
 } keys %$teams;
 
 my $vars = {
-  urlbase            => Bugzilla->localconfig->{urlbase},
+  urlbase            => Bugzilla->localconfig->urlbase,
   report_week        => $report_week,
   teams              => \@sorted_team_names,
   sec_keywords       => $sec_keywords,
@@ -132,7 +132,7 @@ $report_dump_file->spurt(Dumper($report));
 
 sub build_bugs_link {
   my ($arr, $product) = @_;
-  my $uri = URI->new(Bugzilla->localconfig->{urlbase} . 'buglist.cgi');
+  my $uri = URI->new(Bugzilla->localconfig->urlbase . 'buglist.cgi');
   $uri->query_param(bug_id => (join ',', @$arr));
   $uri->query_param(product => $product) if $product;
   return $uri->as_string;
index be0699412cc9661ea1dd7c106dcef77888ac15a4..f501b214e143f97fde6fe9b50e7d9524b70f1e13 100755 (executable)
@@ -122,7 +122,7 @@ my ($fh, $filename) = File::Temp::tempfile(
 chmod Bugzilla::Install::Filesystem::CGI_WRITE, $filename
   or warn install_string('chmod_failed', {path => $filename, error => $!});
 
-my $urlbase = Bugzilla->localconfig->{urlbase};
+my $urlbase = Bugzilla->localconfig->urlbase;
 
 print $fh "digraph G {";
 print $fh qq(
@@ -260,7 +260,7 @@ if ($bug_count > MAX_WEBDOT_BUGS) {
 my $webdotbase = Bugzilla->params->{'webdotbase'};
 
 if ($webdotbase =~ /^https?:/) {
-  $webdotbase =~ s/%(?:sslbase|urlbase)%/Bugzilla->localconfig->{urlbase}/eg;
+  $webdotbase =~ s/%(?:sslbase|urlbase)%/Bugzilla->localconfig->urlbase/eg;
   my $url = $webdotbase . $filename;
   $vars->{'image_url'} = $url . ".gif";
   $vars->{'map_url'}   = $url . ".map";
index 992e17fbcd86c28ec581062589445bc46d8569f1..08badc3f8af2cc6110b54584b5e2358428238abb 100644 (file)
@@ -40,7 +40,7 @@ my $bug_1 = Bugzilla::Bug->create({
 });
 ok($bug_1->id, "got a new bug");
 
-my $urlbase  = Bugzilla->localconfig->{urlbase};
+my $urlbase  = Bugzilla->localconfig->urlbase;
 my $bug_1_id = $bug_1->id;
 my $bug_2    = Bugzilla::Bug->create({
   short_desc => 'A bug that references another bug',
index 9579b0c39884d8bc25daeadfd43ea8e0cec0e2c0..0c08c185496d69c7eb1ed430aa3d13e4f4760338 100644 (file)
@@ -10,13 +10,21 @@ use 5.10.1;
 use lib qw( . lib local/lib/perl5 );
 use Bugzilla::Util qw(generate_random_password);
 use Bugzilla::Token qw(issue_hash_sig check_hash_sig);
-use Test::More;
+use Bugzilla::Localconfig;
+use Test2::V0;
+use Test2::Mock qw(mock);
 
-my $localconfig = {site_wide_secret => generate_random_password(256)};
-{
+my $site_wide_secret = generate_random_password(256);
+my $Localconfig = mock 'Bugzilla::Localconfig' => (
+  add_constructor => [fake_new => 'ref_copy'],
+  override => [
+    site_wide_secret => sub { $site_wide_secret },
+  ]
+);
 
+{
   package Bugzilla;
-  sub localconfig {$localconfig}
+  sub localconfig { Bugzilla::Localconfig->fake_new({}) }
 }
 
 my $sig = issue_hash_sig("hero", "batman");
index d91fe458b4ba7596270137931f6d4a40d92b73be..cff18b588f10602c58dd32d581dae78c8b9f98e0 100644 (file)
@@ -25,7 +25,7 @@ use Test::Mojo;
 
 my $oauth_login    = 'oauth@mozilla.bugs';
 my $oauth_password = 'password123456789!';
-my $referer        = Bugzilla->localconfig->{urlbase};
+my $referer        = Bugzilla->localconfig->urlbase;
 my $stash          = {};
 
 # Create user to use as OAuth2 resource owner
index 05255adcfadfb108bfb8d19f63a59985c39ac8b5..38699420938720b50fa6960eb7caf648ba1457ce 100755 (executable)
@@ -51,7 +51,7 @@ if (!ON_WINDOWS) {
 
 # Determine the numeric GID of $webservergroup
 my $webgroupnum    = 0;
-my $webservergroup = Bugzilla->localconfig->{webservergroup};
+my $webservergroup = Bugzilla->localconfig->webservergroup;
 if ($webservergroup =~ /^(\d+)$/) {
   $webgroupnum = $1;
 }
@@ -66,7 +66,7 @@ if ($sgid > 0) {
 That is a very insecure practice. Please refer to the
 Bugzilla documentation.\n";
   }
-  elsif ($webgroupnum == $sgid || Bugzilla->localconfig->{use_suexec}) {
+  elsif ($webgroupnum == $sgid || Bugzilla->localconfig->use_suexec) {
     print "TEST-OK Webserver is running under group id in \$webservergroup.\n";
   }
   else {