git-remote-mediawiki: bugfix for pages w/ >500 revisions
Mediawiki introduces a new API for queries w/ more than 500 results in version 1.21. That change triggered an infinite loop while cloning a mediawiki with such a page. The latest API renamed and moved the "continuing" information in the response, necessary to build the next query. The code failed to retrieve that information but still detected that it was in a "continuing query". As a result, it launched the same query over and over again. If a "continuing" information is detected in the response (old or new), the next query is updated accordingly. If not, we quit assuming it's not a continuing query. Reported-by: Benjamin Cathey Signed-off-by: Benoit Person <benoit.person@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
This commit is contained in:

committed by
Jonathan Nieder

parent
a0d3f1090d
commit
1d905f74fd
@ -622,6 +622,9 @@ sub fetch_mw_revisions_for_page {
|
||||
rvstartid => $fetch_from,
|
||||
rvlimit => 500,
|
||||
pageids => $id,
|
||||
|
||||
# Let MediaWiki know that we support the latest API.
|
||||
continue => '',
|
||||
};
|
||||
|
||||
my $revnum = 0;
|
||||
@ -637,8 +640,15 @@ sub fetch_mw_revisions_for_page {
|
||||
push(@page_revs, $page_rev_ids);
|
||||
$revnum++;
|
||||
}
|
||||
last if (!$result->{'query-continue'});
|
||||
$query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
|
||||
|
||||
if ($result->{'query-continue'}) { # For legacy APIs
|
||||
$query->{rvstartid} = $result->{'query-continue'}->{revisions}->{rvstartid};
|
||||
} elsif ($result->{continue}) { # For newer APIs
|
||||
$query->{rvstartid} = $result->{continue}->{rvcontinue};
|
||||
$query->{continue} = $result->{continue}->{continue};
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
if ($shallow_import && @page_revs) {
|
||||
print {*STDERR} " Found 1 revision (shallow import).\n";
|
||||
|
Reference in New Issue
Block a user