# - we need to read the biblio if NoZebra is set (to remove it from the indexes
# - if something goes wrong, the biblio may be deleted from Koha but not from zebra
# and we would have no way to remove it (except manually in zebra, but I bet it would be very hard to handle the problem)
- ModZebra($biblionumber, "delete_record", "biblioserver", undef);
+ ModZebra($biblionumber, "recordDelete", "biblioserver", undef);
# delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems
$sth =
### ZEBRA SERVER UPDATER
##Uses its own database handle
my $dbh=C4::Context->dbh;
-my $readsth=$dbh->prepare("SELECT id,biblio_auth_number,operation,server FROM zebraqueue WHERE done=0");
+my $readsth=$dbh->prepare("SELECT id,biblio_auth_number,operation,server FROM zebraqueue WHERE done=0
+ ORDER BY id DESC"); # NOTE - going in reverse order to catch deletes that
+ # occur after a string of updates (e.g., user deletes
+ # the items attached to a bib, then the items.
+ # Having a specialUpdate occur after a recordDelete
+ # should not occur.
#my $delsth=$dbh->prepare("delete from zebraqueue where id =?");
# if the operation is a deletion, zebra requires that we give it the xml.
# as it is no more in the SQL db, retrieve it from zebra itself.
# may sound silly, but that's the way zebra works ;-)
- if ($operation =~ /delete/) {
+ if ($operation =~ /delete/i) { # NOTE depending on version, delete operation
+ # was coded 'delete_record' or 'recordDelete'.
+ # 'recordDelete' is the preferred one, as that's
+ # what the ZOOM API wants.
# 1st read the record in zebra
my $Zconn=C4::Context->Zconn($server, 0, 1,'','xml');
my $query = $Zconn->search_pqf( '@attr 1=Local-Number '.$biblionumber);
# did a modif (or item deletion) just before biblio deletion, there are some specialUpdage
# that are pending and can't succeed, as we don't have the XML anymore
# so, delete everything for this biblionumber
- if ($operation eq 'delete_record') {
+ my $reset_readsth = 0;
+ if ($operation eq 'recordDelete') {
print "deleting biblio deletion $biblionumber\n" if $verbose;
$delsth =$dbh->prepare("UPDATE zebraqueue SET done=1 WHERE biblio_auth_number =?");
$delsth->execute($biblionumber);
+ $reset_readsth = 1 if $delsth->rows() > 0;
# if it's not a deletion, delete every pending specialUpdate for this biblionumber
# in case the user add biblio, then X items, before this script runs
# this avoid indexing X+1 times where just 1 is enough.
print "deleting special date for $biblionumber\n" if $verbose;
$delsth =$dbh->prepare("UPDATE zebraqueue SET done=1 WHERE biblio_auth_number =? and operation='specialUpdate'");
$delsth->execute($biblionumber);
+ $reset_readsth = 1 if $delsth->rows() > 0;
+ }
+ if ($reset_readsth) {
+ # if we can ignore rows in zebraqueue because we've already
+ # touched a record, reset the query.
+ $readsth->finish();
+ $readsth->execute();
}
}
}