From 11287e0ad19d69175026b507ac8796988cfd0ab9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 10 Feb 2015 11:34:10 +0100 Subject: [PATCH] Bug 13690: use Koha::Schema only when it's needed This patch makes Koha::Database lazy-load the whole Koha::Schema libraries. It doesn't seem to have negative effects, and makes scripts not using DBIx::Class notably faster [1]. Regards [1] If you read the DBIx::Class::Schema docs, it explains that it it uses Module::Find to load all schema files... http://search.cpan.org/~ribasushi/DBIx-Class-0.082810/lib/DBIx/Class/Schema.pm#load_namespaces Signed-off-by: Tomas Cohen Arazi Happy to sign this one. The only extra comment would be that DBIx::Class performance issues remain after this patch, but is being handled in a different bug. Signed-off-by: Kyle M Hall (cherry picked from commit c52bc9756a5fa1e4f6bba7ce5c58124f150c5efc) Signed-off-by: Chris Cormack --- Koha/Database.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/Database.pm b/Koha/Database.pm index 92e83ec8fa..ee2cc91117 100644 --- a/Koha/Database.pm +++ b/Koha/Database.pm @@ -35,7 +35,6 @@ Koha::Database use Modern::Perl; use Carp; use C4::Context; -use Koha::Schema; use base qw(Class::Accessor); __PACKAGE__->mk_accessors(qw( )); @@ -46,6 +45,7 @@ __PACKAGE__->mk_accessors(qw( )); # returns it. sub _new_schema { + require Koha::Schema; my $context = C4::Context->new(); # we are letting C4::Context->dbh not set the RaiseError handle attribute -- 2.39.5