Bug 26136

Summary: Prevent double submit of checkin form
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: CirculationAssignee: Nick Clemens (kidclamp) <nick>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: normal    
Priority: P5 - low CC: aleisha, gmcharlt, josef.moravec, kelly, kyle.m.hall, lucas, sally.healey, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.11.00, 20.05.03, 19.11.10
Bug Depends on:    
Bug Blocks: 26224    
Attachments: Bug 26136: Prevent double submit on checkin-form
Bug 26136: Prevent double submit on checkin-form
Bug 26136: Prevent double submit on checkin-form

Description Nick Clemens (kidclamp) 2020-08-04 13:13:34 UTC
We have seen reports of sites where checkins appear to be failing due to corrupt data with the error:
The checkin for the following issue failed, Please go to the about page, section 'data corrupted' to know how to fix this problem (DBIx::Class::Row::update(): Can't update Koha::Schema::Result::Issue=HASH(0x55c471ef6c28): row not found at /usr/share/koha/lib/Koha/Object.pm line 158

This seems to be caused by a double submission / race condition - the checkout is returned twice - the first succeeeds, the second fails because the row is moved to old_issues

Sometimes it succeeds an is logged as a return + localuse

We should prevent this from happening
Comment 1 Nick Clemens (kidclamp) 2020-08-04 13:17:20 UTC
Created attachment 107764 [details] [review]
Bug 26136: Prevent double submit on checkin-form

To test:
 1 - Browse to Circulation->Check-in
 2 - Type a barcode into the Check in box
 3 - Hit Enter as many as times as you can
 4 - Check the statistics table:
    SELECT * FROM statistics WHERE itemnumber={itemnumber} AND DATE(datetime)=CURDATE();
 5 - Note you have multiple lines for the same item at the same time
 6 - Apply patch
 7 - Reload the page
 8 - Type the barcode
 9 - Press Enter even more fast and more furiously
10 - Check the statistics table
11 - Only one entry, huzzah!
Comment 2 ByWater Sandboxes 2020-08-04 15:05:39 UTC
Created attachment 107784 [details] [review]
Bug 26136: Prevent double submit on checkin-form

To test:
 1 - Browse to Circulation->Check-in
 2 - Type a barcode into the Check in box
 3 - Hit Enter as many as times as you can
 4 - Check the statistics table:
    SELECT * FROM statistics WHERE itemnumber={itemnumber} AND DATE(datetime)=CURDATE();
 5 - Note you have multiple lines for the same item at the same time
 6 - Apply patch
 7 - Reload the page
 8 - Type the barcode
 9 - Press Enter even more fast and more furiously
10 - Check the statistics table
11 - Only one entry, huzzah!

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 3 Josef Moravec 2020-08-06 18:54:45 UTC
Created attachment 107907 [details] [review]
Bug 26136: Prevent double submit on checkin-form

To test:
 1 - Browse to Circulation->Check-in
 2 - Type a barcode into the Check in box
 3 - Hit Enter as many as times as you can
 4 - Check the statistics table:
    SELECT * FROM statistics WHERE itemnumber={itemnumber} AND DATE(datetime)=CURDATE();
 5 - Note you have multiple lines for the same item at the same time
 6 - Apply patch
 7 - Reload the page
 8 - Type the barcode
 9 - Press Enter even more fast and more furiously
10 - Check the statistics table
11 - Only one entry, huzzah!

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 4 Jonathan Druart 2020-08-07 14:56:15 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 5 Lucas Gass 2020-08-14 21:35:30 UTC
backported to 20.05.x for 20.05.03
Comment 6 Aleisha Amohia 2020-08-16 22:47:00 UTC
cannot reproduce bug in 19.11.x. not backported.
Comment 7 Aleisha Amohia 2020-09-01 22:30:19 UTC
managed to reproduce somewhere else, so have backported to 19.11.x for 19.11.10
Comment 8 Victor Grousset/tuxayo 2020-09-20 15:06:09 UTC
Not backported to oldoldstable (19.05.x). Feel free to ask if it's needed.