Bug 11315

Summary: Add support for subfield deletion when doing authority merges.
Product: Koha Reporter: Frédérick Capovilla <fcapovilla>
Component: MARC Authority data supportAssignee: Maxime Beaulieu <maxime.beaulieu>
Status: CLOSED DUPLICATE QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: chris, eric.begin, francois.charbonnier, fridolin.somers, jonathan.druart, katrin.fischer, m.de.rooy, philippe.blouin
Version: master   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=5572
http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14583
Change sponsored?: Sponsored Patch complexity: Medium patch
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 15358    
Bug Blocks: 17908    
Attachments: Add the overwriteSubfieldsOnMerge preference.
New version of the patch adding the overwriteSubfieldsOnMerge preference.
Bug 11315 : Add the overwriteSubfieldsOnMerge preference.
Bug 11315 - Fixed issues in updatedatabase.pl
Bug 11315 - Added unit tests for the modified sub in AuthoritiesMarc.pm
Bug 11315 : Add the overwriteSubfieldsOnMerge preference.
Bug 11315 - Added unit tests for the modified sub in AuthoritiesMarc.pm new file: t/AuthoritiesMarc.t

Description Frédérick Capovilla 2013-11-27 17:43:20 UTC Comment hidden (obsolete)
Comment 1 Jonathan Druart 2014-01-27 11:32:43 UTC
Frédérick,
Why don't you check the pref overwriteSubfieldsOnMerge value in the merge routine?
Could you provide a test plan please?
Comment 2 Frédérick Capovilla 2014-02-17 22:28:05 UTC
I checked in our codebase, and we have a special merge script which needs to forces the $overwrite parameter to 1 to do its job correctly. I guess this is why the check wasn't done in the merge routine. 

I agree there is room for improvement. We could do the pref check in the merge routine and allow a parameter which could overrides the system pref.

Test plan :

Preparation :
* Create a test authority. For example, lets create a PERSON authority with this value :
   100$a : "Bruce Wayne"
* Rebuild the Zebra authority index. (rebuild_zebra.pl -a)
* Create a new biblio record and link it to the newly created authority by clicking the icon right of the 600$a field and searching for the "Bruce Wayne" authority.
* Add the "2014" value in the 600$d field of the biblio record before saving the biblio record. This is the value we will use to check the behavior of the new system preference.
* Rebuild the Zebra biblio index. (rebuild_zebra.pl -b)

Test 1 :
* Set the "overwriteSubfieldsOnMerge" system preference to "Don't overwrite".
* Edit the "Bruce Wayne" authority, change 100$a value to "Batman".
* Save the authority and go check the test biblio record. The 600$a field should now be "Batman", and the 600$d should still be "2014".

Test 2 :
* Set the "overwriteSubfieldsOnMerge" system preference to "Overwrite".
* Edit the "Batman" authority, change the 100$a value back to "Bruce Wayne".
* Save the authority and go check the test biblio record. The 600$a field should now be "Bruce Wayne", and the 600$d should now be empty. The additional subfield was overwritten this time.
Comment 3 Frédérick Capovilla 2014-02-18 15:29:21 UTC Comment hidden (obsolete)
Comment 4 Chris Cormack 2014-02-18 22:40:28 UTC
Created attachment 25404 [details] [review]
Bug 11315 : Add the overwriteSubfieldsOnMerge preference.

If it is activated, all of the biblio's subfields will be overwritten
when doing an authority merge.
This means that subfields that exist in the biblio, but not in the
authority will be deleted in the biblio when doing the merge.

Sponsored-by: CCSR ( http://www.ccsr.qc.ca )

Test plan :

Preparation :
* Set dontmerge system preference to "Do automatically update attached
biblios..."
* Create a test authority. For example, lets create a PERSON authority
with this value : 100$a : "Bruce Wayne"
* Rebuild the Zebra authority index. (rebuild_zebra.pl -a)
* Create a new biblio record and link it to the newly created
authority by clicking the icon right of the 600$a field and searching
for the "Bruce Wayne" authority.
* Add the "2014" value in the 600$d field of the biblio record before
saving the biblio record. This is the value we will use to check the
behavior of the new system preference.
* Rebuild the Zebra biblio index. (rebuild_zebra.pl -b)

Test 1 :
* Set the "overwriteSubfieldsOnMerge" system preference to "Don't
overwrite".
* Edit the "Bruce Wayne" authority, change 100$a value to "Batman".
* Save the authority and go check the test biblio record. The 600$a
field should now be "Batman", and the 600$d should still be "2014".

Test 2 :
* Set the "overwriteSubfieldsOnMerge" system preference to "Overwrite".
* Edit the "Batman" authority, change the 100$a value back to "Bruce
Wayne".
* Save the authority and go check the test biblio record. The 600$a
field should now be "Bruce Wayne", and the 600$d should now be empty.
The additional subfield was overwritten this time.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 5 Katrin Fischer 2014-04-18 22:42:44 UTC
Hi Frederick, 

can you please provide unit tests? It also looks like the database update is not correct - it's using the wrong version check and the update message is missing the beginning and the bug number. Could you please provide a follow up?
Comment 6 Maxime Beaulieu 2014-08-18 14:13:01 UTC
Created attachment 30940 [details] [review]
Bug 11315 - Fixed issues in updatedatabase.pl
Comment 7 Maxime Beaulieu 2014-08-18 14:13:15 UTC
Created attachment 30941 [details] [review]
Bug 11315 - Added unit tests for the modified sub in AuthoritiesMarc.pm

new file:   t/AuthoritiesMarc.t
Comment 8 Fridolin Somers 2015-02-25 16:01:20 UTC
Looks like it is close to the purpose of Bug 5572
Comment 9 Charles Farmer 2016-12-15 22:31:24 UTC
Created attachment 58234 [details] [review]
Bug 11315 : Add the overwriteSubfieldsOnMerge preference.

If it is activated, all of the biblio's subfields will be overwritten
when doing an authority merge.
This means that subfields that exist in the biblio, but not in the
authority will be deleted in the biblio when doing the merge.

Sponsored-by: CCSR ( http://www.ccsr.qc.ca )

Test plan :

Preparation :
* Set dontmerge system preference to "Do automatically update attached
biblios..."
* Create a test authority. For example, lets create a PERSON authority
with this value : 100$a : "Bruce Wayne"
* Rebuild the Zebra authority index. (rebuild_zebra.pl -a)
* Create a new biblio record and link it to the newly created
authority by clicking the icon right of the 600$a field and searching
for the "Bruce Wayne" authority.
* Add the "2014" value in the 600$d field of the biblio record before
saving the biblio record. This is the value we will use to check the
behavior of the new system preference.
* Rebuild the Zebra biblio index. (rebuild_zebra.pl -b)

Test 1 :
* Set the "overwriteSubfieldsOnMerge" system preference to "Don't
overwrite".
* Edit the "Bruce Wayne" authority, change 100$a value to "Batman".
* Save the authority and go check the test biblio record. The 600$a
field should now be "Batman", and the 600$d should still be "2014".

Test 2 :
* Set the "overwriteSubfieldsOnMerge" system preference to "Overwrite".
* Edit the "Batman" authority, change the 100$a value back to "Bruce
Wayne".
* Save the authority and go check the test biblio record. The 600$a
field should now be "Bruce Wayne", and the 600$d should now be empty.
The additional subfield was overwritten this time.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Comment 10 Charles Farmer 2016-12-15 22:31:32 UTC
Created attachment 58235 [details] [review]
Bug 11315 - Added unit tests for the modified sub in AuthoritiesMarc.pm new file: t/AuthoritiesMarc.t
Comment 11 Marcel de Rooy 2017-01-14 12:22:15 UTC
I am putting this one in the merge omnibus bug 17908.
The pref overwriteSubfieldsOnMerge is called AuthCleanBiblios on 5572. I thought of a name like AuthorityMergeMode. The loose mode would not touch, the strict mode would clear/overwrite. I am not sure if the loose mode conflicts with cataloguing rules btw..
Comment 12 Marcel de Rooy 2017-01-16 09:41:14 UTC
Temporarily blocked: see omnibus bug 17908. See also bug 17909 and 17913.
Comment 13 Marcel de Rooy 2017-01-23 08:09:09 UTC
Can be closed now: see omnibus bug 17908 and especially 17913

*** This bug has been marked as a duplicate of bug 17913 ***