From 1ff62d619e30102af54f8d2e63fbd5af6f4a865c Mon Sep 17 00:00:00 2001 From: dklawren Date: Wed, 21 Aug 2019 12:24:00 -0400 Subject: [PATCH] no bug - Move initialisation to a before_dispatch hook (#1419) --- Bugzilla.pm | 7 ++----- Bugzilla/App.pm | 10 ++++++++++ Bugzilla/App/CGI.pm | 1 - 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Bugzilla.pm b/Bugzilla.pm index 088f031f9..1d3702258 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -63,12 +63,9 @@ use constant request_cache => Bugzilla::Install::Util::_cache(); ##################################################################### # Note that this is a raw subroutine, not a method, so $class isn't available. +# Called prior to every Bugzilla CGI request (not called for native Mojo +# routes). sub init_page { - - # This is probably not needed, but bugs resulting from a dirty - # request cache are very annoying (see bug 1347335) - # and this is not an expensive operation. - clear_request_cache(); if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) { init_console(); } diff --git a/Bugzilla/App.pm b/Bugzilla/App.pm index 6fa6fb3e1..5990a6854 100644 --- a/Bugzilla/App.pm +++ b/Bugzilla/App.pm @@ -129,6 +129,16 @@ sub startup { } ); } + $self->hook( + before_dispatch => sub { + # Ensure the request_cache is always cleared prior to every request, + # regardless of routing or Bugzilla::App wrapping. + # This is not an expensive operation. + Bugzilla->clear_request_cache(); + # We also need to clear CGI's globals. + CGI::initialize_globals(); + } + ); $self->hook(after_dispatch => sub { my ($c) = @_; my ($req, $res) = ($c->req, $c->res); diff --git a/Bugzilla/App/CGI.pm b/Bugzilla/App/CGI.pm index a3b82ff9f..29b284216 100644 --- a/Bugzilla/App/CGI.pm +++ b/Bugzilla/App/CGI.pm @@ -76,7 +76,6 @@ sub load_one { $c->stash->{cleanup_guard}->dismiss; Bugzilla->usage_mode(USAGE_MODE_BROWSER); try { - CGI::initialize_globals(); Bugzilla->init_page(); $inner->(); } -- 2.47.3