Index: trunk/extensions/Translate/utils/MessageIndexRebuilder.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | |
43 | 43 | global $wgCacheDirectory; |
44 | 44 | |
45 | | - $filename = "$wgCacheDirectory/translate_messageindex.cdb"; |
| 45 | + $filename = TranslateUtils::cacheFile( 'translate_messageindex.cdb' ); |
46 | 46 | |
47 | 47 | $writer = CdbWriter::open( $filename ); |
48 | 48 | $writer->set( 'map', serialize( $hugearray ) ); |
Index: trunk/extensions/Translate/utils/MessageGroupCache.php |
— | — | @@ -67,9 +67,7 @@ |
68 | 68 | } |
69 | 69 | |
70 | 70 | 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" ); |
74 | 72 | } |
75 | 73 | |
76 | 74 | protected function specialKey( $key ) { |
Index: trunk/extensions/Translate/TranslateUtils.php |
— | — | @@ -223,8 +223,7 @@ |
224 | 224 | } |
225 | 225 | |
226 | 226 | public static function messageIndex() { |
227 | | - global $wgCacheDirectory; |
228 | | - $filename = "$wgCacheDirectory/translate_messageindex.cdb"; |
| 227 | + $filename = self::cacheFile( 'translate_messageindex.cdb' ); |
229 | 228 | if ( !file_exists( $filename ) ) MessageIndexRebuilder::execute(); |
230 | 229 | |
231 | 230 | if ( file_exists( $filename ) ) { |
— | — | @@ -287,6 +286,23 @@ |
288 | 287 | return "$wgExtensionAssetsPath/Translate/$path"; |
289 | 288 | } |
290 | 289 | |
| 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 | + |
291 | 307 | public static function snippet( &$text, $length = 10 ) { |
292 | 308 | global $wgLegalTitleChars, $wgContLang; |
293 | 309 | |