Bug 23709 - Can't add new subfields to bibliographic frameworks
Summary: Can't add new subfields to bibliographic frameworks
Status: RESOLVED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: 18.11
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 23309
Blocks: 17258
  Show dependency treegraph
 
Reported: 2019-10-01 07:21 UTC by Corinne Hayet
Modified: 2019-12-11 09:25 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Corinne Hayet 2019-10-01 07:21:55 UTC
It only works if the subfield is connected to an Authorized values list.

I created a subfield 099$m with a link with COUNTRY authorized values list and it's OK

But, if I try to create a simple subfield 012$z and I've got the following error in logs : 

DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails (`koha`.`marc_subfield_structure`,
CONSTRAINT `marc_subfield_structure_ibfk_1` FOREIGN KEY
(`authorised_value`) REFERENCES `authorised_value_categories`
(`category_name`) ON DELETE SET NULL ON ) [for Statement "INSERT INTO `marc_subfield_structure` ( `authorised_value`, `authtypecode`, `defaultvalue`, `frameworkcode`, `hidden`, `isurl`, `kohafield`, `liblibrarian`, `libopac`, `link`, `mandatory`, `maxlength`, `repeatable`, `seealso`, `tab`, `tagfield`, `tagsubfield`,
`value_builder`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="", 1="", 2="", 3="", 4="0", 5=0, 6="", 7="test", 8="test", 9="", 10=0, 11="9999", 12=0, 13=undef, 14="0", 15="013", 16="x", 17=""] at /usr/local/share/perl5/DBIx/Class/Storage/DBI.pm line 1836.

Best regards,
Corinne
Comment 1 Jonathan Druart 2019-10-14 13:05:43 UTC
Corinne, can you confirm you still get this error using the last 18.11.x version?
Comment 2 Corinne Hayet 2019-10-14 13:22:04 UTC
yep, we use 18.11.10
Comment 3 Corinne Hayet 2019-10-14 13:25:11 UTC
both if you add a subfield using "edit/add subfield" menu or using import framework function
Comment 4 Jonathan Druart 2019-10-15 10:37:40 UTC
My guess is that the instance does not have the empty string value in authorised_value_categories.

Could you:
  SELECT COUNT(*) FROM authorised_value_categories WHERE category_name="";

If if returns 0 you can insert it using:
  INSERT INTO authorised_value_categories(category_name) VALUES ("");

Is it an old instance?
Comment 5 Jonathan Druart 2019-10-22 10:06:24 UTC
Lowering severity until it is confirmed.
Comment 6 Jonathan Druart 2019-12-11 08:58:36 UTC
No answer, closing. Please reopen if still valid.
Comment 7 Corinne Hayet 2019-12-11 09:10:07 UTC
Sorry for being late. For me, it still doesn't work in 18.11.11 despite we applied the patch. 

First installation was made with standard koha source (no migration)

SQL query  : SELECT COUNT(*) FROM authorised_value_categories WHERE category_name=""; give 1 as result. 

After applying the patch, we can add a subfield but we cannot update framework using import function.

Corinne
Comment 8 Jonathan Druart 2019-12-11 09:25:55 UTC
(In reply to Corinne Hayet from comment #7)
> After applying the patch, we can add a subfield but we cannot update
> framework using import function.

Bonjour Corinne,
So it sounds like something else. Can you detail the steps behind "using import function"?

See also bug 23398, which may be related ("Export to XML" is broken basically).