Test case : - Select any biblio - Add an item - fill the form, and submit with the "Add & duplicate" button - Item is added, and the form is duplicated - Fill the missing info (barcode), and save the new item - Error 500 In koha logs, I have the following error : DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry '1100882' for key 'PRIMARY' at /home/koha/src/Koha/Object.pm line 170 After investigations, the id 1100882 is the id of the item that was added before. It looks like the new itemnumber is still present after duplicate ! Thanks, Christophe
Confirmed.. looking into it now
I can't for the life of me replicate this locally on a 22.11 checkout (or master).. but I can replicate it on a live site.. there must be something in the configuration that's causing this somewhere but I'm not seeing it yet.
Christophe, which exact version of Koha are you using? Do you recreate the problem on a sandbox?
I've traced the issue on this and managed to re-produce in KTD. It depends on the MARC framework you are using and what you have in the 952 field for the itemnumber field (subfield 9). If that subfield (952$9) is set to anything other than "ignore" in the "Managed in tab" then it will pull the item number that has just been created from the UI and try to add that as part of the duplicated item. We need to tell the duplication code to ignore the itemnumber field Patch incoming
Created attachment 156390 [details] [review] Bug 34689: Ignore itemnumber when creating item hash A primary key error can be thrown when an item number is included in a new title hash. We need the item creation to ignore an itemnumber even if it is included in a MARC Framework Test plan: 1) Edit the MARC framework relating to books (BKS in KTD) 2) In the 952$9 field (Koha itemnumber (autogenerated)), change the value of "Managed in tab" to "items (10)" 3) In the catalog, find a record that uses that MARC framework 4) Click "New" and choose to add a new item 5) Enter a barcode and click the "Add & duplicate" button 6) The page will refresh and an item will have been added 7) Enter a new barcode and click the same button again 8) An error will be thrown 9) Click the back button in the browser 10) Apply patch and restart_all 11) Click the add and duplicate button again 12) This time no error will be thrown and the page will refresh with another new item added 13) Sign off!
Created attachment 156431 [details] [review] Bug 34689: Ignore itemnumber when creating item hash A primary key error can be thrown when an item number is included in a new title hash. We need the item creation to ignore an itemnumber even if it is included in a MARC Framework Test plan: 1) Edit the MARC framework relating to books (BKS in KTD) 2) In the 952$9 field (Koha itemnumber (autogenerated)), change the value of "Managed in tab" to "items (10)" 3) In the catalog, find a record that uses that MARC framework 4) Click "New" and choose to add a new item 5) Enter a barcode and click the "Add & duplicate" button 6) The page will refresh and an item will have been added 7) Enter a new barcode and click the same button again 8) An error will be thrown 9) Click the back button in the browser 10) Apply patch and restart_all 11) Click the add and duplicate button again 12) This time no error will be thrown and the page will refresh with another new item added 13) Sign off! Signed-off-by: David Nind <david@davidnind.com>
Created attachment 156451 [details] [review] Bug 34689: Ignore itemnumber when creating item hash A primary key error can be thrown when an item number is included in a new title hash. We need the item creation to ignore an itemnumber even if it is included in a MARC Framework Test plan: 1) Edit the MARC framework relating to books (BKS in KTD) 2) In the 952$9 field (Koha itemnumber (autogenerated)), change the value of "Managed in tab" to "items (10)" 3) In the catalog, find a record that uses that MARC framework 4) Click "New" and choose to add a new item 5) Enter a barcode and click the "Add & duplicate" button 6) The page will refresh and an item will have been added 7) Enter a new barcode and click the same button again 8) An error will be thrown 9) Click the back button in the browser 10) Apply patch and restart_all 11) Click the add and duplicate button again 12) This time no error will be thrown and the page will refresh with another new item added 13) Sign off! Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Works, makes sense, QA script happy, code looks good, passing QA :)
We need confirmation from Christophe that the patch fixes his problem.
Hi, I just applied the patch on our platform and it fixes the problem on our side ! Thank you
(In reply to Christophe TORIN from comment #10) > Hi, > > I just applied the patch on our platform and it fixes the problem on our > side ! > > Thank you Great, thanks for the quick reply!
Pushed to master for 23.11. Nice work everyone, thanks!
Pushed to 23.05.x for 23.05.05
Nice work everyone! Pushed to oldstable for 22.11.x