Bugzilla – Attachment 134470 Details for
Bug 30275
Checkout renewals should be stored in their own table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30275: (follow-up) Drop renewer_id constraint
Bug-30275-follow-up-Drop-renewerid-constraint.patch (text/plain), 8.18 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-05-02 19:30:39 UTC
(
hide
)
Description:
Bug 30275: (follow-up) Drop renewer_id constraint
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-05-02 19:30:39 UTC
Size:
8.18 KB
patch
obsolete
>From adbea4ea679adccb44ef5f24bfc1d127e913d99a Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 28 Apr 2022 09:28:50 +0100 >Subject: [PATCH] Bug 30275: (follow-up) Drop renewer_id constraint > >This patch fixes some unit tests by ensureing we set a valid userid for >mock userenv setting so that the foreign key constraint doesn't fail and >it also removes the exception class and check for renewer_id from the >store method as, for example with autorenewals, the renewal may not have >been triggered by a actual user. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Circulation.pm | 2 +- > Koha/Checkouts/Renewal.pm | 7 +--- > Koha/Exceptions/Checkouts/Renewals.pm | 49 ------------------------- > t/db_dependent/Circulation.t | 52 ++++++++++++++++----------- > t/db_dependent/Koha/Account/Line.t | 4 +-- > 5 files changed, 36 insertions(+), 78 deletions(-) > delete mode 100644 Koha/Exceptions/Checkouts/Renewals.pm > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 3b54a8ec9e..c28eb4b56e 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3193,7 +3193,7 @@ sub AddRenewal { > my $renewal = Koha::Checkouts::Renewal->new( > { > checkout_id => $issue->issue_id, >- renewer_id => C4::Context->userenv->{'number'}, >+ renewer_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, > seen => $seen, > interface => C4::Context->interface > } >diff --git a/Koha/Checkouts/Renewal.pm b/Koha/Checkouts/Renewal.pm >index bb8c54992a..b90072a028 100644 >--- a/Koha/Checkouts/Renewal.pm >+++ b/Koha/Checkouts/Renewal.pm >@@ -22,7 +22,6 @@ use Modern::Perl; > use base qw(Koha::Object); > > use Koha::Checkouts; >-use Koha::Exceptions::Checkouts::Renewals; > use Koha::Exceptions::Object; > use Koha::Old::Checkouts; > use Koha::Patrons; >@@ -39,7 +38,7 @@ Koha::Checkouts::Renewal - Koha Renewal object class > > =head3 store > >- my $return_claim = Koha::Checkout::Renewal->new($args)->store; >+ my $renewal = Koha::Checkout::Renewal->new($args)->store; > > Overloaded I<store> method that validates the attributes and raises relevant > exceptions as needed. >@@ -49,10 +48,6 @@ exceptions as needed. > sub store { > my ( $self ) = @_; > >- unless ( $self->in_storage || $self->renewer_id ) { >- Koha::Exceptions::Checkouts::Renewals::NoRenewerID->throw(); >- } >- > unless ( ( !$self->checkout_id && $self->in_storage ) > || Koha::Checkouts->find( $self->checkout_id ) > || Koha::Old::Checkouts->find( $self->checkout_id ) ) >diff --git a/Koha/Exceptions/Checkouts/Renewals.pm b/Koha/Exceptions/Checkouts/Renewals.pm >deleted file mode 100644 >index 93ca7373d6..0000000000 >--- a/Koha/Exceptions/Checkouts/Renewals.pm >+++ /dev/null >@@ -1,49 +0,0 @@ >-package Koha::Exceptions::Checkouts::Renewals; >- >-# 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::Exception; >- >-use Exception::Class ( >- 'Koha::Exceptions::Checkouts::Renewals' => { >- isa => 'Koha::Exception', >- }, >- 'Koha::Exceptions::Checkouts::Renewals::NoRenewerID' => { >- isa => 'Koha::Exceptions::Checkouts::Renewals', >- description => 'renewer_id is mandatory' >- }, >-); >- >-=head1 NAME >- >-Koha::Exceptions::Checkouts - Base class for Checkouts exceptions >- >-=head1 Exceptions >- >-=head2 Koha::Exceptions::Checkouts::Renewals >- >-Generic return claim exception >- >-=head2 Koha::Exceptions::Checkouts::Renewals::NoRenewerID >- >-Exception to be used when a renewal is requested to be store but >-the 'renewer_id' param is not passed. >- >-=cut >- >-1; >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index cf54a4f720..83602d9bc9 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -55,9 +55,11 @@ use Koha::Account::Offsets; > use Koha::ActionLogs; > use Koha::Notice::Messages; > >+my $builder = t::lib::TestBuilder->new; > sub set_userenv { > my ( $library ) = @_; >- t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} }); >+ my $staff = $builder->build_object({ class => "Koha::Patrons" }); >+ t::lib::Mocks::mock_userenv({ patron => $staff, branchcode => $library->{branchcode} }); > } > > sub str { >@@ -104,7 +106,6 @@ sub test_debarment_on_checkout { > > my $schema = Koha::Database->schema; > $schema->storage->txn_begin; >-my $builder = t::lib::TestBuilder->new; > my $dbh = C4::Context->dbh; > > # Prevent random failures by mocking ->now >@@ -711,6 +712,9 @@ subtest "CanBookBeRenewed tests" => sub { > # Make sure fine calculation isn't skipped when adding renewal > t::lib::Mocks::mock_preference('CalculateFinesOnReturn', 1); > >+ my $staff = $builder->build_object({ class => "Koha::Patrons" }); >+ t::lib::Mocks::mock_userenv({ patron => $staff }); >+ > t::lib::Mocks::mock_preference('RenewalLog', 0); > my $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } ); > my %params_renewal = ( >@@ -3891,26 +3895,34 @@ subtest 'ItemsDeniedRenewal preference' => sub { > } > }); > my $future = dt_from_string->add( days => 1 ); >- my $deny_issue = $builder->build_object({ class => 'Koha::Checkouts', value => { >- returndate => undef, >- renewals => 0, >- auto_renew => 0, >- borrowernumber => $idr_borrower->borrowernumber, >- itemnumber => $deny_book->itemnumber, >- onsite_checkout => 0, >- date_due => $future, >+ my $deny_issue = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ returndate => undef, >+ renewals_count => 0, >+ auto_renew => 0, >+ borrowernumber => $idr_borrower->borrowernumber, >+ itemnumber => $deny_book->itemnumber, >+ onsite_checkout => 0, >+ date_due => $future, >+ } > } >- }); >- my $allow_issue = $builder->build_object({ class => 'Koha::Checkouts', value => { >- returndate => undef, >- renewals => 0, >- auto_renew => 0, >- borrowernumber => $idr_borrower->borrowernumber, >- itemnumber => $allow_book->itemnumber, >- onsite_checkout => 0, >- date_due => $future, >+ ); >+ my $allow_issue = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ returndate => undef, >+ renewals_count => 0, >+ auto_renew => 0, >+ borrowernumber => $idr_borrower->borrowernumber, >+ itemnumber => $allow_book->itemnumber, >+ onsite_checkout => 0, >+ date_due => $future, >+ } > } >- }); >+ ); > > my $idr_rules; > >diff --git a/t/db_dependent/Koha/Account/Line.t b/t/db_dependent/Koha/Account/Line.t >index fe593ae17b..098d8e8bec 100755 >--- a/t/db_dependent/Koha/Account/Line.t >+++ b/t/db_dependent/Koha/Account/Line.t >@@ -509,7 +509,7 @@ subtest 'Renewal related tests' => sub { > value => { > itemnumber => $item->itemnumber, > onsite_checkout => 0, >- renewals => 99, >+ renewals_count => 99, > auto_renew => 0 > } > } >@@ -558,7 +558,7 @@ subtest 'Renewal related tests' => sub { > value => { > itemnumber => $item->itemnumber, > onsite_checkout => 0, >- renewals => 0, >+ renewals_count => 0, > auto_renew => 0 > } > } >-- >2.36.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 30275
:
131593
|
131594
|
131595
|
131596
|
131597
|
131598
|
131599
|
131600
|
131601
|
131602
|
131603
|
131604
|
131605
|
131606
|
131607
|
131608
|
131609
|
131610
|
131611
|
131612
|
131613
|
131614
|
131615
|
131616
|
131879
|
131880
|
131881
|
131882
|
131883
|
131884
|
131885
|
131886
|
131887
|
131888
|
131889
|
131890
|
131897
|
131898
|
131899
|
131900
|
131901
|
131902
|
131903
|
131904
|
131905
|
131906
|
131907
|
131908
|
131909
|
131910
|
133908
|
133909
|
133910
|
133911
|
133912
|
133913
|
133914
|
133915
|
133916
|
133917
|
133918
|
133919
|
133920
|
133921
|
133922
|
133929
|
133930
|
133931
|
133932
|
133933
|
133934
|
133935
|
133936
|
133937
|
133938
|
133939
|
133940
|
133941
|
133942
|
133943
|
133944
|
133969
|
133970
|
133971
|
133972
|
133973
|
133974
|
133975
|
133976
|
133977
|
133978
|
133979
|
133980
|
133981
|
133982
|
133983
|
133984
|
134177
|
134178
|
134179
|
134180
|
134181
|
134182
|
134183
|
134184
|
134185
|
134186
|
134187
|
134188
|
134189
|
134190
|
134191
|
134192
|
134193
|
134210
|
134228
|
134229
|
134230
|
134231
|
134232
|
134233
|
134234
|
134235
|
134236
|
134237
|
134238
|
134239
|
134240
|
134241
|
134242
|
134243
|
134244
|
134245
|
134246
|
134247
|
134248
|
134470
|
134471
|
134472
|
134473
|
134869
|
134870
|
134871
|
134872
|
134873
|
134874
|
134875
|
134876
|
134877
|
134878
|
134879
|
134880
|
134881
|
134882
|
134883
|
134884
|
134885
|
134886
|
134887
|
134888
|
134889
|
135123
|
135124
|
135125
|
135126
|
135127
|
135128
|
135129
|
135130
|
135131
|
135132
|
135133
|
135134
|
135135
|
135136
|
135137
|
135138
|
135139
|
135140
|
135141
|
135142
|
135143
|
137146
|
137147
|
137148
|
137149
|
137150
|
137151
|
137152
|
137153
|
137154
|
137155
|
137156
|
137157
|
137158
|
137159
|
137160
|
137161
|
137162
|
137163
|
137164
|
137165
|
137166
|
137217
|
137598