Bugzilla – Attachment 75049 Details for
Bug 11943
Koha::Virtualshelfshare duplicates rows for the same list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11943: Prevent double accepts in Koha::Virtualshelfshare
Bug-11943-Prevent-double-accepts-in-KohaVirtualshe.patch (text/plain), 2.07 KB, created by
Marcel de Rooy
on 2018-05-04 08:57:24 UTC
(
hide
)
Description:
Bug 11943: Prevent double accepts in Koha::Virtualshelfshare
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-05-04 08:57:24 UTC
Size:
2.07 KB
patch
obsolete
>From 331c5bdedd31aa785db1b9c2c59c69b3d3712be8 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 4 May 2018 09:34:02 +0200 >Subject: [PATCH] Bug 11943: Prevent double accepts in Koha::Virtualshelfshare >Content-Type: text/plain; charset=utf-8 > >This 'bug' existed long enough now to finally remove it ;) > >We do so by deleting the invitation if the borrower already has a share >on this list. Actually not that hard. > >We still need: a unit test and a db revision. > >Test plan: >[1] Share a list. Let user B accept. >[2] Without this patch: Share again and let B accept again. >[3] Verify that you have two shares for this list in virtualshelfshares. >[4] With this patch: Share another list, let B accept. >[5] Share this other list again, let B accept again. >[6] Verify that virtualshelfshares does not contain double entries now. > (Note: This pertains to the second list only.) > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Virtualshelfshare.pm | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > >diff --git a/Koha/Virtualshelfshare.pm b/Koha/Virtualshelfshare.pm >index 09e383f..2185454 100644 >--- a/Koha/Virtualshelfshare.pm >+++ b/Koha/Virtualshelfshare.pm >@@ -51,10 +51,20 @@ sub accept { > if ( $self->invitekey ne $invitekey ) { > Koha::Exceptions::Virtualshelves::InvalidInviteKey->throw; > } >- $self->invitekey(undef); >- $self->sharedate(dt_from_string); >- $self->borrowernumber($borrowernumber); >- $self->store; >+ >+ # If this borrower already has a share, there is no need to accept twice >+ # We solve this by 'pretending' to reaccept, but delete instead >+ my $search = Koha::Virtualshelfshares->search({ shelfnumber => $self->shelfnumber, borrowernumber => $borrowernumber, invitekey => undef }); >+ if( $search->count ) { >+ $self->delete; >+ return $search->next; >+ } else { >+ $self->invitekey(undef); >+ $self->sharedate(dt_from_string); >+ $self->borrowernumber($borrowernumber); >+ $self->store; >+ return $self; >+ } > } > > sub has_expired { >-- >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 11943
:
75049
|
75050
|
75051
|
75104
|
75105
|
75106
|
75120
|
75121
|
75122
|
75246
|
75247