remote-mediawiki: skip virtual namespaces
Virtual namespaces do not correspond to pages in the database and are automatically generated by MediaWiki. It makes little sense, therefore, to fetch pages from those namespaces and the MW API doesn't support listing those pages. According to the documentation, those virtual namespaces are currently "Special" (-1) and "Media" (-2) but we treat all negative namespaces as "virtual" as a future-proofing mechanism. Signed-off-by: Antoine Beaupré <anarcat@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Antoine Beaupré committed
Nov 7, 2017 at 11:06 UTC
db3364352da98f20915e1b838616688f388fad8b
1 file changed
+4
-1
contrib/mw-to-git/git-remote-mediawiki.perl
+4
-1
@@ -264,10 +264,13 @@ sub get_mw_tracked_categories {
264
sub get_mw_tracked_namespaces {
265
my $pages = shift;
266
foreach my $local_namespace (@tracked_namespaces) {
267
+ my $namespace_id = get_mw_namespace_id($local_namespace);
268
+ # virtual namespaces don't support allpages
269
+ next if !defined($namespace_id) || $namespace_id < 0;
270
my $mw_pages = $mediawiki->list( {
271
action => 'query',
272
list => 'allpages',
270
- apnamespace => get_mw_namespace_id($local_namespace),
273
+ apnamespace => $namespace_id,
274
aplimit => 'max' } )
275
|| die $mediawiki->{error}->{code} . ': '
276
. $mediawiki->{error}->{details} . "\n";