Bug 20687 - Multiple invitations to share lists prevents some users from accepting
Summary: Multiple invitations to share lists prevents some users from accepting
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Lists (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Nick Clemens
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 9032 14544
Blocks:
  Show dependency treegraph
 
Reported: 2018-05-01 11:19 UTC by Nick Clemens
Modified: 2018-10-24 09:13 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 20687 - Check all share keys for a given list (2.48 KB, patch)
2018-05-01 13:50 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 20687: Check all share keys for a given list (2.57 KB, patch)
2018-05-04 06:55 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 20687: (follow-up) Look for invitekey in show_accept and fix error codes (3.80 KB, patch)
2018-05-04 06:55 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 20687: Check all share keys for a given list (2.61 KB, patch)
2018-05-07 13:56 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 20687: (follow-up) Look for invitekey in show_accept and fix error codes (3.84 KB, patch)
2018-05-07 13:56 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2018-05-01 11:19:05 UTC
To recreate:
1 - Create a private list in the opac
2 - Invite 2 patrons to the list
3 - Try to accept from the patron you first shared to
4 - You will get a failure message about expiration of the link

It seems we only get the latest invitation when trying to accept:

opac/opac-shareshelf.pl line 135:
    # We could have used ->find with the share id, but we don't want to change
    # the url sent to the patron
    my $shared_shelf = Koha::Virtualshelfshares->search(
        {
            shelfnumber => $param->{shelfnumber},
        },
        {
            order_by => { -desc => 'sharedate' },
            limit => 1,
        }
    );
Comment 1 Nick Clemens 2018-05-01 13:50:26 UTC
Created attachment 74949 [details] [review]
Bug 20687 - Check all share keys for a given list

This patch gets all the shares for a list and iterates through to find
the correct one when accepting from a link

To test:
1 - Create a private list in the opac
2 - Invite 2 patrons to the list
3 - Try to accept from the patron you first shared to
4 - You will get a failure message about expiration of the link
5 - Apply patch
6 - Now try to accept the first share
7 - It works! Success!
Comment 2 Jonathan Druart 2018-05-03 14:45:04 UTC
Just reading the code: should not we search using the invitekey?
There is definitely something wrong. Marcel maybe?
Comment 3 Marcel de Rooy 2018-05-04 05:49:00 UTC
(In reply to Jonathan Druart from comment #2)
> Just reading the code: should not we search using the invitekey?
> There is definitely something wrong. Marcel maybe?

I wrote the original code, but the author of bug 14544 made some changes :)
Comment 4 Marcel de Rooy 2018-05-04 05:53:10 UTC
Working on this one now
Comment 5 Marcel de Rooy 2018-05-04 06:53:16 UTC
Nick: Commit title does not start with 'Bug XXXXX: ' - d63a082 !!
Comment 6 Marcel de Rooy 2018-05-04 06:55:02 UTC
Created attachment 75047 [details] [review]
Bug 20687: Check all share keys for a given list

This patch gets all the shares for a list and iterates through to find
the correct one when accepting from a link

To test:
1 - Create a private list in the opac
2 - Invite 2 patrons to the list
3 - Try to accept from the patron you first shared to
4 - You will get a failure message about expiration of the link
5 - Apply patch
6 - Now try to accept the first share
7 - It works! Success!

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 7 Marcel de Rooy 2018-05-04 06:55:07 UTC
Created attachment 75048 [details] [review]
Bug 20687: (follow-up) Look for invitekey in show_accept and fix error codes

We should check the invitekey in show_accept by passing it along in the
search call.
On the way I fixed some error checking: if the list number is invalid, or
the list is public or you are the owner, or if the key is not found, we
should set the right error code; the template contains those messages.

Test plan:
[1] Share a list and accept a correct invitation with another user.
[2] Try to accept some invalid proposals: wrong key, wrong list.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested invalid key, wrong list, owner, public list, expiry.
Comment 8 Marcel de Rooy 2018-05-04 07:02:30 UTC
Left only one (known) problem: double accepts (bug 11943).
Will try to add something there ;)
Comment 9 Kyle M Hall 2018-05-07 13:56:19 UTC
Created attachment 75124 [details] [review]
Bug 20687: Check all share keys for a given list

This patch gets all the shares for a list and iterates through to find
the correct one when accepting from a link

To test:
1 - Create a private list in the opac
2 - Invite 2 patrons to the list
3 - Try to accept from the patron you first shared to
4 - You will get a failure message about expiration of the link
5 - Apply patch
6 - Now try to accept the first share
7 - It works! Success!

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 10 Kyle M Hall 2018-05-07 13:56:27 UTC
Created attachment 75125 [details] [review]
Bug 20687: (follow-up) Look for invitekey in show_accept and fix error codes

We should check the invitekey in show_accept by passing it along in the
search call.
On the way I fixed some error checking: if the list number is invalid, or
the list is public or you are the owner, or if the key is not found, we
should set the right error code; the template contains those messages.

Test plan:
[1] Share a list and accept a correct invitation with another user.
[2] Try to accept some invalid proposals: wrong key, wrong list.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested invalid key, wrong list, owner, public list, expiry.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 11 Jonathan Druart 2018-05-07 15:26:21 UTC
Pushed to master for 18.05, thanks to everybody involved!
Comment 12 Nick Clemens 2018-05-22 11:10:16 UTC
Pushed to stable for 17.11.6
Comment 13 Fridolin SOMERS 2018-05-23 05:29:15 UTC
Pushed to 17.05.x for v17.05.12