From: Bill Erickson Date: Thu, 9 Aug 2012 18:58:41 +0000 (-0400) Subject: URLVerify.pm; avoid re-processing same url within the same attempt X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1cd7fd1ef4b860833acf20f5eca3f9f5f4b45cb2;p=evergreen%2Fequinox.git URLVerify.pm; avoid re-processing same url within the same attempt Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm index adb4c02d23..8ea98d5a89 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/URLVerify.pm @@ -56,7 +56,6 @@ sub validate_session { $options ||= {}; # loop through list of URLs / session URLs - # TODO: see if we've already tested the url, if so copy the status info / redirect_to info and move on # add a sleep (org setting) to the multisession handler # TODO: Avoid testing URLs having the same domain sequentially @@ -402,6 +401,34 @@ sub collect_verify_attempt_and_settings { ); } + +# finds the url_verfication for any url processed within this +# verification attempt whose full_url matches the full_url of +# the provided URL. +sub find_matching_url_for_attempt { + my ($e, $attempt, $url) = @_; + + my $match = $e->json_query({ + select => {uvuv => ['id']}, + from => { + uvuv => { + uvva => {}, # attempt + uvu => {} # url + } + }, + where => { + '+uvu' => { + id => {'!=' => $url->id}, + full_url => $url->full_url + } + } + })->[0]; + + return $e->retrieve_url_verify_url_verification($match->{id}) if $match; + return undef; +} + + =head comment 1. create the verification object and commit. @@ -428,9 +455,20 @@ sub verify_one_url { # begin phase-I DB communication $e->xact_begin; + + my $match_vcation = find_matching_url_for_attempt($e, $attempt, $url); + + if ($match_vcation) { + $logger->info("url: found matching URL in verification attempt [$url_text]"); + $vcation->redirect_to($match_vcation->url); + } + $e->create_url_verify_url_verification($vcation) or return $e->die_event; $e->xact_commit; + # found a matching URL, no need to re-process + return {verification => $vcation} if $match_vcation; + # End phase-I DB communication # No active DB xact means no cstore timeout concerns.