Re: [PATCH 4/4] remote-mediawiki: allow using (Main) as a namespace and skip special namespaces
- From
Antoine Beaupré <anarcat@debian.org>
- Date
- Oct 30, 2017, 02:43 UTC
- Message-ID
- <87y3nt73uy.fsf@curie.anarc.at>
- In-Reply-To
- <CAPig+cSTp1Udo6xXk5-L6MpWBdiy4sPO__NcND03-89EvRgLHQ@mail.gmail.com>
On 2017-10-29 15:49:28, Eric Sunshine wrote: [...]
Show 28 quoted lines
>> Reviewed-by: Antoine Beaupré <anarcat@debian.org>
>> Signed-off-by: Antoine Beaupré <anarcat@debian.org>
>> ---
>> diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
>> @@ -264,16 +264,27 @@ sub get_mw_tracked_categories {
>> sub get_mw_tracked_namespaces {
>> my $pages = shift;
>> - foreach my $local_namespace (@tracked_namespaces) {
>> - my $mw_pages = $mediawiki->list( {
>> - action => 'query',
>> - list => 'allpages',
>> - apnamespace => get_mw_namespace_id($local_namespace),
>> - aplimit => 'max' } )
>> - || die $mediawiki->{error}->{code} . ': '
>> - . $mediawiki->{error}->{details} . "\n";
>> - foreach my $page (@{$mw_pages}) {
>> - $pages->{$page->{title}} = $page;
>> + foreach my $local_namespace (sort @tracked_namespaces) {
>> + my ($mw_pages, $namespace_id);
>> + if ($local_namespace eq "(Main)") {
>> + $namespace_id = 0;
>> + } else {
>> + $namespace_id = get_mw_namespace_id($local_namespace);
>> + }
>> + if ($namespace_id >= 0) {
>
> This may be problematic since get_mw_namespace_id() may return undef
> rather than a number, in which case Perl will complain.[...]
Actually, get_mw_namespace_id() doesn't seem like it can return undef - did you mistake it with get_mw_namespace_id_for_page()?
A.
--
Uncompromising war resistance and refusal to do military service under
any circumstances.
- Albert Einstein