]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1320977 - performance tweaks
authorDylan William Hardison <dylan@hardison.net>
Tue, 31 Jul 2018 17:54:12 +0000 (13:54 -0400)
committerGitHub <noreply@github.com>
Tue, 31 Jul 2018 17:54:12 +0000 (13:54 -0400)
Bugzilla/User/Setting.pm
Bugzilla/WebService/Server/REST.pm
mod_perl.pl
rest.cgi

index a0b079ec7c625e22e5a592914caf3a47af1ce6d3..ac53fbb32fb63d1c9fa939cc7305a7d9f35c3ab7 100644 (file)
@@ -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);
index b8884b7533d673927f8109dfad8cc4db5a25dbb4..13896b248098e5ab17ae2934ad1247e91631d781 100644 (file)
@@ -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.
index aeadd6f3556e99851f894ac7843a5a282d3b81a4..09e3bac3863ff8eee4b80fc94e9e4441f62d334a 100644 (file)
@@ -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;
 
index 2df7e50bb82119bb725194110c2e2d3332b59105..b64a6e6a37a1641ebb96e96aad64c69ac3b05995 100755 (executable)
--- 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;