use C4::Log;
use Koha::MetadataRecord::Authority;
use Koha::Authorities;
-use Koha::Authority::MergeRequest;
+use Koha::Authority::MergeRequests;
use Koha::Authority::Types;
use Koha::Authority;
use Koha::Libraries;
$sortby="" unless $sortby;
my $query;
my $qpquery = '';
- my $QParser;
- $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
my $attr = '';
# the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
# the authtypecode. Then, search on $a of this tag_to_report
# also store main entry MARC tag, to extract it at end of search
- my $mainentrytag;
##first set the authtype search and may be multiple authorities
if ($authtypecode) {
my $n=0;
if ($n>1){
while ($n>1){$query= "\@or ".$query;$n--;}
}
- if ($QParser) {
- $qpquery .= '(authtype:' . join('|| authtype:', @auths) . ')';
- }
}
my $dosearch;
elsif ( @$tags[$i] eq "thesaurus" ) {
$attr = " \@attr 1=Subject-heading-thesaurus ";
}
+ elsif ( @$tags[$i] eq "all" ) {
+ $attr = " \@attr 1=Any ";
+ }
else { # Use the index passed in params
$attr = " \@attr 1=" . @$tags[$i] . " ";
}
$q2 .= $attr;
$dosearch = 1;
++$attr_cnt;
- if ($QParser) {
- $qpquery .= " $tags->[$i]:\"$value->[$i]\"";
- }
} #if value
}
##Add how many queries generated
} elsif ($sortby eq 'AuthidDsc') {
$orderstring = '@attr 7=2 @attr 4=109 @attr 1=Local-Number 0';
}
- if ($QParser) {
- $qpquery .= ' all:all' unless $value->[0];
-
- if ( $value->[0] =~ m/^qp=(.*)$/ ) {
- $qpquery = $1;
- }
-
- $qpquery .= " #$sortby" unless $sortby eq '';
-
- $QParser->parse( $qpquery );
- $query = $QParser->target_syntax('authorityserver');
- } else {
- $query=($query?$query:"\@attr 1=_ALLRECORDS \@attr 2=103 ''");
- $query="\@or $orderstring $query" if $orderstring;
- }
+ $query=($query?$query:"\@attr 1=_ALLRECORDS \@attr 2=103 ''");
+ $query="\@or $orderstring $query" if $orderstring;
$offset = 0 if not defined $offset or $offset < 0;
my $counter = $offset;
my $marcorgcode = C4::Context->preference('MARCOrgCode');
if ( $userenv && $userenv->{'branch'} ) {
$library = Koha::Libraries->find( $userenv->{'branch'} );
- $marcorgcode = $library->get_effective_marcorgcode;
+ # userenv's library could not exist because of a trick in misc/commit_file.pl (see FIXME and set_userenv statement)
+ $marcorgcode = $library ? $library->get_effective_marcorgcode : $marcorgcode;
}
if (!$record->leader) {
$record->leader($leader);
my $authid = $params->{authid} || return;
my $skip_merge = $params->{skip_merge};
my $dbh = C4::Context->dbh;
+
+ # Remove older pending merge requests for $authid to itself. (See bug 22437)
+ my $condition = { authid => $authid, authid_new => [undef, 0, $authid], done => 0 };
+ Koha::Authority::MergeRequests->search($condition)->delete;
+
merge({ mergefrom => $authid }) if !$skip_merge;
$dbh->do( "DELETE FROM auth_header WHERE authid=?", undef, $authid );
logaction( "AUTHORITIES", "DELETE", $authid, "authority" ) if C4::Context->preference("AuthoritiesLog");
my $auth_tag_to_report = Koha::Authority::Types->find($authtypecode)->auth_tag_to_report;
# warn "record :".$record->as_formatted." auth_tag_to_report :$auth_tag_to_report";
# build a request for SearchAuthorities
- my $QParser;
- $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
- my $op;
- if ($QParser) {
- $op = '&&';
- } else {
- $op = 'and';
- }
+ my $op = 'AND';
+ $authtypecode =~ s#/#\\/#; # GENRE/FORM contains forward slash which is a reserved character
my $query='at:'.$authtypecode.' ';
my $filtervalues=qr([\001-\040\Q!'"`#$%&*+,-./:;<=>?@(){[}_|~\E\]]);
if ($record->field($auth_tag_to_report)) {
if ($type eq 'subfi') {
push @seefrom, {
heading => $field->as_string($marc21subfields),
- hemain => $field->subfield( substr($marc21subfields, 0, 1) ),
+ hemain => scalar $field->subfield( substr($marc21subfields, 0, 1) ),
type => ($field->subfield('i') || ''),
field => $field->tag(),
};
} else {
push @seefrom, {
heading => $field->as_string($marc21subfields),
- hemain => $field->subfield( substr($marc21subfields, 0, 1) ),
+ hemain => scalar $field->subfield( substr($marc21subfields, 0, 1) ),
type => $type,
field => $field->tag(),
};
if ($type eq 'subfi') {
push @seealso, {
heading => $field->as_string($marc21subfields),
- hemain => $field->subfield( substr($marc21subfields, 0, 1) ),
- type => $field->subfield('i'),
+ hemain => scalar $field->subfield( substr($marc21subfields, 0, 1) ),
+ type => scalar $field->subfield('i'),
field => $field->tag(),
search => $field->as_string($marc21subfields) || '',
authid => $field->subfield('9') || ''
} else {
push @seealso, {
heading => $field->as_string($marc21subfields),
- hemain => $field->subfield( substr($marc21subfields, 0, 1) ),
+ hemain => scalar $field->subfield( substr($marc21subfields, 0, 1) ),
type => $type,
field => $field->tag(),
search => $field->as_string($marc21subfields) || '',