r104270 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104269‎ | r104270 | r104271 >
Date:15:12, 26 November 2011
Author:ialex
Status:ok
Tags:
Comment:
Fixes for LanguageConverter::parseCachedTable() (seems really broken for subpages at the moment):
* Use Revsion::newFromTitle() to get the text instead of Article, avoids interference with "oldid" URL parameter. Also Article::getContents() (with final "s") does not exist and would throw a fatal error.
* Check if $subpage is empty before using the message cache instead of '/' in $code
* Early return if the page contains no text
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -889,26 +889,26 @@
890890 return array();
891891 }
892892
893 - if ( strpos( $code, '/' ) === false ) {
894 - $txt = MessageCache::singleton()->get( 'Conversiontable', true, $code );
895 - if ( $txt === false ) {
896 - # @todo FIXME: This method doesn't seem to be expecting
897 - # this possible outcome...
898 - $txt = '<Conversiontable>';
899 - }
 893+ $parsed[$key] = true;
 894+
 895+ if ( $subpage === '' ) {
 896+ $txt = MessageCache::singleton()->get( 'conversiontable', true, $code );
900897 } else {
901 - $title = Title::makeTitleSafe(
902 - NS_MEDIAWIKI,
903 - "Conversiontable/$code"
904 - );
 898+ $txt = false;
 899+ $title = Title::makeTitleSafe( NS_MEDIAWIKI, $key );
905900 if ( $title && $title->exists() ) {
906 - $article = new Article( $title );
907 - $txt = $article->getContents();
908 - } else {
909 - $txt = '';
 901+ $revision = Revision::newFromTitle( $title );
 902+ if ( $revision ) {
 903+ $txt = $revision->getRawText();
 904+ }
910905 }
911906 }
912907
 908+ # Nothing to parse if there's no text
 909+ if ( $txt === false || $txt === null || $txt === '' ) {
 910+ return array();
 911+ }
 912+
913913 // get all subpage links of the form
914914 // [[MediaWiki:Conversiontable/zh-xx/...|...]]
915915 $linkhead = $this->mLangObj->getNsText( NS_MEDIAWIKI ) .
@@ -957,7 +957,6 @@
958958 $ret[trim( $m[0] )] = trim( $tt[0] );
959959 }
960960 }
961 - $parsed[$key] = true;
962961
963962 // recursively parse the subpages
964963 if ( $recursive ) {

Status & tagging log