Bugzilla – Attachment 156399 Details for
Bug 29145
Allow patrons to have overdue items that would not result in debarment when removing overdue debarments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29145: (QA follow-up) Use objects instead of straight SQL queries
Bug-29145-QA-follow-up-Use-objects-instead-of-stra.patch (text/plain), 5.90 KB, created by
Katrin Fischer
on 2023-09-29 14:07:55 UTC
(
hide
)
Description:
Bug 29145: (QA follow-up) Use objects instead of straight SQL queries
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2023-09-29 14:07:55 UTC
Size:
5.90 KB
patch
obsolete
>From 63e668e8301450d4af0a879996284e49d00807cc Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 27 Jan 2023 14:36:40 +0000 >Subject: [PATCH] Bug 29145: (QA follow-up) Use objects instead of straight SQL > queries > >--- > Koha/OverdueRule.pm | 40 +++++++++++++++++++++++++ > Koha/OverdueRules.pm | 50 +++++++++++++++++++++++++++++++ > Koha/Patron.pm | 38 ++++++++++++----------- > Koha/Schema/Result/Overduerule.pm | 7 ++++- > 4 files changed, 116 insertions(+), 19 deletions(-) > create mode 100644 Koha/OverdueRule.pm > create mode 100644 Koha/OverdueRules.pm > >diff --git a/Koha/OverdueRule.pm b/Koha/OverdueRule.pm >new file mode 100644 >index 0000000000..16152a5098 >--- /dev/null >+++ b/Koha/OverdueRule.pm >@@ -0,0 +1,40 @@ >+package Koha::OverdueRule; >+ >+# Copyright ByWater Solutions 2023 >+# >+# 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 base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::OverdueRule - Koha Overdue rule object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=head3 _type >+ >+=cut >+ >+sub _type { >+ return 'Overduerule'; >+} >+ >+1; >diff --git a/Koha/OverdueRules.pm b/Koha/OverdueRules.pm >new file mode 100644 >index 0000000000..a958ee031c >--- /dev/null >+++ b/Koha/OverdueRules.pm >@@ -0,0 +1,50 @@ >+package Koha::OverdueRules; >+ >+# Copyright ByWater Solutions 2023 >+# >+# 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 Koha::OverdueRule; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::OverdueRules - Koha::OverdueRule Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=head3 _type >+ >+=cut >+ >+sub _type { >+ return 'Overduerule'; >+} >+ >+=head3 object_class >+ >+=cut >+ >+sub object_class { >+ return 'Koha::OverdueRule'; >+} >+ >+1; >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index df9ad20bd9..48cf9aae1e 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -25,23 +25,24 @@ use JSON qw( to_json ); > use Unicode::Normalize qw( NFKD ); > use Try::Tiny; > >-use C4::Context; > use C4::Auth qw( checkpw_hash ); >+use C4::Context; >+use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages ); > use C4::Log qw( logaction ); > use Koha::Account; > use Koha::ArticleRequests; >-use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages ); > use Koha::AuthUtils; > use Koha::Checkouts; > use Koha::CirculationRules; > use Koha::Club::Enrollments; >+use Koha::CurbsidePickups; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Encryption; > use Koha::Exceptions::Password; > use Koha::Holds; >-use Koha::CurbsidePickups; > use Koha::Old::Checkouts; >+use Koha::OverdueRules; > use Koha::Patron::Attributes; > use Koha::Patron::Categories; > use Koha::Patron::Debarments; >@@ -1073,23 +1074,24 @@ sub _get_overdue_debarred_delay { > my ($branchcode, $categorycode) = @_; > my $dbh = C4::Context->dbh(); > >- my $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = ? AND categorycode = ?"; >- >- my $rqoverduerules = $dbh->prepare($query); >- $rqoverduerules->execute($branchcode, $categorycode); >- > # We get default rules if there is no rule for this branch >- if($rqoverduerules->rows == 0) { >- $query = "SELECT * FROM overduerules WHERE delay1 IS NOT NULL AND branchcode = '' AND categorycode = ?"; >- >- $rqoverduerules = $dbh->prepare($query); >- $rqoverduerules->execute($categorycode); >- } >+ my $rule = Koha::OverdueRules->find( >+ { >+ branchcode => $branchcode, >+ categorycode => $categorycode >+ } >+ ) >+ || Koha::OverdueRules->find( >+ { >+ branchcode => q{}, >+ categorycode => $categorycode >+ } >+ ); > >- while ( my $overdue_rules = $rqoverduerules->fetchrow_hashref ) { >- return $overdue_rules->{"delay1"} if($overdue_rules->{"debarred1"}); >- return $overdue_rules->{"delay2"} if($overdue_rules->{"debarred2"}); >- return $overdue_rules->{"delay3"} if($overdue_rules->{"debarred3"}); >+ if ( $rule ) { >+ return $rule->delay1 if $rule->debarred1; >+ return $rule->delay2 if $rule->debarred2; >+ return $rule->delay3 if $rule->debarred3; > } > } > >diff --git a/Koha/Schema/Result/Overduerule.pm b/Koha/Schema/Result/Overduerule.pm >index e5c112c2f4..c52005ca50 100644 >--- a/Koha/Schema/Result/Overduerule.pm >+++ b/Koha/Schema/Result/Overduerule.pm >@@ -198,6 +198,11 @@ __PACKAGE__->has_many( > # Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pORigxtC5qztZWHI29mZ/g > >+sub koha_object_class { >+ 'Koha::OverdueRule'; >+} >+sub koha_objects_class { >+ 'Koha::OverdueRules'; >+} > >-# You can replace this text with custom content, and it will be preserved on regeneration > 1; >-- >2.30.2
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 29145
:
125495
|
140819
|
140820
|
141822
|
141823
|
142394
|
142395
|
142396
|
142814
|
142815
|
142816
|
142817
|
143213
|
144773
|
144774
|
144775
|
144776
|
144777
|
144778
|
144779
|
144780
|
144781
|
144782
|
145720
|
145749
|
145750
|
145751
|
153804
|
153805
|
153806
|
153807
|
153808
|
153809
|
153810
|
153811
|
153812
|
153813
|
153814
|
156392
|
156393
|
156394
|
156395
|
156396
|
156397
|
156398
| 156399 |
156400
|
156401
|
156402
|
156403
|
156404