Bug 28846 - MarcRecordFromNewSuggestion needs mapping to biblioitems.itemtype
Summary: MarcRecordFromNewSuggestion needs mapping to biblioitems.itemtype
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Baptiste Wojtkowski (bwoj)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-12 01:18 UTC by Fridolin Somers
Modified: 2025-12-26 10:18 UTC (History)
2 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes creating suggestions in the staff interface when there is no Koha to MARC mapping for `biblioitems.itemtype` (Koha administration > Catalog > Koha to MARC mapping). If there was no mapping, and you created a new suggestion (Acquisitions > Acquisitions home > Suggestions > New suggestion) you would get an error ("Tag "" is not a valid tag...."), regardless of whether you selected a value for the `Document type` field or not. Now: - If there is no mapping, the `Document type` field is no longer shown on the suggestion form. - If there is a mapping, the `Document type` field is shown on the suggestion form and works as expected.
Version(s) released in:
Circulation function:


Attachments
Bug 28846: Check if biblioitems.itemtype mapping exists before using itemtypes in suggestions (4.18 KB, patch)
2025-10-27 11:33 UTC, Baptiste Wojtkowski (bwoj)
Details | Diff | Splinter Review
Bug 28846: Check if biblioitems.itemtype mapping exists before using itemtypes in suggestions (4.23 KB, patch)
2025-12-24 04:06 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2021-08-12 01:18:57 UTC
In C4::Suggestions, MarcRecordFromNewSuggestion uses mapping to biblioitems.itemtype :
https://git.koha-community.org/Koha-community/Koha/src/commit/e9428f662fe2ec0271878ec78886e7f95a25a9e1/C4/Suggestions.pm#L614

But this Koha to MARC mapping may not exists when itemtype is on item level.
Same for biblio.autor, even if unlikely.
Comment 1 Katrin Fischer 2022-07-16 11:58:55 UTC
Libraries using item-level itypes usually still have the mapping on record level, although they might set it to be not mandatory in cataloguing. There is a lot of functionality tied to the record level itype, even when using item level itypes, so both make sense to have.

biblio.author should also exist.

Is this to avoid an explosion if the mapping doesn't exist?

I tried to remove both and create a record from a suggestion:

* Administration > Kohat-to-MARC-Mapping, unmap biblio.author and biblioitems.itemtype (not a good idea, but for testing)
* Add a new suggestion > BOOM!

Tag "" is not a valid tag. at /kohadevbox/koha/C4/Suggestions.pm line 492.

This is actually odd, because creating a suggestions doens't create a MARC record yet.

Is this a non-fix if mappings are also required in other places or an even bigger issue?
Comment 2 Baptiste Wojtkowski (bwoj) 2025-10-22 14:05:11 UTC
We have a big customer that has no mapping there for a long time and only experienced a problem recently while trying to use the suggestion module. I'll propose a patch to fix issue there ; I don't think other parts of Koha are broken without this mapping, and if it is the case, they should probably be fixed each time.
Comment 3 Baptiste Wojtkowski (bwoj) 2025-10-27 11:33:35 UTC
Created attachment 188472 [details] [review]
Bug 28846: Check if biblioitems.itemtype mapping exists before using itemtypes in suggestions

Test plan:
1 - Ensure you have no mappings on biblioitems.itemtype
2 - Create a suggestion -> there is a field "Document type" you get an error when submitting.
3 - Apply patch
4 - Create a suggestion -> there is no field anymore and you get no error
5 - Put back the mapping on biblioitems.itemtype and check the field "Document type" is still present suggestion form
Comment 4 David Nind 2025-12-24 04:06:52 UTC
Created attachment 190709 [details] [review]
Bug 28846: Check if biblioitems.itemtype mapping exists before using itemtypes in suggestions

Test plan:
1 - Ensure you have no mappings on biblioitems.itemtype
2 - Create a suggestion -> there is a field "Document type" you get an error when submitting.
3 - Apply patch
4 - Create a suggestion -> there is no field anymore and you get no error
5 - Put back the mapping on biblioitems.itemtype and check the field "Document type" is still present suggestion form

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2025-12-24 04:14:04 UTC
I only tested in a MARC21 installation. Is testing in a UNIMARC installation required as well?

Testing notes (using KTD):

1. Step 1: 
   1.1 Go to Administration > Catalog > Koha to MARC mapping
   1.2 Find the biblioitems.itemtype mapping
   1.3 Click "Remove"
   1.4 Run these scripts:
       . misc/batchRebuildBiblioTables.pl -c 
       . misc/batchRebuildItemsTables.pl -c

2. Step 2: Create a suggestion:
   2.1 Acquisitions > Acquisitions home > Suggestions > New suggestion
   2.2 Enter details for a suggestion
   2.3 Choose a value for "Document type" field
   2.4 You get an error trace:
         Tag "" is not a valid tag. at /kohadevbox/koha/C4/Suggestions.pm line 448.
 at /usr/lib/x86_64-linux-gnu/perl-base/Carp.pm line 289
   2.5 Repeat adding a new suggestion, without selecting anything for the "Document type" field
   2.6 You get the same error as in 2.4

3. Step 5:
   3.1 Reset everything in KTD so that the mapping is back: reset_all
   3.2 Test again with creating a suggestion, one with something in "Document type" and one with nothing selected
   3.3 Suggestions successfully created.
Comment 6 Fridolin Somers 2025-12-26 10:18:35 UTC
(In reply to David Nind from comment #5)
> I only tested in a MARC21 installation. Is testing in a UNIMARC installation
> required as well?

I think no, it is not required.

Thanks a lot for testing, a real gift under the tree :D