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 <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
d95fffb8ec
commit
673aaaaba2
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue