Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -449,8 +449,6 @@ |
450 | 450 | } |
451 | 451 | |
452 | 452 | protected function getMicrosoftSuggestion( $serviceName, $config ) { |
453 | | - global $wgMemc; |
454 | | - |
455 | 453 | $this->mustHaveDefinition(); |
456 | 454 | self::checkTranslationServiceFailure( $serviceName ); |
457 | 455 | |
— | — | @@ -459,7 +457,7 @@ |
460 | 458 | $definition = self::wrapUntranslatable( $definition ); |
461 | 459 | |
462 | 460 | $memckey = wfMemckey( 'translate-tmsug-badcodes-' . $serviceName ); |
463 | | - $unsupported = $wgMemc->get( $memckey ); |
| 461 | + $unsupported = wfGetCache( CACHE_ANYTHING )->get( $memckey ); |
464 | 462 | |
465 | 463 | if ( isset( $unsupported[$code] ) ) { |
466 | 464 | return null; |
— | — | @@ -496,7 +494,7 @@ |
497 | 495 | $error = $req->getContent(); |
498 | 496 | if ( strpos( $error, 'must be a valid language' ) !== false ) { |
499 | 497 | $unsupported[$code] = true; |
500 | | - $wgMemc->set( $memckey, $unsupported, 60 * 60 * 8 ); |
| 498 | + wfGetCache( CACHE_ANYTHING )->set( $memckey, $unsupported, 60 * 60 * 8 ); |
501 | 499 | return null; |
502 | 500 | } |
503 | 501 | |
— | — | @@ -531,8 +529,6 @@ |
532 | 530 | } |
533 | 531 | |
534 | 532 | protected function getApertiumSuggestion( $serviceName, $config ) { |
535 | | - global $wgMemc; |
536 | | - |
537 | 533 | self::checkTranslationServiceFailure( $serviceName ); |
538 | 534 | |
539 | 535 | $page = $this->handle->getKey(); |
— | — | @@ -540,7 +536,7 @@ |
541 | 537 | $ns = $this->handle->getTitle()->getNamespace(); |
542 | 538 | |
543 | 539 | $memckey = wfMemckey( 'translate-tmsug-pairs-' . $serviceName ); |
544 | | - $pairs = $wgMemc->get( $memckey ); |
| 540 | + $pairs = wfGetCache( CACHE_ANYTHING )->get( $memckey ); |
545 | 541 | |
546 | 542 | if ( !$pairs ) { |
547 | 543 | |
— | — | @@ -564,7 +560,7 @@ |
565 | 561 | $pairs[$target][$source] = true; |
566 | 562 | } |
567 | 563 | |
568 | | - $wgMemc->set( $memckey, $pairs, 60 * 60 * 24 ); |
| 564 | + wfGetCache( CACHE_ANYTHING )->set( $memckey, $pairs, 60 * 60 * 24 ); |
569 | 565 | } |
570 | 566 | |
571 | 567 | if ( isset( $config['codemap'][$code] ) ) { |
— | — | @@ -1258,10 +1254,8 @@ |
1259 | 1255 | * @return bool |
1260 | 1256 | */ |
1261 | 1257 | public static function checkTranslationServiceFailure( $service ) { |
1262 | | - global $wgMemc; |
1263 | | - |
1264 | 1258 | $key = wfMemckey( "translate-service-$service" ); |
1265 | | - $value = $wgMemc->get( $key ); |
| 1259 | + $value = wfGetCache( CACHE_ANYTHING )->get( $key ); |
1266 | 1260 | if ( !is_string( $value ) ) { |
1267 | 1261 | return false; |
1268 | 1262 | } |
— | — | @@ -1271,7 +1265,7 @@ |
1272 | 1266 | if ( $count >= self::$serviceFailureCount ) { |
1273 | 1267 | error_log( "Translation service $service (was) restored" ); |
1274 | 1268 | } |
1275 | | - $wgMemc->delete( $key ); |
| 1269 | + wfGetCache( CACHE_ANYTHING )->delete( $key ); |
1276 | 1270 | return false; |
1277 | 1271 | } elseif ( $failed + self::$serviceFailurePeriod < wfTimestamp() ) { |
1278 | 1272 | /* We are in suspicious mode and one failure is enough to update |
— | — | @@ -1291,10 +1285,8 @@ |
1292 | 1286 | * @param $service |
1293 | 1287 | */ |
1294 | 1288 | public static function reportTranslationServiceFailure( $service ) { |
1295 | | - global $wgMemc; |
1296 | | - |
1297 | 1289 | $key = wfMemckey( "translate-service-$service" ); |
1298 | | - $value = $wgMemc->get( $key ); |
| 1290 | + $value = wfGetCache( CACHE_ANYTHING )->get( $key ); |
1299 | 1291 | if ( !is_string( $value ) ) { |
1300 | 1292 | $count = 0; |
1301 | 1293 | } else { |
— | — | @@ -1303,7 +1295,7 @@ |
1304 | 1296 | |
1305 | 1297 | $count += 1; |
1306 | 1298 | $failed = wfTimestamp(); |
1307 | | - $wgMemc->set( $key, "$count|$failed", self::$serviceFailurePeriod * 5 ); |
| 1299 | + wfGetCache( CACHE_ANYTHING )->set( $key, "$count|$failed", self::$serviceFailurePeriod * 5 ); |
1308 | 1300 | |
1309 | 1301 | if ( $count == self::$serviceFailureCount ) { |
1310 | 1302 | error_log( "Translation service $service suspended" ); |