]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
no bug - Move initialisation to a before_dispatch hook (#1419)
authordklawren <dklawren@users.noreply.github.com>
Wed, 21 Aug 2019 16:24:00 +0000 (12:24 -0400)
committerGitHub <noreply@github.com>
Wed, 21 Aug 2019 16:24:00 +0000 (12:24 -0400)
Bugzilla.pm
Bugzilla/App.pm
Bugzilla/App/CGI.pm

index 088f031f99b66ffe4411388861d40c7dcb503054..1d3702258e644aa790d639eaa8bd01fb55dea8d8 100644 (file)
@@ -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();
   }
index 6fa6fb3e1f6a774f3a112e0ed5d26f1ef0895767..5990a6854005774a6d432952db71bbe8dd572e7b 100644 (file)
@@ -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);
index a3b82ff9f7de6300fd8198a0127f167fbc61ab3a..29b2842162351a348fc0dd7bf7ac2ef3b19b954a 100644 (file)
@@ -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->();
     }