summaryrefslogtreecommitdiffstats
path: root/Bugzilla/ModPerl
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-10-06 18:27:48 +0200
committerGitHub <noreply@github.com>2017-10-06 18:27:48 +0200
commit350f370d64df2effbf8ef147d5fc744a3b01601f (patch)
treec5dc8fd764f7c62e955d55cc573e8668795f47fc /Bugzilla/ModPerl
parent5261604e9397dbecc367d990c0acf0171bd277d7 (diff)
downloadbugzilla-350f370d64df2effbf8ef147d5fc744a3b01601f.tar.gz
bugzilla-350f370d64df2effbf8ef147d5fc744a3b01601f.tar.xz
Bug 1405011 - Prevent code in mod_perl.pl from executing twice
Diffstat (limited to 'Bugzilla/ModPerl')
-rw-r--r--Bugzilla/ModPerl/StartupFix.pm43
1 files changed, 43 insertions, 0 deletions
diff --git a/Bugzilla/ModPerl/StartupFix.pm b/Bugzilla/ModPerl/StartupFix.pm
new file mode 100644
index 000000000..e6e0e5f43
--- /dev/null
+++ b/Bugzilla/ModPerl/StartupFix.pm
@@ -0,0 +1,43 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+package Bugzilla::ModPerl::StartupFix;
+use 5.10.1;
+use strict;
+use warnings;
+
+use Filter::Util::Call;
+use Apache2::ServerUtil ();
+
+my $FIRST_STARTUP = <<'CODE';
+warn "Bugzilla::ModPerl::StartupFix: Skipping first startup using source filter\n";
+1;
+CODE
+
+sub import {
+ my ($type) = @_;
+ my ($ref) = {};
+ filter_add( bless $ref );
+}
+
+sub filter {
+ my ($self) = @_;
+ my ($status);
+ if ($status = filter_read() > 0) {
+ if (Apache2::ServerUtil::restart_count() < 2) {
+ if (!$self->{did_it}) {
+ $self->{did_it} = 1;
+ $_ = $FIRST_STARTUP;
+ }
+ else {
+ $_ = "";
+ }
+ }
+ }
+ return $status;
+}
+
+1; \ No newline at end of file