From 269a23100c29c9d09e4af5fb375655ffcce8aa08 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 15 Mar 2018 22:30:48 -0400 Subject: [PATCH] add Bugzilla->urlbase method that returns a URI object --- Bugzilla.pm | 7 +++++++ Bugzilla/CGI.pm | 2 +- Bugzilla/Template.pm | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Bugzilla.pm b/Bugzilla.pm index 42b56ec03f..c88e842ef3 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -46,6 +46,7 @@ use File::Spec::Functions; use Safe; use JSON::XS qw(decode_json); use Scope::Guard; +use URI; use parent qw(Bugzilla::CPAN); @@ -162,6 +163,12 @@ sub localconfig { ||= Bugzilla::Localconfig->new(read_localconfig()); } +sub urlbase { + my ($class) = @_; + + # Since this could be modified, we have to return a new one every time. + return URI->new($class->localconfig->{urlbase}); +} sub params { return request_cache->{params} ||= Bugzilla::Config::read_param_file(); diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index f3f69b8b88..d3979e4683 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -520,7 +520,7 @@ sub send_cookie { } # Add the default path and the domain in. - state $uri = URI->new(Bugzilla->localconfig->urlbase); + state $uri = Bugzilla->urlbase; $paramhash{'-path'} = $uri->path; # we don't set the domain. diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 59de9eac40..e970b789ac 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -985,7 +985,7 @@ sub create { 'sudoer' => sub { return Bugzilla->sudoer; }, # Allow templates to access the "correct" URLBase value - 'urlbase' => sub { return Bugzilla->localconfig->urlbase; }, + 'urlbase' => sub { Bugzilla->urlbase }, # Allow templates to get the absolute path of the URLBase value 'basepath' => sub { return Bugzilla->localconfig->basepath; },