[PATCH] [SIGNED-OFF] Bug 8519 - Remove zebraqueue_start.pl script

Tomas Cohen Arazi tomascohen at gmail.com
Sun Aug 12 00:52:36 CEST 2012


Asked by wajasu, remove remaining obsolete zebraqueue stuff.

Sponsored-by: Universidad Nacional de C=C3=B3rdoba

Signed-off-by: wajasu <matted-34813 at mypacks.net>
---
 misc/cronjobs/zebraqueue_start.pl | 176 ----------------------------------=
----
 1 file changed, 176 deletions(-)
 delete mode 100755 misc/cronjobs/zebraqueue_start.pl

diff --git a/misc/cronjobs/zebraqueue_start.pl b/misc/cronjobs/zebraqueue_s=
tart.pl
deleted file mode 100755
index ea84156..0000000
--- a/misc/cronjobs/zebraqueue_start.pl
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/usr/bin/perl
-# script that starts the zebraquee
-#  Written by TG on 01/08/2006
-use strict;
-#use warnings; FIXME - Bug 2505
-BEGIN {
-    # find Koha's Perl modules
-    # test carefully before changing this
-    use FindBin;
-    eval { require "$FindBin::Bin/../kohalib.pl" };
-}
-
-use C4::Context;
-use C4::Biblio;
-use C4::Search;
-use C4::AuthoritiesMarc;
-use XML::Simple;
-use utf8;
-### ZEBRA SERVER UPDATER
-##Uses its own database handle
-my $dbh=3DC4::Context->dbh;
-my $readsth=3D$dbh->prepare("SELECT id,biblio_auth_number,operation,server=
 FROM zebraqueue WHERE done=3D0=20
-                           ORDER BY id DESC"); # NOTE - going in reverse o=
rder to catch deletes that
-                                               # occur after a string of u=
pdates (e.g., user deletes
-                                               # the items attached to a b=
ib, then the items.
-                                               # Having a specialUpdate oc=
cur after a recordDelete
-                                               # should not occur.
-#my $delsth=3D$dbh->prepare("delete from zebraqueue where id =3D?");
-
-
-#AGAIN:
-
-#my $wait=3DC4::Context->preference('zebrawait') || 120;
-my $verbose =3D 0;
-print "starting with verbose=3D$verbose\n" if $verbose;
-
-my ($id,$biblionumber,$operation,$server,$marcxml);
-
-$readsth->execute;
-while (($id,$biblionumber,$operation,$server)=3D$readsth->fetchrow){
-    print "read in queue : $id : biblio $biblionumber for $operation on $s=
erver\n" if $verbose;
-    my $ok;
-    eval{
-        # if the operation is a deletion, zebra requires that we give it t=
he 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 ;-)
-=09    if ($operation =3D~ /delete/i) { # NOTE depending on version, delet=
e operation
-                                       #      was coded 'delete_record' or=
 'recordDelete'.
-                                       #      'recordDelete' is the prefer=
red one, as that's
-                                       #      what the ZOOM API wants.
-=09       # 1st read the record in zebra
-            my $Zconn=3DC4::Context->Zconn($server, 0, 1,'','xml');
-            my $query =3D $Zconn->search_pqf( '@attr 1=3DLocal-Number '.$b=
iblionumber);
-            # then, delete the record
-=09        $ok=3Dzebrado($query->record(0)->render(),$operation,$server,$b=
iblionumber);
-        # if it's an add or a modif
-        } else {
-            # get the XML
-            if ($server eq "biblioserver") {
-                my $marc =3D GetMarcBiblio($biblionumber);
-                $marcxml =3D $marc->as_xml_record() if $marc;
-            } elsif ($server eq "authorityserver") {
-                $marcxml =3DC4::AuthoritiesMarc::GetAuthorityXML($biblionu=
mber);
-            }
-            if ($verbose) {
-                if ($marcxml) {
-                    print "XML read : $marcxml\n" if $verbose >1;
-                } else {
-                # workaround for zebra bug needing a XML even for deletion
-                $marcxml=3D "<dummy/>";
-                    print "unable to read MARCxml\n" if $verbose;
-                }
-            }
-            # check it's XML, just in case
-            eval {
-                my $hashed=3DXMLin($marcxml);
-            }; ### is it a proper xml? broken xml may crash ZEBRA- slow bu=
t safe
-            ## it's Broken XML-- Should not reach here-- but if it does -l=
ets protect ZEBRA
-            if ($@){
-                warn $@;
-                my $delsth=3D$dbh->prepare("UPDATE zebraqueue SET done=3D1=
 WHERE id =3D?");
-                $delsth->execute($id);
-                next;
-            }
-            # ok, we have everything, do the operation in zebra !
-            $ok=3Dzebrado($marcxml,$operation,$server);
-        }
-    };
-    print "ZEBRAopserver returned : $ok \n" if $verbose;
-    if ($ok =3D=3D1) {
-        $dbh=3DC4::Context->dbh;
-        my $delsth;
-        # if it's a deletion, we can delete every request on this biblio :=
 in case the user
-        # did a modif (or item deletion) just before biblio deletion, ther=
e are some specialUpdage
-        # that are pending and can't succeed, as we don't have the XML any=
more
-        # so, delete everything for this biblionumber
-        my $reset_readsth =3D 0;
-        if ($operation eq 'recordDelete') {
-            print "deleting biblio deletion $biblionumber\n" if $verbose;
-            $delsth =3D$dbh->prepare("UPDATE zebraqueue SET done=3D1 WHERE=
 biblio_auth_number =3D?");
-            $delsth->execute($biblionumber);
-            $reset_readsth =3D 1 if $delsth->rows() > 0;
-        # if it's not a deletion, delete every pending specialUpdate for t=
his biblionumber
-        # in case the user add biblio, then X items, before this script ru=
ns
-        # this avoid indexing X+1 times where just 1 is enough.
-        } else {
-            print "deleting special date for $biblionumber\n" if $verbose;
-            $delsth =3D$dbh->prepare("UPDATE zebraqueue SET done=3D1 WHERE=
 biblio_auth_number =3D? and operation=3D'specialUpdate'");
-            $delsth->execute($biblionumber);
-            $reset_readsth =3D 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.=20
-            $readsth->finish();
-            $readsth->execute();
-        }
-    }
-}
-
-sub zebrado {
-   =20
-    ###Accepts a $server variable thus we can use it to update  biblios, a=
uthorities or other zebra dbs
-    my ($record,$op,$server,$biblionumber)=3D at _;
-   =20
-    my @port;
-   =20
-    my $tried=3D0;
-    my $recon=3D0;
-    my $reconnect=3D0;
-#    $record=3DEncode::encode("UTF-8",$record);
-    my $shadow=3D$server."shadow";
-    $op =3D 'recordDelete' if $op eq 'delete_record';
-reconnect:
-   =20
-    my $Zconn=3DC4::Context->Zconn($server, 0, 1);
-    if ($record){
-        print "updating $op on $biblionumber for server $server\n $record\=
n" if $verbose;
-        my $Zpackage =3D $Zconn->package();
-        $Zpackage->option(action =3D> $op);
-        $Zpackage->option(record =3D> $record);
-# =09    $Zpackage->option(recordIdOpaque =3D> $biblionumber) if $biblionu=
mber;
-retry:
-        $Zpackage->send("update");
-        my($error, $errmsg, $addinfo, $diagset) =3D $Zconn->error_x();
-        if ($error=3D=3D10007 && $tried<3) {## timeout --another 30 looonn=
g seconds for this update
-            print "error 10007\n" if $verbose;
-            sleep 1;=09##  wait a sec!
-            $tried=3D$tried+1;
-            goto "retry";
-        }elsif ($error=3D=3D2 && $tried<2) {## timeout --temporary zebra e=
rror !whatever that means
-            print "error 2\n" if $verbose;
-            sleep 2;=09##  wait two seconds!
-            $tried=3D$tried+1;
-            goto "retry";
-        }elsif($error=3D=3D10004 && $recon=3D=3D0){##Lost connection -reco=
nnect
-            print "error 10004\n" if $verbose;
-            sleep 1;=09##  wait a sec!
-            $recon=3D1;
-            $Zpackage->destroy();
-            $Zconn->destroy();
-            goto "reconnect";
-        }elsif ($error){
-        #=09warn "Error-$server   $op  /errcode:, $error, /MSG:,$errmsg,$a=
ddinfo \n";=09
-            print "error $error\n" if $verbose;
-            $Zpackage->destroy();
-            $Zconn->destroy();
-            return 0;
-        }
-        $Zpackage->send('commit');
-#     $Zpackage->destroy();
-#     $Zconn->destroy();
-    return 1;
-    }
-    return 0;
-}
--=20
1.7.11.4


------=_Part_3823_196734.1345573016075--



More information about the Koha-patches mailing list