By moving BlockIP plugin first, it is ensured to execute first.
This is a slight speed gain. The primary speed gain is by caching
the content of the template.
Before: 429 Too Many Requests (0.031951s, 31.298/s)
After: 429 Too Many Requests (0.000182s, 5494.505/s)
command: |
[[ -f build_info/only_version_changed.txt ]] && exit 0
mv /opt/bmo/local /app/local
+ for file in patches/*.patch; do
+ patch -p0 < $file
+ done
perl -MSys::Hostname -i -pE 's/bmo.test/hostname() . ":$ENV{PORT}"/ges' $BZ_QA_CONF_FILE
perl checksetup.pl --no-database --default-localconfig
mkdir artifacts
my ($self) = @_;
DEBUG('Starting up');
+ $self->plugin('Bugzilla::Quantum::Plugin::BlockIP');
$self->plugin('Bugzilla::Quantum::Plugin::Glue');
$self->plugin('Bugzilla::Quantum::Plugin::Hostage')
unless $ENV{BUGZILLA_DISABLE_HOSTAGE};
$self->plugin('Bugzilla::Quantum::Plugin::SizeLimit')
unless $ENV{BUGZILLA_DISABLE_SIZELIMIT};
$self->plugin('ForwardedFor') if Bugzilla->has_feature('better_xff');
- $self->plugin('Bugzilla::Quantum::Plugin::BlockIP');
$self->plugin('Bugzilla::Quantum::Plugin::Helpers');
# hypnotoad is weird and doesn't look for MOJO_LISTEN itself.
$c->stash->{cleanup_guard}->dismiss;
Bugzilla->usage_mode(USAGE_MODE_BROWSER);
try {
+ CGI::initialize_globals();
Bugzilla->init_page();
$inner->();
}
untie *STDOUT;
$c->finish if !$error || _is_exit($error);
Bugzilla->cleanup;
- CGI::initialize_globals();
};
};
use constant BLOCK_TIMEOUT => 60 * 60;
-my $MEMCACHED = Bugzilla::Memcached->new()->{memcached};
+my $MEMCACHED = Bugzilla::Memcached->new()->{memcached};
+my $BLOCKED_HTML = "";
sub register {
my ($self, $app, $conf) = @_;
$app->hook(before_routes => \&_before_routes);
$app->helper(block_ip => \&_block_ip);
$app->helper(unblock_ip => \&_unblock_ip);
+
+ my $template = Bugzilla::Template->create();
+ $template->process('global/ip-blocked.html.tmpl',
+ {block_timeout => BLOCK_TIMEOUT},
+ \$BLOCKED_HTML);
+ undef $template;
+ utf8::encode($BLOCKED_HTML);
}
sub _block_ip {
$c->block_ip($ip);
$c->res->code(429);
$c->res->message('Too Many Requests');
- $c->render(handler => 'bugzilla', template => 'global/ip-blocked', block_timeout => BLOCK_TIMEOUT);
+ $c->write($BLOCKED_HTML);
+ $c->finish;
}
}
use constant FORMAT_DOUBLE => '%19s %-55s';
use constant FORMAT_2_SIZE => [19,55];
-my %SHARED_PROVIDERS;
+our %SHARED_PROVIDERS;
# Pseudo-constant.
sub SAFE_URL_REGEXP {