r68476 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68475‎ | r68476 | r68477 >
Date:19:03, 23 June 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Allow overriding the cache directory location with $wgTranslateCacheDirectory
Modified paths:
  • /trunk/extensions/Translate/TranslateUtils.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageGroupCache.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageIndexRebuilder.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/utils/MessageIndexRebuilder.php
@@ -41,7 +41,7 @@
4242
4343 global $wgCacheDirectory;
4444
45 - $filename = "$wgCacheDirectory/translate_messageindex.cdb";
 45+ $filename = TranslateUtils::cacheFile( 'translate_messageindex.cdb' );
4646
4747 $writer = CdbWriter::open( $filename );
4848 $writer->set( 'map', serialize( $hugearray ) );
Index: trunk/extensions/Translate/utils/MessageGroupCache.php
@@ -67,9 +67,7 @@
6868 }
6969
7070 protected function getCacheFileName( $code ) {
71 - global $wgCacheDirectory;
72 -
73 - return "$wgCacheDirectory/translate_groupcache-{$this->group}-$code.cdb";
 71+ return TranslateUtils::cacheFile( "translate_groupcache-{$this->group}-$code.cdb" );
7472 }
7573
7674 protected function specialKey( $key ) {
Index: trunk/extensions/Translate/TranslateUtils.php
@@ -223,8 +223,7 @@
224224 }
225225
226226 public static function messageIndex() {
227 - global $wgCacheDirectory;
228 - $filename = "$wgCacheDirectory/translate_messageindex.cdb";
 227+ $filename = self::cacheFile( 'translate_messageindex.cdb' );
229228 if ( !file_exists( $filename ) ) MessageIndexRebuilder::execute();
230229
231230 if ( file_exists( $filename ) ) {
@@ -287,6 +286,23 @@
288287 return "$wgExtensionAssetsPath/Translate/$path";
289288 }
290289
 290+ /**
 291+ * Gets the path for cache files
 292+ */
 293+ public static function cacheFile( $filename ) {
 294+ global $wgTranslateCacheDirectory, $wgCacheDirectory;
 295+
 296+ if ( $wgTranslateCacheDirectory !== false ) {
 297+ $dir = $wgTranslateCacheDirectory;
 298+ } elseif ( $wgCacheDirectory !== false ) {
 299+ $dir = $wgCacheDirectory;
 300+ } else {
 301+ throw new MWException( "\$wgCacheDirectory must be configured" );
 302+ }
 303+
 304+ return "$dir/$filename";
 305+ }
 306+
291307 public static function snippet( &$text, $length = 10 ) {
292308 global $wgLegalTitleChars, $wgContLang;
293309

Follow-up revisions

RevisionCommit summaryAuthorDate
r68477Follow-up to r68476, missed this filenikerabbit19:04, 23 June 2010

Status & tagging log