From: Dylan William Hardison Date: Thu, 13 Jun 2019 14:25:02 +0000 (-0400) Subject: no bug - turn Bugzilla->localconfig into an object to make use of lazy attributes... X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f781a22c9b10db954e87586a2b4f508015a5f7c7;p=thirdparty%2Fbugzilla.git no bug - turn Bugzilla->localconfig into an object to make use of lazy attributes and so on --- diff --git a/Bugzilla.pm b/Bugzilla.pm index 8ab2f48c4..8fcbcb624 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -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 //= ''; diff --git a/Bugzilla/App/Plugin/Glue.pm b/Bugzilla/App/Plugin/Glue.pm index 45c9721c7..2c80507c2 100644 --- a/Bugzilla/App/Plugin/Glue.pm +++ b/Bugzilla/App/Plugin/Glue.pm @@ -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 diff --git a/Bugzilla/App/Plugin/Hostage.pm b/Bugzilla/App/Plugin/Hostage.pm index 62ce7d01d..fdf044e49 100644 --- a/Bugzilla/App/Plugin/Hostage.pm +++ b/Bugzilla/App/Plugin/Hostage.pm @@ -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); diff --git a/Bugzilla/App/Plugin/OAuth2.pm b/Bugzilla/App/Plugin/OAuth2.pm index e49278c8d..ab1fdf1e1 100644 --- a/Bugzilla/App/Plugin/OAuth2.pm +++ b/Bugzilla/App/Plugin/OAuth2.pm @@ -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}) { diff --git a/Bugzilla/App/Plugin/SizeLimit.pm b/Bugzilla/App/Plugin/SizeLimit.pm index 7fdc8cbc4..6ac068f25 100644 --- a/Bugzilla/App/Plugin/SizeLimit.pm +++ b/Bugzilla/App/Plugin/SizeLimit.pm @@ -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) { diff --git a/Bugzilla/Attachment/PatchReader.pm b/Bugzilla/Attachment/PatchReader.pm index 0ae70d3f4..3db2d6d45 100644 --- a/Bugzilla/Attachment/PatchReader.pm +++ b/Bugzilla/Attachment/PatchReader.pm @@ -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'}; diff --git a/Bugzilla/Auth/Login/CGI.pm b/Bugzilla/Auth/Login/CGI.pm index 1b3b1f69e..6c6c493d1 100644 --- a/Bugzilla/Auth/Login/CGI.pm +++ b/Bugzilla/Auth/Login/CGI.pm @@ -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/; } diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm index 28ff871da..6becbc9a6 100644 --- a/Bugzilla/BugMail.pm +++ b/Bugzilla/BugMail.pm @@ -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; diff --git a/Bugzilla/BugUrl/Bugzilla/Local.pm b/Bugzilla/BugUrl/Bugzilla/Local.pm index 9d3dda685..b3606468a 100644 --- a/Bugzilla/BugUrl/Bugzilla/Local.pm +++ b/Bugzilla/BugUrl/Bugzilla/Local.pm @@ -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 { diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index f2404b8b6..e6da5a2a2 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -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; diff --git a/Bugzilla/Config.pm b/Bugzilla/Config.pm index 39c7b228f..60faa2fbc 100644 --- a/Bugzilla/Config.pm +++ b/Bugzilla/Config.pm @@ -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 diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index fe01e9909..45c84ace2 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -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; diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index 543549293..a4bc54a33 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -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); } diff --git a/Bugzilla/DB/Mysql.pm b/Bugzilla/DB/Mysql.pm index 5f0ebbb74..cde571dca 100644 --- a/Bugzilla/DB/Mysql.pm +++ b/Bugzilla/DB/Mysql.pm @@ -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"); diff --git a/Bugzilla/DB/Oracle.pm b/Bugzilla/DB/Oracle.pm index aa53b5343..db8932c9e 100644 --- a/Bugzilla/DB/Oracle.pm +++ b/Bugzilla/DB/Oracle.pm @@ -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( diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm index fe5602637..4fad160f4 100644 --- a/Bugzilla/Install/Filesystem.pm +++ b/Bugzilla/Install/Filesystem.pm @@ -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; diff --git a/Bugzilla/Install/Localconfig.pm b/Bugzilla/Install/Localconfig.pm index aa93709a7..0dcba2f51 100644 --- a/Bugzilla/Install/Localconfig.pm +++ b/Bugzilla/Install/Localconfig.pm @@ -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"; } diff --git a/Bugzilla/Install/Requirements.pm b/Bugzilla/Install/Requirements.pm index 6a82a1bf8..e0176fcb2 100644 --- a/Bugzilla/Install/Requirements.pm +++ b/Bugzilla/Install/Requirements.pm @@ -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 index 000000000..abbbed0c1 --- /dev/null +++ b/Bugzilla/Localconfig.pm @@ -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; diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm index 9a2023a8c..bd02bc1cc 100644 --- a/Bugzilla/Mailer.pm +++ b/Bugzilla/Mailer.pm @@ -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) { diff --git a/Bugzilla/Memcached.pm b/Bugzilla/Memcached.pm index 10a45caee..aa9fbf709 100644 --- a/Bugzilla/Memcached.pm +++ b/Bugzilla/Memcached.pm @@ -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)], diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index 335caedbb..5fb6b07fd 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -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; } } diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 7489bc5a0..4893166c6 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -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; }, diff --git a/Bugzilla/Token.pm b/Bugzilla/Token.pm index 7c9137085..15697c998 100644 --- a/Bugzilla/Token.pm +++ b/Bugzilla/Token.pm @@ -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; diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index ddeda869f..aec096155 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -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); diff --git a/Bugzilla/WebService/Server/JSONRPC.pm b/Bugzilla/WebService/Server/JSONRPC.pm index e763831e5..3d8104f35 100644 --- a/Bugzilla/WebService/Server/JSONRPC.pm +++ b/Bugzilla/WebService/Server/JSONRPC.pm @@ -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, diff --git a/Bugzilla/WebService/Server/REST.pm b/Bugzilla/WebService/Server/REST.pm index f4be30183..b64b4f676 100644 --- a/Bugzilla/WebService/Server/REST.pm +++ b/Bugzilla/WebService/Server/REST.pm @@ -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 }; diff --git a/attachment.cgi b/attachment.cgi index 40e042221..6f1672250 100755 --- a/attachment.cgi +++ b/attachment.cgi @@ -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. diff --git a/editparams.cgi b/editparams.cgi index 881214844..433f6f725 100755 --- a/editparams.cgi +++ b/editparams.cgi @@ -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); diff --git a/extensions/Bitly/lib/WebService.pm b/extensions/Bitly/lib/WebService.pm index b900e17ee..5117cfd4d 100644 --- a/extensions/Bitly/lib/WebService.pm +++ b/extensions/Bitly/lib/WebService.pm @@ -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) { diff --git a/extensions/BugModal/lib/ActivityStream.pm b/extensions/BugModal/lib/ActivityStream.pm index 18e3370cc..a75a41f88 100644 --- a/extensions/BugModal/lib/ActivityStream.pm +++ b/extensions/BugModal/lib/ActivityStream.pm @@ -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})) { diff --git a/extensions/BzAPI/lib/Resources/Bugzilla.pm b/extensions/BzAPI/lib/Resources/Bugzilla.pm index 8d621cb25..b1d58be5c 100644 --- a/extensions/BzAPI/lib/Resources/Bugzilla.pm +++ b/extensions/BzAPI/lib/Resources/Bugzilla.pm @@ -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) }; diff --git a/extensions/BzAPI/lib/Util.pm b/extensions/BzAPI/lib/Util.pm index 6f7e2c025..2a37ab073 100644 --- a/extensions/BzAPI/lib/Util.pm +++ b/extensions/BzAPI/lib/Util.pm @@ -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 diff --git a/extensions/GitHubAuth/lib/Client.pm b/extensions/GitHubAuth/lib/Client.pm index 328bab48f..772f1dd22 100644 --- a/extensions/GitHubAuth/lib/Client.pm +++ b/extensions/GitHubAuth/lib/Client.pm @@ -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; } diff --git a/extensions/GitHubAuth/lib/Login.pm b/extensions/GitHubAuth/lib/Login.pm index c0165c5ac..15d0cdd4b 100644 --- a/extensions/GitHubAuth/lib/Login.pm +++ b/extensions/GitHubAuth/lib/Login.pm @@ -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; }; diff --git a/extensions/InlineHistory/Extension.pm b/extensions/InlineHistory/Extension.pm index 7ccaf31e6..779ccaf17 100644 --- a/extensions/InlineHistory/Extension.pm +++ b/extensions/InlineHistory/Extension.pm @@ -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})) { diff --git a/extensions/Push/lib/Config.pm b/extensions/Push/lib/Config.pm index bb0d523ad..f9f8fcb46 100644 --- a/extensions/Push/lib/Config.pm +++ b/extensions/Push/lib/Config.pm @@ -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}; diff --git a/extensions/Push/lib/Connector.disabled/AMQP.pm b/extensions/Push/lib/Connector.disabled/AMQP.pm index dda73dade..68f2aabcb 100644 --- a/extensions/Push/lib/Connector.disabled/AMQP.pm +++ b/extensions/Push/lib/Connector.disabled/AMQP.pm @@ -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); diff --git a/extensions/Push/lib/Connector.disabled/ServiceNow.pm b/extensions/Push/lib/Connector.disabled/ServiceNow.pm index 8856f481b..015a022c7 100644 --- a/extensions/Push/lib/Connector.disabled/ServiceNow.pm +++ b/extensions/Push/lib/Connector.disabled/ServiceNow.pm @@ -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 diff --git a/extensions/Push/lib/Connector/Spark.pm b/extensions/Push/lib/Connector/Spark.pm index 1eb6f22c6..4988fcadf 100644 --- a/extensions/Push/lib/Connector/Spark.pm +++ b/extensions/Push/lib/Connector/Spark.pm @@ -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'); diff --git a/extensions/SecureMail/Extension.pm b/extensions/SecureMail/Extension.pm index 719bff0f5..b8a22f13c 100644 --- a/extensions/SecureMail/Extension.pm +++ b/extensions/SecureMail/Extension.pm @@ -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 }; diff --git a/extensions/SiteMapIndex/Extension.pm b/extensions/SiteMapIndex/Extension.pm index c606702ae..f02a91124 100644 --- a/extensions/SiteMapIndex/Extension.pm +++ b/extensions/SiteMapIndex/Extension.pm @@ -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; diff --git a/extensions/SiteMapIndex/lib/Util.pm b/extensions/SiteMapIndex/lib/Util.pm index fb945e324..3f868cc5b 100644 --- a/extensions/SiteMapIndex/lib/Util.pm +++ b/extensions/SiteMapIndex/lib/Util.pm @@ -149,7 +149,7 @@ END $index_xml .= " " - . Bugzilla->localconfig->{urlbase} . "data/$extension_name/$filename + . Bugzilla->localconfig->urlbase . "data/$extension_name/$filename $timestamp "; @@ -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 = < diff --git a/github.cgi b/github.cgi index 2d53f9b9e..e93ae09ad 100755 --- a/github.cgi +++ b/github.cgi @@ -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') { diff --git a/index.cgi b/index.cgi index 888f6fc1e..92e947da3 100755 --- 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; diff --git a/reports.cgi b/reports.cgi index 1589189ac..b45c36849 100755 --- a/reports.cgi +++ b/reports.cgi @@ -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; diff --git a/scripts/addcustomfield.pl b/scripts/addcustomfield.pl index f64172848..00e464856 100755 --- a/scripts/addcustomfield.pl +++ b/scripts/addcustomfield.pl @@ -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"; diff --git a/scripts/convert_datetime.pl b/scripts/convert_datetime.pl index 8cda77096..314c55871 100755 --- a/scripts/convert_datetime.pl +++ b/scripts/convert_datetime.pl @@ -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; diff --git a/scripts/remove-non-public-data.pl b/scripts/remove-non-public-data.pl index 4b9d9cc86..3961b07cd 100755 --- a/scripts/remove-non-public-data.pl +++ b/scripts/remove-non-public-data.pl @@ -179,7 +179,7 @@ my %whitelist = ( # -my $db_name = Bugzilla->localconfig->{db_name}; +my $db_name = Bugzilla->localconfig->db_name; print < 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; diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi index be0699412..f501b214e 100755 --- a/showdependencygraph.cgi +++ b/showdependencygraph.cgi @@ -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"; diff --git a/t/bmo/comments.t b/t/bmo/comments.t index 992e17fbc..08badc3f8 100644 --- a/t/bmo/comments.t +++ b/t/bmo/comments.t @@ -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', diff --git a/t/hash-sig.t b/t/hash-sig.t index 9579b0c39..0c08c1854 100644 --- a/t/hash-sig.t +++ b/t/hash-sig.t @@ -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"); diff --git a/t/mojo-oauth2.t b/t/mojo-oauth2.t index d91fe458b..cff18b588 100644 --- a/t/mojo-oauth2.t +++ b/t/mojo-oauth2.t @@ -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 diff --git a/testserver.pl b/testserver.pl index 05255adcf..386994209 100755 --- a/testserver.pl +++ b/testserver.pl @@ -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 {