From 84b3c05c0d98fc77f5c859fa084d9491731cb34f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Mon, 15 Feb 2010 08:14:25 +0100 Subject: [PATCH] Bug 2959 - Add a timeout parameter to the URL checker Could improve performances for DB containing URLs which can't be fetched (good or bad) quickly. Signed-off-by: Galen Charlton --- misc/cronjobs/check-url.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/misc/cronjobs/check-url.pl b/misc/cronjobs/check-url.pl index 9700c98729..c2f4b5c3b8 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. -- 2.39.5