From 45609d22aa474ceca3f674728e9519523912f28c Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Tue, 1 Mar 2016 13:44:22 -0700 Subject: [PATCH] Bug 15350: Move the import of Koha::Schema to a basic `use` This moves the import of Koha::Schema from an on-demand `require` to just a `use`; most everything in Koha uses C4::Context, which will indirectly end up calling Koha::Database->schema->new anyway, so this was no longer saving anything. Note that this saves time only when a Plack-based Koha needs to create a database connection, which is usually only the case for a new worker. Unscientific timings before patch: * First load of koha2marclinks.pl on a new worker: 0.70 seconds * Each load after: 0.17 seconds After patch: * First load: 0.31 seconds * Each load after: 0.17 seconds --- Koha/Database.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Koha/Database.pm b/Koha/Database.pm index a8f4eab..6d64506 100644 --- a/Koha/Database.pm +++ b/Koha/Database.pm @@ -35,6 +35,7 @@ Koha::Database use Modern::Perl; use Carp; use C4::Context; +use Koha::Schema; use base qw(Class::Accessor); use vars qw($database); @@ -46,9 +47,6 @@ __PACKAGE__->mk_accessors(qw( )); # database connection from the data given in the current context, and # returns it. sub _new_schema { - - require Koha::Schema; - my $context = C4::Context->new(); my $db_driver = $context->{db_driver}; -- 2.7.0