Bugzilla – Attachment 79462 Details for
Bug 21337
Add Koha::Patrons->delete
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21337: (Follow-up) Add parameter for move_to_deleted action
Bug-21337-Follow-up-Add-parameter-for-movetodelete.patch (text/plain), 2.40 KB, created by
Michal Denar
on 2018-09-26 20:26:44 UTC
(
hide
)
Description:
Bug 21337: (Follow-up) Add parameter for move_to_deleted action
Filename:
MIME Type:
Creator:
Michal Denar
Created:
2018-09-26 20:26:44 UTC
Size:
2.40 KB
patch
obsolete
>From 231d1300fe10eb418f4c771ffbe7ab8e7e506a96 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 13 Sep 2018 12:26:57 +0200 >Subject: [PATCH] Bug 21337: (Follow-up) Add parameter for move_to_deleted > action > >For consistency, it would be better to make the move optional. > >Test plan: >Run again t/db_dependent/Koha/Patrons.t. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > Koha/Patrons.pm | 8 ++++---- > t/db_dependent/Koha/Patrons.t | 2 +- > 2 files changed, 5 insertions(+), 5 deletions(-) > >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 713ad6c..37df417 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -209,23 +209,23 @@ sub anonymise_issue_history { > > =head3 delete > >- Koha::Patrons->search({ some filters here })->delete; >+ Koha::Patrons->search({ some filters here })->delete({ move => 1 }); > > Delete passed set of patron objects. > Wrapper for Koha::Patron->delete. (We do not want to bypass Koha::Patron > and let DBIx do the job without further housekeeping.) >- NOTE: By default includes a move to deletedborrowers. >+ Includes a move to deletedborrowers if move flag set. > > Return value (if relevant) is based on the individual return values. > > =cut > > sub delete { >- my ( $self ) = @_; >+ my ( $self, $params ) = @_; > my (@res, $rv); > $rv = 1; > while( my $patron = $self->next ) { >- $patron->move_to_deleted; # Needed here, since it is no default action.. >+ $patron->move_to_deleted if $params->{move}; > push @res, $patron->delete; > $rv=-1 if $res[-1]==-1; > $rv=0 if $rv==1 && $res[-1]==0; >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index 81b0da2..dac7f52 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -429,7 +429,7 @@ subtest 'Koha::Patrons->delete' => sub { > my $set = Koha::Patrons->search({ borrowernumber => { '>=' => $id1 }}); > is( $set->count, 2, 'Two patrons found as expected' ); > my $count1 = $schema->resultset('Deletedborrower')->count; >- is( $set->delete, 1, 'Two patrons deleted' ); >+ is( $set->delete({ move => 1 }), 1, 'Two patrons deleted' ); > my $count2 = $schema->resultset('Deletedborrower')->count; > is( $count2, $count1 + 2, 'Patrons moved to deletedborrowers' ); > }; >-- >2.1.4
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 21337
:
78586
|
78619
|
78621
|
79461
|
79462
|
79708
|
79709
|
79915
|
79916
|
79917
|
80624
|
81251
|
81252
|
81257