From f504fbfcbc4ffedb9d05f1326d53618675e93b4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Fri, 29 Jun 2018 11:09:41 +0300 Subject: [PATCH] Bug 21015: fix performance issue with C4::Members loading Koha::Schema ("use Koha::Schema;") takes significantly time as it loads almost a couple hundred classes. Koha::Database has done that already once and we can use it to get the ResultSet "Borrower" as well, so let's use that. This also make the code more unified because Koha::Database is used throughout the code instead of Koha::Schema. Signed-off-by: Jonathan Druart Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens (cherry picked from commit 83e0765f448c35c6f387d41fe39feb94b9bc64f3) Signed-off-by: Martin Renvoize (cherry picked from commit f130fd6ec9538fff02582b6dae40e0445f607320) Signed-off-by: Fridolin Somers --- C4/Members.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 62bd8170b2..31a35b419e 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -44,7 +44,6 @@ use Koha::Holds; use Koha::List::Patron; use Koha::Patrons; use Koha::Patron::Categories; -use Koha::Schema; our (@ISA,@EXPORT,@EXPORT_OK,$debug); @@ -899,7 +898,7 @@ database column. =cut sub get_cardnumber_length { - my $borrower = Koha::Schema->resultset('Borrower'); + my $borrower = Koha::Database->new->schema->resultset('Borrower'); my $field_size = $borrower->result_source->column_info('cardnumber')->{size}; my ( $min, $max ) = ( 0, $field_size ); # borrowers.cardnumber is a nullable varchar(20) $min = 1 if C4::Context->preference('BorrowerMandatoryField') =~ /cardnumber/; -- 2.39.5