Bugzilla – Attachment 171240 Details for
Bug 37480
Make C4::Serials::addroutingmember use Koha::Objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37480: Make addroutingmember use Koha::Subscription::Routinglists
Bug-37480-Make-addroutingmember-use-KohaSubscripti.patch (text/plain), 2.53 KB, created by
Jonathan Druart
on 2024-09-10 07:53:28 UTC
(
hide
)
Description:
Bug 37480: Make addroutingmember use Koha::Subscription::Routinglists
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-09-10 07:53:28 UTC
Size:
2.53 KB
patch
obsolete
>From 5cec49678be6053380822ef43239795c911c3d4c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 25 Jul 2024 14:20:09 -0300 >Subject: [PATCH] Bug 37480: Make addroutingmember use > Koha::Subscription::Routinglists > >This patch rewriteis the method so it relies on Koha::Object-based >classes instead of the old way. > >To test: >1. Run: > $ ktd --shell > k$ prove t/db_dependent/Serials.t >=> SUCCESS: Tests pass! >2. Apply this patch >3. Repeat 1 >=> SUCCESS: Tests pass! >4. Run: > $ git grep addroutingmember >=> SUCCESS: It is only called on a single .pl file which doesn't care >about the return value. Neither the tests care. >5. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Serials.pm | 24 +++++++++++------------- > 1 file changed, 11 insertions(+), 13 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index c8097ab6d42..4421bf35b0f 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -46,6 +46,7 @@ use Koha::DateUtils qw( dt_from_string ); > use Koha::Serial; > use Koha::SharedContent; > use Koha::Subscription::Histories; >+use Koha::Subscription::Routinglists; > use Koha::Subscriptions; > use Koha::Suggestions; > use Koha::TemplateUtils qw( process_tt ); >@@ -2017,21 +2018,18 @@ of either 1 or highest current rank + 1 > sub addroutingmember { > my ( $borrowernumber, $subscriptionid ) = @_; > >- return unless ($borrowernumber and $subscriptionid); >+ return unless ( $borrowernumber and $subscriptionid ); > >- my $rank; >- my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare( "SELECT max(ranking) `rank` FROM subscriptionroutinglist WHERE subscriptionid = ?" ); >- $sth->execute($subscriptionid); >- while ( my $line = $sth->fetchrow_hashref ) { >- if ( defined $line->{rank} && $line->{rank} > 0 ) { >- $rank = $line->{rank} + 1; >- } else { >- $rank = 1; >+ my $max_ranking = Koha::Subscription::Routinglists->search( { subscriptionid => $subscriptionid } ) >+ ->_resultset->get_column('ranking')->max; >+ >+ return Koha::Subscription::Routinglist->new( >+ { >+ subscriptionid => $subscriptionid, >+ borrowernumber => $borrowernumber, >+ ranking => defined $max_ranking ? $max_ranking + 1 : 1, > } >- } >- $sth = $dbh->prepare( "INSERT INTO subscriptionroutinglist (subscriptionid,borrowernumber,ranking) VALUES (?,?,?)" ); >- $sth->execute( $subscriptionid, $borrowernumber, $rank ); >+ )->store(); > } > > =head2 reorder_members >-- >2.34.1
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 37480
:
169608
|
169796
| 171240