Since moving to MediaWiki 1.18, several of our extensions that use namespaces 
have broken in the following way. Any advice/explanation would be very much 
appreciated! (I don't see anything in the release notes.)

Some of our extensions contain logic like this:

  if ($wgTitle->getNamespace() == NS_FOO) { .... }

The problem occurs when an article in the main namespace redirects to the Foo 
namespace:

  #REDIRECT [[Foo:Bar]]

When the user hits this redirect in 1.17 and earlier, the above test returned 
True. In 1.18 it returns False, and I've had to replace it with more complex 
logic to follow the redirect:

if ($wgTitle)
  if ($wgTitle->getNamespace() == NS_FOO) {
    // Really in the User namespace
    $fooPageTitle = $wgTitle;
  } elseif ($wgTitle->isRedirect()) {
    $wikiPage = WikiPage::factory($wgTitle);
    if ($wikiPage) {
      $t = $wikiPage->getRedirectTarget();
      if ($t && $t->getNamespace() == NS_FOO) {
        $fooPageTitle = $t;
      }
    }
  }
}

Am I doing something wrong, or is this a bug?  What's the right way to detect 
the namespace of a title, automatically following redirects, as used to work in 
1.17?

Thanks,
DanB 

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to