*/
public function convertTo( $text, $variant ) {
global $wgDisableLangConversion;
- if ( $wgDisableLangConversion || $this->guessVariant( $text, $variant ) ) {
+ if ( $wgDisableLangConversion ) {
return $text;
}
return $this->recursiveConvertTopLevel( $text, $variant );
$startPos = 0;
$out = '';
$length = strlen( $text );
+ $shouldConvert = !$this->guessVariant( $text, $variant );
+
while ( $startPos < $length ) {
$pos = strpos( $text, '-{', $startPos );
if ( $pos === false ) {
// No more markup, append final segment
- $out .= $this->autoConvert( substr( $text, $startPos ), $variant );
+ $fragment = substr( $text, $startPos );
+ $out .= $shouldConvert? $this->autoConvert( $fragment, $variant ): $fragment;
return $out;
}
// Markup found
// Append initial segment
- $out .= $this->autoConvert( substr( $text, $startPos, $pos - $startPos ), $variant );
+ $fragment = substr( $text, $startPos, $pos - $startPos );
+ $out .= $shouldConvert? $this->autoConvert( $fragment, $variant ): $fragment;
// Advance position
$startPos = $pos;
* @param $fromCache Boolean: load from memcached? Defaults to true.
*/
function loadTables( $fromCache = true ) {
+ global $wgLangConvMemc;
+
if ( $this->mTablesLoaded ) {
return;
}
- global $wgMemc;
+
wfProfileIn( __METHOD__ );
$this->mTablesLoaded = true;
$this->mTables = false;
if ( $fromCache ) {
wfProfileIn( __METHOD__ . '-cache' );
- $this->mTables = $wgMemc->get( $this->mCacheKey );
+ $this->mTables = $wgLangConvMemc->get( $this->mCacheKey );
wfProfileOut( __METHOD__ . '-cache' );
}
if ( !$this->mTables
$this->postLoadTables();
$this->mTables[self::CACHE_VERSION_KEY] = true;
- $wgMemc->set( $this->mCacheKey, $this->mTables, 43200 );
+ $wgLangConvMemc->set( $this->mCacheKey, $this->mTables, 43200 );
wfProfileOut( __METHOD__ . '-recache' );
}
wfProfileOut( __METHOD__ );