Skip to content

Commit db33643

Browse files
anarcatgitster
authored andcommitted
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>
1 parent 09eebba commit db33643

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

contrib/mw-to-git/git-remote-mediawiki.perl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,13 @@ sub get_mw_tracked_categories {
264264
sub get_mw_tracked_namespaces {
265265
my $pages = shift;
266266
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;
267270
my $mw_pages = $mediawiki->list( {
268271
action => 'query',
269272
list => 'allpages',
270-
apnamespace => get_mw_namespace_id($local_namespace),
273+
apnamespace => $namespace_id,
271274
aplimit => 'max' } )
272275
|| die $mediawiki->{error}->{code} . ': '
273276
. $mediawiki->{error}->{details} . "\n";

0 commit comments

Comments
 (0)