Avoid usage of deprecated ObjectCache::getMainWANInstance()

Replacement with services made available in 1.28 and this extension
requires 1.31. So, the replacement is good.

Change-Id: I1960a36541c9578abc3178a3a5ddcac7c32b8292
This commit is contained in:
Derick Alangi 2019-07-03 13:52:16 +01:00
parent 3d81e121f1
commit 4d939a399a
2 changed files with 7 additions and 5 deletions

View file

@ -1,5 +1,7 @@
<?php
use MediaWiki\MediaWikiServices;
/**
* Base class for different kinds of blacklists
*/
@ -234,7 +236,7 @@ abstract class BaseBlacklist {
public function getLocalBlacklists() {
$that = $this;
$type = $this->getBlacklistType();
$cache = ObjectCache::getMainWANInstance();
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
$cache->makeKey( 'spamblacklist', $type, 'blacklist-regex' ),
@ -253,7 +255,7 @@ abstract class BaseBlacklist {
public function getWhitelists() {
$that = $this;
$type = $this->getBlacklistType();
$cache = ObjectCache::getMainWANInstance();
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
$cache->makeKey( 'spamblacklist', $type, 'whitelist-regex' ),
@ -282,7 +284,7 @@ abstract class BaseBlacklist {
$miss = false;
$that = $this;
$cache = ObjectCache::getMainWANInstance();
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$regexes = $cache->getWithSetCallback(
// This used to be cached per-site, but that could be bad on a shared
// server where not all wikis have the same configuration.
@ -307,7 +309,7 @@ abstract class BaseBlacklist {
public function clearCache() {
$listType = $this->getBlacklistType();
$cache = ObjectCache::getMainWANInstance();
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$cache->delete( $cache->makeKey( 'spamblacklist', $listType, 'shared-blacklist-regex' ) );
$cache->delete( $cache->makeKey( 'spamblacklist', $listType, 'blacklist-regex' ) );
$cache->delete( $cache->makeKey( 'spamblacklist', $listType, 'whitelist-regex' ) );

View file

@ -271,7 +271,7 @@ class SpamBlacklist extends BaseBlacklist {
* @return array
*/
public function getCurrentLinks( Title $title ) {
$cache = ObjectCache::getMainWANInstance();
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$fname = __METHOD__;
return $cache->getWithSetCallback(
// Key is warmed via warmCachesForFilter() from ApiStashEdit