From 3154c482b5b1adb5c9229106d2130bc87439e627 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Thu, 20 Dec 2012 11:33:44 +0800 Subject: Bug 822547: jobqueue.pl should clear the request cache before sending each mail --- Bugzilla.pm | 14 +++++++++++++- Bugzilla/JobQueue.pm | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Bugzilla.pm b/Bugzilla.pm index 70a3ade54..efef052be 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -627,6 +627,18 @@ sub request_cache { return $_request_cache; } +sub clear_request_cache { + $_request_cache = {}; + if ($ENV{MOD_PERL}) { + require Apache2::RequestUtil; + my $request = eval { Apache2::RequestUtil->request }; + if ($request) { + my $pnotes = $request->pnotes; + delete @$pnotes{(keys %$pnotes)}; + } + } +} + # This is a per-process cache. Under mod_cgi it's identical to the # request_cache. When using mod_perl, items in this cache live until the # worker process is terminated. @@ -648,7 +660,7 @@ sub _cleanup { $dbh->bz_rollback_transaction() if $dbh->bz_in_transaction; $dbh->disconnect; } - undef $_request_cache; + clear_request_cache(); # These are both set by CGI.pm but need to be undone so that # Apache can actually shut down its children if it needs to. diff --git a/Bugzilla/JobQueue.pm b/Bugzilla/JobQueue.pm index 7ea678345..e719efa04 100644 --- a/Bugzilla/JobQueue.pm +++ b/Bugzilla/JobQueue.pm @@ -99,6 +99,13 @@ sub insert { return $retval; } +# Clear the request cache at the start of each run. +sub work_once { + my $self = shift; + Bugzilla->clear_request_cache(); + return $self->SUPER::work_once(@_); +} + 1; __END__ -- cgit v1.2.3-24-g4f1b