Bug 15177: TO_PROCESS notice for fr-FR
[koha-ffzg.git] / authorities / merge.pl
index 5682b5e..476b774 100755 (executable)
@@ -6,7 +6,7 @@
 #
 # Koha is free software; you can redistribute it and/or modify it under the
 # terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
+# Foundation; either version 3 of the License, or (at your option) any later
 # version.
 #
 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -19,7 +19,7 @@
 
 use strict;
 use warnings;
-use CGI;
+use CGI qw ( -utf8 );
 use C4::Output;
 use C4::Auth;
 use C4::AuthoritiesMarc;
@@ -68,6 +68,7 @@ if ($merge) {
             require C4::ImportBatch;
             C4::ImportBatch::SetImportRecordStatus( $recordid2, 'imported' );
         } else {
+            C4::AuthoritiesMarc::merge( $recordid2, GetAuthority($recordid2), $recordid1, $record );
             $error = (DelAuthority($recordid2) == 0);
         }
         push @errors, $error if ($error);
@@ -122,10 +123,13 @@ else {
                 }
             }
 
-            my $notreference =
-              ( $authid[0] == $mergereference )
-              ? $authid[1]
-              : $authid[0];
+            #Setting $notreference
+            my $notreference = $authid[1];
+            if($mergereference == $notreference){
+                $notreference = $authid[0];
+                #Swap so $recordObj1 is always the correct merge reference
+                ($recordObj1, $recordObj2) = ($recordObj2, $recordObj1);
+            }
 
             # Creating a loop for display