Index: trunk/phase3/includes/Export.php |
— | — | @@ -476,14 +476,14 @@ |
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( 'ns', array(), strval( $row->page_namespace) ) . "\n"; |
482 | 482 | $out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n"; |
483 | 483 | if ( $row->page_is_redirect ) { |
484 | 484 | $page = WikiPage::factory( $title ); |
485 | 485 | $redirect = $page->getRedirectTarget(); |
486 | 486 | if ( $redirect instanceOf Title && $redirect->isValidRedirectTarget() ) { |
487 | | - $out .= ' ' . Xml::element( 'redirect', array( 'title' => $redirect->getPrefixedText() ) ) . "\n"; |
| 487 | + $out .= ' ' . Xml::element( 'redirect', array( 'title' => self::canonicalTitle( $redirect ) ) ) . "\n"; |
488 | 488 | } |
489 | 489 | } |
490 | 490 | if ( $row->page_restrictions != '' ) { |
— | — | @@ -595,7 +595,7 @@ |
596 | 596 | $out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n"; |
597 | 597 | } else { |
598 | 598 | $title = Title::makeTitle( $row->log_namespace, $row->log_title ); |
599 | | - $out .= " " . Xml::elementClean( 'logtitle', null, $title->getPrefixedText() ) . "\n"; |
| 599 | + $out .= " " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n"; |
600 | 600 | $out .= " " . Xml::elementClean( 'params', |
601 | 601 | array( 'xml:space' => 'preserve' ), |
602 | 602 | strval( $row->log_params ) ) . "\n"; |
— | — | @@ -677,6 +677,29 @@ |
678 | 678 | " </upload>\n"; |
679 | 679 | } |
680 | 680 | |
| 681 | + /** |
| 682 | + * Return prefixed text form of title, but using the content language's |
| 683 | + * canonical namespace. This skips any special-casing such as gendered |
| 684 | + * user namespaces -- which while useful, are not yet listed in the |
| 685 | + * XML <siteinfo> data so are unsafe in export. |
| 686 | + * |
| 687 | + * @param Title $title |
| 688 | + * @return string |
| 689 | + */ |
| 690 | + public static function canonicalTitle( Title $title ) { |
| 691 | + if ( $title->getInterwiki() ) { |
| 692 | + return $title->getPrefixedText(); |
| 693 | + } |
| 694 | + |
| 695 | + global $wgContLang; |
| 696 | + $prefix = $wgContLang->getNsText( $title->getNamespace() ); |
| 697 | + |
| 698 | + if ($prefix !== '') { |
| 699 | + $prefix .= ':'; |
| 700 | + } |
| 701 | + |
| 702 | + return $prefix . $title->getText(); |
| 703 | + } |
681 | 704 | } |
682 | 705 | |
683 | 706 | |