]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1405011 - Prevent code in mod_perl.pl from executing twice
authorDylan William Hardison <dylan@hardison.net>
Fri, 6 Oct 2017 16:27:48 +0000 (12:27 -0400)
committerGitHub <noreply@github.com>
Fri, 6 Oct 2017 16:27:48 +0000 (12:27 -0400)
Bugzilla/ModPerl/StartupFix.pm [new file with mode: 0644]
mod_perl.pl

diff --git a/Bugzilla/ModPerl/StartupFix.pm b/Bugzilla/ModPerl/StartupFix.pm
new file mode 100644 (file)
index 0000000..e6e0e5f
--- /dev/null
@@ -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
index 03438dd4d5b2cfb61c10e16a1ff75920614ccea5..42b74fde5ece5d05872469bd2c77642bdefcd01d 100644 (file)
@@ -22,6 +22,8 @@ BEGIN {
     lib->import($dir, File::Spec->catdir($dir, "lib"), File::Spec->catdir($dir, qw(local lib perl5)));
 }
 
+use Bugzilla::ModPerl::StartupFix;
+
 use Bugzilla::Constants ();
 
 # If you have an Apache2::Status handler in your Apache configuration,