From 02f8ac0819e598628b9cfd7c71b6f3a00f8a23b9 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 20 Aug 2024 04:13:38 +0000 Subject: [PATCH] Bug 37657: Make koha-preferences CLI tool faster By using Koha::Database->dbh() to use a minimal database handle which doesn't preload the whole DBIx::Class schema, we're able to run the same command 2-3 times faster. This is beneficial when running the tool in a loop which runs the command serially one by one. Test plan: 1. time misc/admin/koha-preferences get SearchEngine 2. Note time is about 1 second 3. time misc/admin/koha-preferences dump 4. Note time is about 1 second 5. Create sysprefs.yml Signed-off-by: Martin Renvoize --- misc/admin/koha-preferences | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/misc/admin/koha-preferences b/misc/admin/koha-preferences index 5c07c2b8a79..11cbc42dc73 100755 --- a/misc/admin/koha-preferences +++ b/misc/admin/koha-preferences @@ -28,6 +28,8 @@ use YAML::XS; use Koha::Logger; +use Koha::Database; + our %NOT_SET_PREFS = map { $_, 1 } qw( Version ); =head1 NAME @@ -68,7 +70,7 @@ sub _set_preference { } sub GetPreferences { - my $dbh = C4::Context->dbh; + my $dbh = Koha::Database->dbh; return { map { $_->{variable}, $_->{value} } @@ -83,7 +85,7 @@ sub GetPreferences { sub SetPreferences { my ( %preferences ) = @_; - my $dbh = C4::Context->dbh; + my $dbh = Koha::Database->dbh; # First, a quick check to make sure all of the system preferences exist my $current_state = $dbh->selectall_arrayref( " @@ -109,7 +111,7 @@ sub SetPreferences { sub _fetch_preference { my ( $preference ) = @_; - my $dbh = C4::Context->dbh; + my $dbh = Koha::Database->dbh; my $row = $dbh->selectrow_hashref( " SELECT -- 2.46.0