Thread (71 messages) 71 messages, 4 authors, 2017-11-07

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

From: Eric Sunshine <hidden>
Date: 2017-10-30 03:49:09

On Sun, Oct 29, 2017 at 10:11 PM, Antoine Beaupré [off-list ref] wrote:
On 2017-10-29 15:49:28, Eric Sunshine wrote:
quoted
On Sun, Oct 29, 2017 at 12:08 PM, Antoine Beaupré [off-list ref] wrote:
quoted
+    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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help