On the manage marc import screen, clicking Import Batch on a batch containing a deleted item gives the message "Error attempting to create label batch. Please ask your system administrator to check the log for more details.", and creates an empty PDF file. To replicate: 1) Import a marc record including items. 2) Delete one of the items in the batch. 3) In Home › Tools › Manage staged MARC records, click '(Create label batch)' on the batch in question. 4) This will show the message "Error attempting to create label batch. Please ask your system administrator to check the log for more details." The logs in /var/log/koha/INSTANCE/intranet-error.log will look like this: 123456 [Mon May 15 11:14:21.848772 2017] [cgi:error] [pid 15635] [client a.b.c.d:xxxxx] AH01215: [Mon May 15 11:14:21 2017] manage-marc-import.pl: DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha_xyzzy`.`creator_batches`, CONSTRAINT `creator_batches_ibfk_3` FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE) [for Statement "INSERT INTO creator_batches (batch_id, item_number, branch_code, creator) VALUES (?,?,?,?);" with ParamValues: 0=164, 1=123456, 2="APL", 3='Labels'] at /usr/share/koha/lib/C4/Creators/Batch.pm line 69., referer: http://asdfsadf... [Mon May 15 11:14:21.849012 2017] [cgi:error] [pid 15635] [client a.b.c.d:xxxxx] AH01215: [Mon May 15 11:14:21 2017] manage-marc-import.pl: Database returned the following error on attempted INSERT: Cannot add or update a child row: a foreign key constraint fails (`koha_xyzzy`.`creator_batches`, CONSTRAINT `creator_batches_ibfk_3` FOREIGN KEY (`item_number`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE) at /usr/share/koha/lib/C4/Creators/Batch.pm line 71., referer: http://asdfsadf... [Mon May 15 11:14:21.849147 2017] [cgi:error] [pid 15635] [client a.b.c.d:xxxxx] AH01215: [Mon May 15 11:14:21 2017] manage-marc-import.pl: create_labelbatch_from_importbatch() : Error attempting to add item #123456 of import batch #11048 to label batch. at /usr/share/koha/intranet/cgi-bin/tools/manage-marc-import.pl line 198., referer: http://asdfsadf ... I think we need to have /usr/share/koha/lib/C4/Creators/Batch.pm exclude items where the itemnumber is null.
As a work-around, create a report of valid barcodes in a given import batch using the query found here: https://wiki.koha-community.org/wiki/SQL_Reports_Library#Workaround_for_Bug_18611
Created attachment 63483 [details] [review] Bug 18611 - Create labels action fails in manage-marc-import.pl if an item has been deleted from the import batch. To test: 1 - Import a batch with some items 2 - Delete one of the imported items 3 - Browse to Tools->Staged MARC record management 4 - Click (Create label batch) for the batch you imported 5 - Recieve an error 6 - Apply patch 7 - Click (Create label batch) 8 - Batch is created with remaning items from the import
Created attachment 63667 [details] [review] Bug 18611 - Create labels action fails in manage-marc-import.pl if an item has been deleted from the import batch. To test: 1 - Import a batch with some items 2 - Delete one of the imported items 3 - Browse to Tools->Staged MARC record management 4 - Click (Create label batch) for the batch you imported 5 - Recieve an error 6 - Apply patch 7 - Click (Create label batch) 8 - Batch is created with remaning items from the import Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 63668 [details] [review] [SIGNED-OFF] Bug 18611 - Followup, remove tabs to make qa tools happy Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 63669 [details] [review] Bug 18611 - Followup, remove tabs to make qa tools happy Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 63728 [details] [review] Bug 18611 - Create labels action fails in manage-marc-import.pl if an item has been deleted from the import batch. To test: 1 - Import a batch with some items 2 - Delete one of the imported items 3 - Browse to Tools->Staged MARC record management 4 - Click (Create label batch) for the batch you imported 5 - Recieve an error 6 - Apply patch 7 - Click (Create label batch) 8 - Batch is created with remaning items from the import Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 63729 [details] [review] Bug 18611 - Followup, remove tabs to make qa tools happy Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 63730 [details] [review] Bug 18611: [QA Follow-up] Make SQL query more readable Make it more explicit by adding join statements. Test plan: See next patch for adding a unit test. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 63731 [details] [review] Bug 18611: [QA Follow-up] Add unit test for GetItemNumbersFromImportBatch Test plan: Run t/db_dependent/ImportBatch.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to master for 17.05, thanks Nick, Josef, Marcel!
These patches have been pushed to 16.11.x and will be in 16.11.09.
Pushed to 16.05.x, for 16.05.15 release