Bugzilla – Attachment 116471 Details for
Bug 27154
Koha/Util/SystemPreferences.pm must be removed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27154: Remove Koha::Util::SystemPreferences
Bug-27154-Remove-KohaUtilSystemPreferences.patch (text/plain), 4.47 KB, created by
Katrin Fischer
on 2021-02-07 12:35:48 UTC
(
hide
)
Description:
Bug 27154: Remove Koha::Util::SystemPreferences
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2021-02-07 12:35:48 UTC
Size:
4.47 KB
patch
obsolete
>From c27819ae52f19b2c31c90222e87d3e3daa3cf8ef Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 5 Feb 2021 12:01:38 +0100 >Subject: [PATCH] Bug 27154: Remove Koha::Util::SystemPreferences > >On bug 15494, the same method "get_yaml_pref_hash" has been added to two modules, >Koha/Config/SysPref.pm and Koha/Util/SystemPreferences.pm > >We only need the one from Koha::Config::SysPref and remove the whole >Koha::Util::SystemPreferences module. > >Test plan: > prove t/db_dependent/Circulation/issue.t >must return green > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > C4/Circulation.pm | 4 +-- > Koha/Config/SysPref.pm | 4 ++- > Koha/Util/SystemPreferences.pm | 69 ------------------------------------------ > 3 files changed, 5 insertions(+), 72 deletions(-) > delete mode 100644 Koha/Util/SystemPreferences.pm > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 1f13cef93d..7f37b37af9 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -56,7 +56,7 @@ use Koha::Account::Lines; > use Koha::Account::Offsets; > use Koha::Config::SysPrefs; > use Koha::Charges::Fees; >-use Koha::Util::SystemPreferences; >+use Koha::Config::SysPref; > use Koha::Checkouts::ReturnClaims; > use Koha::SearchEngine::Indexer; > use Carp; >@@ -1986,7 +1986,7 @@ sub AddReturn { > my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not > my $patron_unblessed = $patron ? $patron->unblessed : {}; > >- my $update_loc_rules = get_yaml_pref_hash('UpdateItemLocationOnCheckin'); >+ my $update_loc_rules = Koha::Config::SysPrefs->find('UpdateItemLocationOnCheckin')->get_yaml_pref_hash(); > map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays > if ($update_loc_rules) { > if (defined $update_loc_rules->{_ALL_}) { >diff --git a/Koha/Config/SysPref.pm b/Koha/Config/SysPref.pm >index 0793cb4547..1775160cb5 100644 >--- a/Koha/Config/SysPref.pm >+++ b/Koha/Config/SysPref.pm >@@ -47,7 +47,9 @@ sub get_yaml_pref_hash { > my ( $self ) = @_; > return if !defined( $self ); > >- my @lines = split /\n/, $self->value//''; >+ # We want to use C4::Context->preference in any cases >+ # It's cached, and mock_preference still works from tests >+ my @lines = split /\n/, C4::Context->preference($self->variable) // ''; > my $pref_as_hash; > foreach my $line (@lines){ > my ($field,$array) = split /:/, $line; >diff --git a/Koha/Util/SystemPreferences.pm b/Koha/Util/SystemPreferences.pm >deleted file mode 100644 >index cb054cf9ff..0000000000 >--- a/Koha/Util/SystemPreferences.pm >+++ /dev/null >@@ -1,69 +0,0 @@ >-package Koha::Util::SystemPreferences; >- >-# Copyright 2018 Koha Development Team >-# >-# This file is part of Koha. >-# >-# Koha is free software; you can redistribute it and/or modify it >-# under the terms of the GNU General Public License as published by >-# the Free Software Foundation; either version 3 of the License, or >-# (at your option) any later version. >-# >-# Koha is distributed in the hope that it will be useful, but >-# WITHOUT ANY WARRANTY; without even the implied warranty of >-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >-# GNU General Public License for more details. >-# >-# You should have received a copy of the GNU General Public License >-# along with Koha; if not, see <http://www.gnu.org/licenses>. >- >-use Modern::Perl; >- >-use parent qw( Exporter ); >- >-our @EXPORT = qw( >- get_yaml_pref_hash >-); >- >-=head1 NAME >- >-Koha::Util::SystemPreferences - utility class with System Preference routines >- >-=head1 METHODS >- >-=head2 get_yaml_pref_hash >- >-Turn a pref defined via YAML as a hash >- >-=cut >- >-sub get_yaml_pref_hash { >- my ( $pref ) = @_; >- return if !defined( $pref ); >- >- my @lines = split /\n/, C4::Context->preference($pref)//''; >- my $pref_as_hash; >- foreach my $line (@lines){ >- my ($field,$array) = split /:/, $line; >- next if !$array; >- $field =~ s/^\s*|\s*$//g; >- $array =~ s/[ [\]\r]//g; >- my @array = split /,/, $array; >- @array = map { $_ eq '""' || $_ eq "''" ? '' : $_ } @array; >- @array = map { $_ eq 'NULL' ? undef : $_ } @array; >- $pref_as_hash->{$field} = \@array; >- } >- >- return $pref_as_hash; >-} >- >-1; >-__END__ >- >-=head1 AUTHOR >- >-Koha Development Team <http://koha-community.org/> >- >-Nick Clemens <nick@bywatersolutions.com> >- >-=cut >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27154
:
116385
|
116386
| 116471 |
116539