From b18915bb95c8b1fd9cf8ecef73f45cd47f71fc09 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 15 Mar 2018 22:30:48 -0400 Subject: add Bugzilla->urlbase method that returns a URI object --- Bugzilla.pm | 8 ++++++++ Bugzilla/CGI.pm | 2 +- Bugzilla/Template.pm | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Bugzilla.pm b/Bugzilla.pm index 3e969a99d..1ab72431a 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -59,6 +59,7 @@ use Safe; use Sys::Syslog qw(:DEFAULT); use List::Util qw(any); use JSON::XS qw(decode_json); +use URI; use parent qw(Bugzilla::CPAN); @@ -272,6 +273,13 @@ sub localconfig { return $_[0]->process_cache->{localconfig} ||= 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 $_[0]->request_cache->{params} ||= Bugzilla::Config::read_param_file(); } diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 05e2bd749..ba82c83d0 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -664,7 +664,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. $paramhash{'-secure'} = 1 diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 0d2a4cd86..31c68bbed 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -925,7 +925,7 @@ sub create { 'sudoer' => sub { return Bugzilla->sudoer; }, # Allow templates to access the "corect" URLBase value - 'urlbase' => sub { return Bugzilla->localconfig->{urlbase}; }, + 'urlbase' => sub { Bugzilla->urlbase }, # Allow templates to access docs url with users' preferred language 'docs_urlbase' => sub { -- cgit v1.2.3-24-g4f1b