r103953 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103952‎ | r103953 | r103954 >
Date:20:19, 22 November 2011
Author:brion
Status:resolved
Tags:
Comment:
MFT r103945: use canonical user NS in export, workaround for search prefix bug 31697 and friends
Modified paths:
  • /branches/REL1_18/phase3/includes/Export.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/includes/Export.php
@@ -476,7 +476,7 @@
477477 function openPage( $row ) {
478478 $out = " <page>\n";
479479 $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";
481481 $out .= ' ' . Xml::element( 'id', array(), strval( $row->page_id ) ) . "\n";
482482 if ( $row->page_is_redirect ) {
483483 $out .= ' ' . Xml::element( 'redirect', array() ) . "\n";
@@ -590,7 +590,7 @@
591591 $out .= " " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
592592 } else {
593593 $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";
595595 $out .= " " . Xml::elementClean( 'params',
596596 array( 'xml:space' => 'preserve' ),
597597 strval( $row->log_params ) ) . "\n";
@@ -672,6 +672,29 @@
673673 " </upload>\n";
674674 }
675675
 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+ }
676699 }
677700
678701

Follow-up revisions

RevisionCommit summaryAuthorDate
r103954MFT r103945: use canonical user NS in export, workaround for search prefix bu...brion20:20, 22 November 2011
r104124Followup r103945: fix regression in XML export namespace formatting for names...brion01:26, 24 November 2011
r104125MFT r104124 (fixes XML export regression in r103945 / r103953 on branch)brion01:29, 24 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103945* (bug 32376) XML export tweak to use canonical user namespaces instead of ge...brion19:33, 22 November 2011

Status & tagging log