if ( $target->isExternal() ) {
$key .= $target->getInterwiki() . ':';
}
- $nsName = $this->getNamespaceName(
- $target->getNamespace(),
- $target->getText()
- );
+ // Try to get a namespace name, but fallback
+ // to empty string if it doesn't exist
+ try {
+ $nsName = $this->getNamespaceName(
+ $target->getNamespace(),
+ $target->getText()
+ );
+ } catch ( InvalidArgumentException $e ) {
+ $nsName = '';
+ }
- if ( $nsName !== '' ) {
+ if ( $target->getNamespace() !== 0 ) {
$key .= $nsName . ':';
}
// names ending in "a" to be female.
[ NS_USER, 'Lisa_Müller', '', '', 'de', 'Benutzerin:Lisa_Müller' ],
- [ NS_MAIN, 'Remote_page', '', 'remotetestiw', 'en', 'remotetestiw:Remote_page' ]
+ [ NS_MAIN, 'Remote_page', '', 'remotetestiw', 'en', 'remotetestiw:Remote_page' ],
+
+ // non-existent namespace
+ [ 10000000, 'Foobar', '', '', 'en', ':Foobar' ],
];
}