summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-07-31 19:54:12 +0200
committerGitHub <noreply@github.com>2018-07-31 19:54:12 +0200
commite1b3729da40453f33a836eb75c8990cb4a42a634 (patch)
treec052bbfee879693e1fb879976863d84d2ff9c88a
parentd133f849672bdd7ad1b22e2ffc327fc65c2b95e8 (diff)
downloadbugzilla-e1b3729da40453f33a836eb75c8990cb4a42a634.tar.gz
bugzilla-e1b3729da40453f33a836eb75c8990cb4a42a634.tar.xz
Bug 1320977 - performance tweaks
-rw-r--r--Bugzilla/User/Setting.pm8
-rw-r--r--Bugzilla/WebService/Server/REST.pm8
-rw-r--r--mod_perl.pl7
-rwxr-xr-xrest.cgi1
4 files changed, 17 insertions, 7 deletions
diff --git a/Bugzilla/User/Setting.pm b/Bugzilla/User/Setting.pm
index a0b079ec7..ac53fbb32 100644
--- a/Bugzilla/User/Setting.pm
+++ b/Bugzilla/User/Setting.pm
@@ -13,8 +13,6 @@ use strict;
use warnings;
use base qw(Exporter);
-
-
# Module stuff
@Bugzilla::User::Setting::EXPORT = qw(
get_all_settings
@@ -25,6 +23,7 @@ use base qw(Exporter);
use Bugzilla::Error;
use Bugzilla::Util qw(trick_taint get_text);
+use Module::Runtime qw(require_module);
###############################
### Module Initialization ###
@@ -104,9 +103,8 @@ sub new {
$self->{'category'} = shift;
}
if ($subclass) {
- eval('require ' . $class . '::' . $subclass);
- $@ && ThrowCodeError('setting_subclass_invalid',
- {'subclass' => $subclass});
+ eval { require_module( $class . '::' . $subclass ) }
+ || ThrowCodeError( 'setting_subclass_invalid', { 'subclass' => $subclass } );
$class = $class . '::' . $subclass;
}
bless($self, $class);
diff --git a/Bugzilla/WebService/Server/REST.pm b/Bugzilla/WebService/Server/REST.pm
index b8884b753..13896b248 100644
--- a/Bugzilla/WebService/Server/REST.pm
+++ b/Bugzilla/WebService/Server/REST.pm
@@ -34,6 +34,7 @@ use Bugzilla::WebService::Server::REST::Resources::Elastic;
use List::MoreUtils qw(uniq);
use Scalar::Util qw(blessed reftype);
use MIME::Base64 qw(decode_base64);
+use Module::Runtime qw(require_module);
###########################
# Public Method Overrides #
@@ -392,6 +393,10 @@ sub _retrieve_json_params {
return $params;
}
+sub preload {
+ require_module($_) for values %{ WS_DISPATCH() };
+}
+
sub _find_resource {
my ($self, $path) = @_;
@@ -399,13 +404,12 @@ sub _find_resource {
# $module->rest_resources to get the resources array ref.
my $resources = {};
foreach my $module (values %{ $self->{dispatch_path} }) {
- eval("require $module") || die $@;
next if !$module->can('rest_resources');
$resources->{$module} = $module->rest_resources;
}
Bugzilla::Hook::process('webservice_rest_resources',
- { rpc => $self, resources => $resources });
+ { rpc => $self, resources => $resources }) if Bugzilla::request_cache->{bzapi};
# Use the resources hash from each module loaded earlier to determine
# which handler to use based on a regex match of the CGI path.
diff --git a/mod_perl.pl b/mod_perl.pl
index aeadd6f35..09e3bac38 100644
--- a/mod_perl.pl
+++ b/mod_perl.pl
@@ -67,6 +67,9 @@ use Bugzilla::Install::Requirements ();
use Bugzilla::Util ();
use Bugzilla::RNG ();
use Bugzilla::ModPerl ();
+use Mojo::Loader qw(find_modules);
+use Module::Runtime qw(require_module);
+use Bugzilla::WebService::Server::REST;
# Make warnings go to the virtual host's log and not the main
# server log.
@@ -103,6 +106,10 @@ Bugzilla::Extension->load_all();
Bugzilla->preload_features();
+require_module($_) for find_modules('Bugzilla::User::Setting');
+
+Bugzilla::WebService::Server::REST->preload;
+
# Force instantiation of template so Bugzilla::Template::PreloadProvider can do its magic.
Bugzilla->preload_templates;
diff --git a/rest.cgi b/rest.cgi
index 2df7e50bb..b64a6e6a3 100755
--- a/rest.cgi
+++ b/rest.cgi
@@ -24,6 +24,7 @@ BEGIN {
}
}
use Bugzilla::WebService::Server::REST;
+
Bugzilla->usage_mode(USAGE_MODE_REST);
local @INC = (bz_locations()->{extensionsdir}, @INC);
my $server = new Bugzilla::WebService::Server::REST;