if (scalar($marc_record->fields()) == 0) {
push @invalid_records, $marc_blob;
} else {
+
+ # Normalize the record so it doesn't have separated diacritics
+ SetUTF8Flag($marc_record);
+
$num_valid++;
if ($record_type eq 'biblio') {
$import_record_id = AddBiblioToBatch($batch_id, $rec_num, $marc_record, $encoding, int(rand(99999)), 0);
# remove item fields so that they don't get
# added again if record is reverted
+ # FIXME: GetXmlBiblio output should not contain item info any more! So the next foreach should not be needed. Does not hurt either; may remove old 952s that should not have been there anymore.
my $old_marc = MARC::Record->new_from_xml(StripNonXmlChars($oldxml), 'UTF-8', $rowref->{'encoding'}, $marc_type);
foreach my $item_field ($old_marc->field($item_tag)) {
$old_marc->delete_field($item_field);
SetImportRecordStatus($rowref->{'import_record_id'}, 'imported');
} elsif ($record_result eq 'ignore') {
$num_ignored++;
+ $recordid = $record_match;
if ($record_type eq 'biblio' and defined $recordid and $item_result eq 'create_new') {
my ($bib_items_added, $bib_items_errored) = BatchCommitItems($rowref->{'import_record_id'}, $recordid);
$num_items_added += $bib_items_added;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("SELECT candidate_match_id
FROM import_record_matches
- WHERE import_record_id = ?
+ JOIN import_records ON ( import_record_matches.import_record_id = import_records.import_record_id )
+ LEFT JOIN biblio ON ( candidate_match_id = biblio.biblionumber )
+ LEFT JOIN auth_header ON ( candidate_match_id = auth_header.authid )
+ WHERE import_record_matches.import_record_id = ? AND
+ ( (import_records.record_type = 'biblio' AND biblio.biblionumber IS NOT NULL) OR
+ (import_records.record_type = 'auth' AND auth_header.authid IS NOT NULL) )
ORDER BY score DESC, candidate_match_id DESC");
$sth->execute($import_record_id);
my ($record_id) = $sth->fetchrow_array();
$sth->execute();
while (my $row = $sth->fetchrow_hashref) {
if ($row->{'record_type'} eq 'auth') {
- $row->{'authorized_heading'} = GetAuthorizedHeading( { authid => $row->{'candidate_match_id'} } );
+ $row->{'authorized_heading'} = C4::AuthoritiesMarc::GetAuthorizedHeading( { authid => $row->{'candidate_match_id'} } );
}
next if ($row->{'record_type'} eq 'biblio' && not $row->{'biblionumber'});
push @$results, $row;
if ($marc_record->field('001')) {
$controlnumber = $marc_record->field('001')->data();
}
- my $authorized_heading = GetAuthorizedHeading({ record => $marc_record });
+ my $authorized_heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marc_record });
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("INSERT INTO import_auths (import_record_id, control_number, authorized_heading) VALUES (?, ?, ?)");
$sth->execute($import_record_id, $controlnumber, $authorized_heading);