From ca0031fb1e6f5605c7bb78b9531c44f3040eacf2 Mon Sep 17 00:00:00 2001 From: Bo Adler Date: Sat, 23 Jul 2011 09:11:14 -0700 Subject: [PATCH] wtapi: better error handling when revision doesn't exist --- remote/analysis/WikiTrust.pm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/remote/analysis/WikiTrust.pm b/remote/analysis/WikiTrust.pm index 77713ad..210ca9a 100644 --- a/remote/analysis/WikiTrust.pm +++ b/remote/analysis/WikiTrust.pm @@ -374,7 +374,15 @@ sub handle_wikimarkup { . "LIMIT 1") || die $dbh->errstr; $sth->execute($rev) || die $dbh->errstr; my $ans = $sth->fetchrow_hashref(); - $ans = { } if !defined $ans; + if (!defined $ans) { + $json->{error} = "Revision found in wikitrust revision."; + # Return a 'caching' value so that we don't make an + # extra query to the db for text that doesn't exist, + # but don't forget that we should add this page to the queue. + mark_for_coloring($page, $page_title, $dbh); + return 10; + } + $ans->{user_id} = 0 if !exists $ans->{user_id}; $json->{Anon} = ($ans->{user_id} == 0 ? JSON::true : JSON::false); foreach my $k (keys %$ans) {