Merge branch 'new/bug_5307' into kcmaster
[koha_gimpoz] / misc / cronjobs / services_throttle.pl
index 39bf269..cafc517 100755 (executable)
@@ -1,12 +1,21 @@
 #!/usr/bin/perl
-#run nightly -- resets the services throttle
+# run nightly -- resets the xisbn services throttle
 
-use strict; use warnings;
+use strict;
+use warnings;
+
+BEGIN {
+    # find Koha's Perl modules
+    # test carefully before changing this
+    use FindBin;
+    eval { require "$FindBin::Bin/../kohalib.pl" };
+}
 
 use C4::Context;
-my $dbh=C4::Context->dbh;
 my $fixit="UPDATE services_throttle SET service_count=0 WHERE service_type='xisbn'";
-my $sth=$dbh->prepare($fixit);
-my $res = $sth->execute() or die "can't execute";
-print "$res\n"; #did it work?
-$dbh->disconnect();
+my $sth = C4::Context->dbh->prepare($fixit);
+my $res = $sth->execute() or die "cannot execute query: $fixit";
+
+# There is no need to return anything if we succeeded, 
+# and the die message (or other more internal Context/mysql error) 
+# will get emailed to the cron user if we didn't.