Index: branches/wmf/1.18wmf1/includes/Export.php |
— | — | @@ -476,7 +476,7 @@ |
477 | 477 | function openPage( $row ) { |
478 | 478 | $out = " <page>\n"; |
479 | 479 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
480 | | - $out .= ' ' . Xml::elementClean( 'title', array(), $title->getPrefixedText() ) . "\n"; |
| 480 | + $out .= ' ' . Xml::elementClean( 'title', array(), self::canonicalTitle( $title ) ) . "\n"; |
481 | 481 | $out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n"; |
482 | 482 | if ( $row->page_is_redirect ) { |
483 | 483 | $out .= ' ' . Xml::element( 'redirect', array() ) . "\n"; |
— | — | @@ -590,7 +590,7 @@ |
591 | 591 | $out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n"; |
592 | 592 | } else { |
593 | 593 | $title = Title::makeTitle( $row->log_namespace, $row->log_title ); |
594 | | - $out .= " " . Xml::elementClean( 'logtitle', null, $title->getPrefixedText() ) . "\n"; |
| 594 | + $out .= " " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n"; |
595 | 595 | $out .= " " . Xml::elementClean( 'params', |
596 | 596 | array( 'xml:space' => 'preserve' ), |
597 | 597 | strval( $row->log_params ) ) . "\n"; |
— | — | @@ -672,6 +672,29 @@ |
673 | 673 | " </upload>\n"; |
674 | 674 | } |
675 | 675 | |
| 676 | + /** |
| 677 | + * Return prefixed text form of title, but using the content language's |
| 678 | + * canonical namespace. This skips any special-casing such as gendered |
| 679 | + * user namespaces -- which while useful, are not yet listed in the |
| 680 | + * XML <siteinfo> data so are unsafe in export. |
| 681 | + * |
| 682 | + * @param Title $title |
| 683 | + * @return string |
| 684 | + */ |
| 685 | + public static function canonicalTitle( Title $title ) { |
| 686 | + if ( $title->getInterwiki() ) { |
| 687 | + return $title->getPrefixedText(); |
| 688 | + } |
| 689 | + |
| 690 | + global $wgContLang; |
| 691 | + $prefix = $wgContLang->getNsText( $title->getNamespace() ); |
| 692 | + |
| 693 | + if ($prefix !== '') { |
| 694 | + $prefix .= ':'; |
| 695 | + } |
| 696 | + |
| 697 | + return $prefix . $title->getText(); |
| 698 | + } |
676 | 699 | } |
677 | 700 | |
678 | 701 | |