git-remote-mediawiki: be more defensive when requests fail
authorMatthieu Moy <Matthieu.Moy@imag.fr>
Fri, 6 Jul 2012 10:03:15 +0000 (12:03 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Jul 2012 19:20:46 +0000 (12:20 -0700)
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/mw-to-git/git-remote-mediawiki
index 6bf1d1ad4490c9b8772e33e173672da92cb5a55b..ff9384e91bb76560f5d0f0a4275a014cd0171041 100755 (executable)
@@ -912,6 +912,14 @@ sub mw_import_revids {
 
                my $result = $mediawiki->api($query);
 
+               if (!$result) {
+                       die "Failed to retrieve modified page for revision $pagerevid";
+               }
+
+               if (!defined($result->{query}->{pages})) {
+                       die "Invalid revision $pagerevid.";
+               }
+
                my @result_pages = values(%{$result->{query}->{pages}});
                my $result_page = $result_pages[0];
                my $rev = $result_pages[0]->{revisions}->[0];