Bug 9201

Summary: OAI-PMH mapping value cannot be 0
Product: Koha Reporter: Mirko Tietgen <mirko>
Component: System AdministrationAssignee: Mirko Tietgen <mirko>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P5 - low CC: chris, gmcharlt, mtj, veron
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 8906    
Bug Blocks:    
Attachments: Bug 9201 OAI-PMH mapping value cannot be 0
Bug 9201 OAI-PMH mapping value cannot be 0
Bug 9201 OAI-PMH mapping value cannot be 0

Description Mirko Tietgen 2012-12-03 19:38:28 UTC
When adding or editing OAI-PMH mappings, using 0 as a value results in that mapping being deleted. 0 is a valid value, mappings should only be deleted when the value is empty.
Comment 1 Marc Véron 2012-12-05 09:23:39 UTC
I can confirm this behaviour.

The reason is in file admin/oai_set_mappings.pl, line:

if($marcfields[$i] and $marcsubfields[$i] and $marcvalues[$i])

I think it should be something like 

if($marcfields[$i] and $marcsubfields[$i] and ($marcvalues[$i] and $marcvalues ne ''))
Comment 2 Mirko Tietgen 2012-12-13 22:50:01 UTC Comment hidden (obsolete)
Comment 3 Mirko Tietgen 2012-12-13 22:53:56 UTC
This patch is not touching the .tt file with description that says you need to empty one of these fields. I don't want to interfere with Bug 8906 that deletes this description anyway. Marking this bug as dependant on 8906 for that reason.
Comment 4 Jonathan Druart 2012-12-26 15:49:26 UTC Comment hidden (obsolete)
Comment 5 Mason James 2013-01-30 08:32:27 UTC
Created attachment 14940 [details] [review]
Bug 9201 OAI-PMH mapping value cannot be 0

Allow the value of a OAI set mapping to be 0 / empty. Delete the mapping if field or subfield are empty.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Now it is possible to add a value == 0 or an empty string.
Signed-off-by: Mason James <mtj@kohaaloha.com>
Comment 6 Mason James 2013-01-30 08:35:38 UTC
(In reply to comment #5)
> Created attachment 14940 [details] [review]
> Bug 9201 OAI-PMH mapping value cannot be 0
> 
> Allow the value of a OAI set mapping to be 0 / empty. Delete the mapping if
> field or subfield are empty.
> 
> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
> Now it is possible to add a value == 0 or an empty string.
> Signed-off-by: Mason James <mtj@kohaaloha.com>

passing QA, works as expected...
Comment 7 Jared Camins-Esakov 2013-01-31 21:12:23 UTC
Before I can push this, bug 8906 will have to be QAed. I will also need a detailed test plan so I can confirm that it actually works.
Comment 8 Mirko Tietgen 2013-02-04 13:09:14 UTC
Before applying the patch:

Go to Administration > OAI sets configuration
Choose »Add a new set«
setSpec: aaa
setName: bbb
Save
Choose »Define mappings« for your new set.
Enter »Field«: 100, »Subfield«: a, »Value«: 0
Click »Save« and see »Warning: no mappings defined for this set«


Apply patch
Enter field: 100, subfield: a, value: 0
Click »Save« and see that your mapping is saved
Comment 9 Jared Camins-Esakov 2013-02-04 13:15:04 UTC
This patch has been pushed to master. I spoke with Mirko, and he clarified that the functionality does not depend on Bug 8906, so I am pushing this patch now.
Comment 10 Chris Cormack 2013-02-06 19:33:22 UTC
Pushed to 3.10.x and 3.8.x will be in 3.10.3 and 3.8.10