* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @license GPL 2+
*/
/**
protected function parseTitleWithNs( $title, $ns ) {
$pieces = explode( ':', $title, 2 );
+ // Is $title of the form Namespace:Title (true), or just Title (false)?
+ $titleIncludesNamespace = ( $ns != '0' && count( $pieces ) === 2 );
+
if ( isset( $this->foreignNamespaces[$ns] ) ) {
$namespaceName = $this->foreignNamespaces[$ns];
} else {
- $namespaceName = $ns == '0' ? '' : $pieces[0];
+ // If the foreign wiki is misconfigured, XML dumps can contain a page with
+ // a non-zero namespace ID, but whose title doesn't contain a colon
+ // (T114115). In those cases, output a made-up namespace name to avoid
+ // collisions. The ImportTitleFactory might replace this with something
+ // more appropriate.
+ $namespaceName = $titleIncludesNamespace ? $pieces[0] : "Ns$ns";
}
// We assume that the portion of the page title before the colon is the
- // namespace name, except in the case of namespace 0
- if ( $ns != '0' ) {
+ // namespace name, except in the case of namespace 0.
+ if ( $titleIncludesNamespace ) {
$pageName = $pieces[1];
} else {
$pageName = $title;