[Koha-patches] [PATCH] Bug 2959 - Add a timeout parameter to the URL checker

Frédéric Demians f.demians at tamil.fr
Mon Feb 15 08:14:25 CET 2010


Could improve performances for DB containing URLs which can't be fetched
(good or bad) quickly.
---
 misc/cronjobs/check-url.pl |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/misc/cronjobs/check-url.pl b/misc/cronjobs/check-url.pl
index 9700c98..c2f4b5c 100755
--- a/misc/cronjobs/check-url.pl
+++ b/misc/cronjobs/check-url.pl
@@ -74,9 +74,11 @@ use C4::Biblio;
 sub new {
 
     my $self = {};
-    my $class = shift;
+    my ($class, $timeout) = @_;
     
-    $self->{ user_agent } = new LWP::UserAgent;
+    my $uagent = new LWP::UserAgent;
+    $uagent->timeout( $timeout) if $timeout;
+    $self->{ user_agent } = $uagent;
     $self->{ bad_url    } = { };
     
     bless $self, $class;
@@ -143,12 +145,14 @@ my $host        = '';
 my $host_pro    = '';
 my $html        = 0;
 my $uriedit     = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=";
+my $timeout     = 15;
 GetOptions( 
     'verbose'       => \$verbose,
     'html'          => \$html,
     'help'          => \$help,
     'host=s'        => \$host,
     'host-pro=s'    => \$host_pro,
+    'timeout=i',    => \$timeout,
 );
 
 
@@ -169,7 +173,7 @@ sub bibediturl {
 # Check all URLs from all current Koha biblio records
 #
 sub check_all_url {
-    my $checker = C4::URL::Checker->new();
+    my $checker = C4::URL::Checker->new($timeout);
     $checker->{ host_default }  = $host;
     
     my $context = new C4::Context(  );  
@@ -259,6 +263,10 @@ record in edit mode. With this parameter B<--host-pro> is required.
 
 Server host used to link to biblio record editing page.
 
+=item B<--timeout=15>
+
+Timeout for fetching URLs. By default 15 seconds.
+
 =item B<--help|-h>
 
 Print this help page.
-- 
1.6.4.3




More information about the Koha-patches mailing list