Bug 15188 - Fixes remove_unused_authorities.pl will delete all authorities if zebra...
authorAlex Arnaud <alex.arnaud@biblibre.com>
Tue, 29 Dec 2015 15:46:38 +0000 (16:46 +0100)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Wed, 27 Jan 2016 01:03:05 +0000 (01:03 +0000)
Test plan:

1) Shut down zebra: koha-zebra-ctl.sh stop
2) Execute the script: remove_unused_authorities.pl (with -t if you don't want to really delete from your database).
3) Check that the script would have deleted all the authorities (eg: 31449 authorities parsed, 31449 deleted and 0 unchanged because used).
4) Apply patch
5) Run, notice that the script dies because zebra is unavailable

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>

misc/migration_tools/remove_unused_authorities.pl

index 2509318..af8897a 100755 (executable)
@@ -45,6 +45,10 @@ if ($test) {
     print "testing only, authorities will not be deleted.\n";
 }
 
+if (C4::Context->Zconn("biblioserver",0)->errcode() == 10000) {
+    die "Zebra server seems not to be available. This script needs Zebra runs."
+}
+
 my $dbh=C4::Context->dbh;
 my $thresholdmin=0;
 my $thresholdmax=0;