Does it matter? Yes, using authorized values like ccode to populate the itemtypes of the biblioitems (instead of the itemtype table) can lead to such data. Or importing records with invalid itemtype codes. Koha doesn't do enough checks to at least warn about these issues. == Reproduce == 1. have/create a budget 2. have/create a fund 3. have/create a vendor with minimal info 4. create a basket with minimal info 5. add a item to the basket 6. go to the basket. URL should be /cgi-bin/koha/acqui/basket.pl?basketno=XXXXX 7. close this basket 8. create a basket group with the basket - your vendor page => Basket groups - create basket group - (tick the "close this basket group" check box) 9. go to the basket group your vendor page => Basket groups => Closed 10. export as PDF, it should work, keep the page opened 11. find the itemtype code of item in the basket 12. delete it with the following SQL[1] (directly or use sql reports) replace with the relevant type code DELETE from itemtypes where itemtype = "BOOK"; 13. reexport the basket as PDF 14. It should fail (internal server error) [1] Or you can find a more realistic way to have a biblioitem whose itemtype is not in the itemtype table
Created attachment 74604 [details] [review] Bug 20623 : Fix basket group PDF when itemtype not itemtype table When an item has an itemtype not in the itemtype table. Trying to fetch it's description lead to an error. Using authorized values like ccode to populate the itemtypes of the biblioitems (instead of the itemtype table) can lead to such data. Or importing records with invalid itemtype codes. Koha doesn't do enough checks at import to at least warn about these issues. == Test plan == 1. have/create a budget 2. have/create a fund 3. have/create a vendor with minimal info 4. create a basket with minimal info 5. add a item to the basket 6. go to the basket. URL should be /cgi-bin/koha/acqui/basket.pl?basketno=XXXXX 7. close this basket 8. create a basket group with the basket - your vendor page => Basket groups - create basket group - (tick the "close this basket group" check box) 9. go to the basket group your vendor page => Basket groups => Closed 10. export as PDF, it should work, keep the page opened 11. find the itemtype code of item in the basket 12. delete it with the following SQL[1] (directly or use sql reports) replace with the relevant type code DELETE from itemtypes where itemtype = "BOOK"; 13. reexport the basket as PDF 14. it should fail (internal server error) this is the bug (no kidding ^^) 15. apply this patch 16. reexport the basket as PDF 17. it should work 18. create an item type (in administration) that has the same code as the deleted one 19. reexport the basket as PDF 20. check that in the PDF that the description is here: table at the bottom of the document → "Document" column [1] Or you can find a more realistic way to have a biblioitem whose itemtype is not in the itemtype table
Created attachment 74605 [details] [review] Bug 20623 : Fix basket group PDF when itemtype not itemtype table When an item has an itemtype not in the itemtype table. Trying to fetch it's description lead to an error. Using authorized values like ccode to populate the itemtypes of the biblioitems (instead of the itemtype table) can lead to such data. Or importing records with invalid itemtype codes. Koha doesn't do enough checks at import to at least warn about these issues. == Test plan == 1. have/create a budget 2. have/create a fund 3. have/create a vendor with minimal info 4. create a basket with minimal info 5. add a item to the basket 6. go to the basket. URL should be /cgi-bin/koha/acqui/basket.pl?basketno=XXXXX 7. close this basket 8. create a basket group with the basket - your vendor page => Basket groups - create basket group - (tick the "close this basket group" check box) 9. go to the basket group your vendor page => Basket groups => Closed 10. export as PDF, it should work, keep the page opened 11. find the itemtype code of item in the basket 12. delete it with the following SQL[1] (directly or use sql reports) replace with the relevant type code DELETE from itemtypes where itemtype = "BOOK"; 13. reexport the basket as PDF 14. it should fail (internal server error) this is the bug (no kidding ^^) 15. apply this patch 16. reexport the basket as PDF 17. it should work 18. create an item type (in administration) that has the same code as the deleted one 19. reexport the basket as PDF 20. check that in the PDF that the description is here: table at the bottom of the document → "Document" column [1] Or you can find a more realistic way to have a biblioitem whose itemtype is not in the itemtype table
This is due to migration issue, see this thread: http://koha.1045719.n5.nabble.com/Expected-behaviour-if-itemtype-does-not-exist-td5939989.html It would be better to add a warning on the about page about data inconsistency.
TODO: find a realistic test plan. After discussing with Jonathan on IRC, I need to provide a test plan that shows that it's not only a migration issue.
Created attachment 74913 [details] [review] Bug 20623 : Fix basket group PDF when itemtype not itemtype table When an item has an itemtype not in the itemtype table. Trying to fetch it's description lead to an error. Using authorized values like ccode to populate the itemtypes of the biblioitems (instead of the itemtype table) can lead to such data. Or importing records with invalid itemtype codes. Koha doesn't do enough checks at import to at least warn about these issues. == Test plan == 1. first we need an item with an itype not in the item_types table 1. download a record as MARCXML 2. find it's item type in administration; and the related code 3. open the MARCXML file and search for occurences of the code and replace them by some non-existing value like "FOOBAR" 4. also change the barcode so it won't be ignored because it's a duplicate 5. also change the title to easily find it later in the search 6. tools → "Stage MARC records for import" 7. upload your file 8. "stage for import" 9. click "Manage staged records" You should end on the page related to your staged record 10. "Import this batch into the catalog" 2. now we need it in a basket group 1. have/create a active budget 2. have/create a fund 3. have/create a vendor with minimal info 4. create a basket with minimal info 5. add our imported item to the basket for example search it by name 6. go to the basket. URL should be /cgi-bin/koha/acqui/basket.pl?basketno=XXXXX 7. close this basket and tick "Attach this basket to a new basket group with the same name" 8. you will end up in the basket groups lists 9. go to the "closed" tab 11. go to the basket group your vendor page => Basket groups => Closed 3. export as PDF, it should fail (internal server error) this is the bug (no kidding ^_^) 4. apply this patch 5. reexport the basket as PDF 6. it should work 7. create an item type (in administration) that has the same code as the one that you put in the MARCXML 8. reexport the basket as PDF 9. check that in the PDF that the description is here: table at the bottom of the document → "Document" column
oleonard: > Catalogers here do some cataloging outside of Koha and then import records. > If they have made a typo when entering the item type or collection code > an error could get in that way. > [...] > The catalogers stage and import files of MARC records
Created attachment 75225 [details] [review] Bug 20623: Fix basket group PDF when itemtype not itemtype table When an item has an itemtype not in the itemtype table. Trying to fetch it's description lead to an error. Using authorized values like ccode to populate the itemtypes of the biblioitems (instead of the itemtype table) can lead to such data. Or importing records with invalid itemtype codes. Koha doesn't do enough checks at import to at least warn about these issues. == Test plan == 1. first we need an item with an itype not in the item_types table 1. download a record as MARCXML 2. find it's item type in administration; and the related code 3. open the MARCXML file and search for occurences of the code and replace them by some non-existing value like "FOOBAR" 4. also change the barcode so it won't be ignored because it's a duplicate 5. also change the title to easily find it later in the search 6. tools → "Stage MARC records for import" 7. upload your file 8. "stage for import" 9. click "Manage staged records" You should end on the page related to your staged record 10. "Import this batch into the catalog" 2. now we need it in a basket group 1. have/create a active budget 2. have/create a fund 3. have/create a vendor with minimal info 4. create a basket with minimal info 5. add our imported item to the basket for example search it by name 6. go to the basket. URL should be /cgi-bin/koha/acqui/basket.pl?basketno=XXXXX 7. close this basket and tick "Attach this basket to a new basket group with the same name" 8. you will end up in the basket groups lists 9. go to the "closed" tab 11. go to the basket group your vendor page => Basket groups => Closed 3. export as PDF, it should fail (internal server error) this is the bug (no kidding ^_^) 4. apply this patch 5. reexport the basket as PDF 6. it should work 7. create an item type (in administration) that has the same code as the one that you put in the MARCXML 8. reexport the basket as PDF 9. check that in the PDF that the description is here: table at the bottom of the document → "Document" column Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Created attachment 75263 [details] [review] Bug 20623: Fix basket group PDF when itemtype not itemtype table When an item has an itemtype not in the itemtype table. Trying to fetch it's description lead to an error. Using authorized values like ccode to populate the itemtypes of the biblioitems (instead of the itemtype table) can lead to such data. Or importing records with invalid itemtype codes. Koha doesn't do enough checks at import to at least warn about these issues. == Test plan == 1. first we need an item with an itype not in the item_types table 1. download a record as MARCXML 2. find it's item type in administration; and the related code 3. open the MARCXML file and search for occurences of the code and replace them by some non-existing value like "FOOBAR" 4. also change the barcode so it won't be ignored because it's a duplicate 5. also change the title to easily find it later in the search 6. tools → "Stage MARC records for import" 7. upload your file 8. "stage for import" 9. click "Manage staged records" You should end on the page related to your staged record 10. "Import this batch into the catalog" 2. now we need it in a basket group 1. have/create a active budget 2. have/create a fund 3. have/create a vendor with minimal info 4. create a basket with minimal info 5. add our imported item to the basket for example search it by name 6. go to the basket. URL should be /cgi-bin/koha/acqui/basket.pl?basketno=XXXXX 7. close this basket and tick "Attach this basket to a new basket group with the same name" 8. you will end up in the basket groups lists 9. go to the "closed" tab 11. go to the basket group your vendor page => Basket groups => Closed 3. export as PDF, it should fail (internal server error) this is the bug (no kidding ^_^) 4. apply this patch 5. reexport the basket as PDF 6. it should work 7. create an item type (in administration) that has the same code as the one that you put in the MARCXML 8. reexport the basket as PDF 9. check that in the PDF that the description is here: table at the bottom of the document → "Document" column Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Created attachment 75264 [details] [review] Bug 20623: (QA follow-up) Remove one find call Imo these somewhat weird lines ask for improvement, but I don't want to change the exact conditions here. Just removing the need to call find twice. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
We could avoid the fetch in some cases. Maybe more: my $itemtype = ( $ord->{itemtype} and $biblioitem->itemtype ) ? Koha::ItemTypes->find( $biblioitem->itemtype ) : undef; $ord->{itemtype} = $itemtype ? $itemtype->description : undef;
Please fix ASAP, I'd like to push it very soon.
I pushed these 2 patches by mistake.
Created attachment 75273 [details] [review] Bug 20623: (QA follow-up) avoid fetch() calls in some cases
Pushed to master for 18.05, thanks to everybody involved!
Pushed to 17.11.x for v17.11.09
To help anyone having a similar problem to check if there are affected of not: error message: Can't call method "description" on an undefined value at /home/koha/src/acqui/basketgroup.pl line 199. Comparing the itemtypes table content with the actually used itemtypes (to check if there are used ones that aren't in the itemtypes table) SELECT itemtype FROM itemtypes; SELECT DISTINCT itemtype from biblioitems;
See bug 21150