From ca55c42a1e887de6485bc1023fb28d168bb17969 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 29 Apr 2015 14:30:22 -0700 Subject: [PATCH] Conversion to using WAN cache Bug: T93141 Change-Id: I67fa3e6e6d348953472a565bdbeccd8298c80f58 --- BaseBlacklist.php | 12 +++++++----- SpamBlacklistHooks.php | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) mode change 100644 => 100755 BaseBlacklist.php mode change 100644 => 100755 SpamBlacklistHooks.php diff --git a/BaseBlacklist.php b/BaseBlacklist.php old mode 100644 new mode 100755 index b1958c35..2e7abe8c --- a/BaseBlacklist.php +++ b/BaseBlacklist.php @@ -221,7 +221,7 @@ abstract class BaseBlacklist { * @return array */ function getSharedBlacklists() { - global $wgMemc, $wgDBname; + global $wgDBname; $listType = $this->getBlacklistType(); wfDebugLog( 'SpamBlacklist', "Loading $listType regex..." ); @@ -232,25 +232,27 @@ abstract class BaseBlacklist { return array(); } + $cache = ObjectCache::getMainWANInstance(); // This used to be cached per-site, but that could be bad on a shared // server where not all wikis have the same configuration. - $cachedRegexes = $wgMemc->get( "$wgDBname:{$listType}_blacklist_regexes" ); + $cachedRegexes = $cache->get( "$wgDBname:{$listType}_blacklist_regexes" ); if( is_array( $cachedRegexes ) ) { wfDebugLog( 'SpamBlacklist', "Got shared spam regexes from cache\n" ); return $cachedRegexes; } $regexes = $this->buildSharedBlacklists(); - $wgMemc->set( "$wgDBname:{$listType}_blacklist_regexes", $regexes, $this->expiryTime ); + $cache->set( "$wgDBname:{$listType}_blacklist_regexes", $regexes, $this->expiryTime ); return $regexes; } function clearCache() { - global $wgMemc, $wgDBname; + global $wgDBname; $listType = $this->getBlacklistType(); - $wgMemc->delete( "$wgDBname:{$listType}_blacklist_regexes" ); + $cache = ObjectCache::getMainWANInstance(); + $cache->delete( "$wgDBname:{$listType}_blacklist_regexes" ); wfDebugLog( 'SpamBlacklist', "$listType blacklist local cache cleared.\n" ); } diff --git a/SpamBlacklistHooks.php b/SpamBlacklistHooks.php old mode 100644 new mode 100755 index 0ceb4fa0..27a2dabb --- a/SpamBlacklistHooks.php +++ b/SpamBlacklistHooks.php @@ -212,11 +212,12 @@ class SpamBlacklistHooks { if( !BaseBlacklist::isLocalSource( $wikiPage->getTitle() ) ) { return true; } - global $wgMemc, $wgDBname; + global $wgDBname; + $cache = ObjectCache::getMainWANInstance(); // This sucks because every Blacklist needs to be cleared foreach ( BaseBlacklist::getBlacklistTypes() as $type => $class ) { - $wgMemc->delete( "$wgDBname:{$type}_blacklist_regexes" ); + $cache->delete( "$wgDBname:{$type}_blacklist_regexes" ); } return true; }