Re: [PATCH 4/4] remote-mediawiki: allow using (Main) as a namespace and skip special namespaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Oct 29, 2017 at 10:11 PM, Antoine Beaupré <anarcat@xxxxxxxxxx> wrote:
> On 2017-10-29 15:49:28, Eric Sunshine wrote:
>> On Sun, Oct 29, 2017 at 12:08 PM, Antoine Beaupré <anarcat@xxxxxxxxxx> wrote:
>>> +    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. Since the code
>> skips the $mediawiki query altogether when it encounters "(Main)", you
>> could fix this problem and simplify the code overall by simply
>> skipping the bulk of the foreach loop body instead of mucking around
>> with $namespace_id. For instance:
>>
>>     foreach my $local_namespace (sort @tracked_namespaces) {
>>         next if ($local_namespace eq "(Main)");
>>         ...normal processing...
>>     }
>
> Ah yes. I see your point but it doesn't actually skip the query when it
> encouters main ($namespace_id >= 0).

Ah, yes, you're right. My brain glossed over the '=' in '>=' for some reason.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux