diff --git a/includes/AbuseFilter.php b/includes/AbuseFilter.php index c69f1e064..f8d25dcbc 100644 --- a/includes/AbuseFilter.php +++ b/includes/AbuseFilter.php @@ -591,7 +591,7 @@ class AbuseFilter { $globalRulesKey = self::getGlobalRulesKey( $group ); $fname = __METHOD__; - $res = ObjectCache::getMainWANInstance()->getWithSetCallback( + $res = MediaWikiServices::getInstance()->getMainWANObjectCache()->getWithSetCallback( $globalRulesKey, WANObjectCache::TTL_INDEFINITE, function () use ( $group, $fname, $fields ) { @@ -740,7 +740,7 @@ class AbuseFilter { * @param int $filter */ private static function resetFilterProfile( $filter ) { - $stash = ObjectCache::getMainStashInstance(); + $stash = MediaWikiServices::getInstance()->getMainObjectStash(); $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'total' ); $condsKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'conds' ); @@ -758,7 +758,7 @@ class AbuseFilter { public static function recordProfilingResult( $filter, $time, $conds ) { // Defer updates to avoid massive (~1 second) edit time increases DeferredUpdates::addCallableUpdate( function () use ( $filter, $time, $conds ) { - $stash = ObjectCache::getMainStashInstance(); + $stash = MediaWikiServices::getInstance()->getMainObjectStash(); $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'total' ); $condsKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'conds' ); @@ -784,7 +784,7 @@ class AbuseFilter { * @return array */ public static function getFilterProfile( $filter ) { - $stash = ObjectCache::getMainStashInstance(); + $stash = MediaWikiServices::getInstance()->getMainObjectStash(); $countKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'count' ); $totalKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'total' ); $condsKey = wfMemcKey( 'abusefilter', 'profile', $filter, 'conds' ); @@ -1417,7 +1417,7 @@ class AbuseFilter { // To distinguish from stuff stored directly $var_dump = "stored-text:$var_dump"; - $stash = ObjectCache::getMainStashInstance(); + $stash = MediaWikiServices::getInstance()->getMainObjectStash(); // Increment trigger counter $stash->incr( self::filterMatchesKey() ); @@ -1749,7 +1749,7 @@ class AbuseFilter { if ( !$user->isAnon() ) { // Block for 3-7 days. $blockPeriod = (int)mt_rand( 3 * 86400, 7 * 86400 ); - ObjectCache::getMainStashInstance()->set( + MediaWikiServices::getInstance()->getMainObjectStash()->set( self::autoPromoteBlockKey( $user ), true, $blockPeriod ); @@ -1916,7 +1916,7 @@ class AbuseFilter { public static function isThrottled( $throttleId, $types, Title $title, $rateCount, $ratePeriod, $global = false ) { - $stash = ObjectCache::getMainStashInstance(); + $stash = MediaWikiServices::getInstance()->getMainObjectStash(); $key = self::throttleKey( $throttleId, $types, $title, $global ); $count = intval( $stash->get( $key ) ); @@ -2050,7 +2050,7 @@ class AbuseFilter { private static function recordStats( $filters, $group = 'default' ) { global $wgAbuseFilterConditionLimit, $wgAbuseFilterProfileActionsCap; - $stash = ObjectCache::getMainStashInstance(); + $stash = MediaWikiServices::getInstance()->getMainObjectStash(); // Figure out if we've triggered overflows and blocks. $overflow_triggered = ( self::$condCount > $wgAbuseFilterConditionLimit ); @@ -2106,7 +2106,8 @@ class AbuseFilter { * @param string[] $filters The filters to check */ private static function checkEmergencyDisable( $group, $filters ) { - $stash = ObjectCache::getMainStashInstance(); + $stash = MediaWikiServices::getInstance()->getMainObjectStash(); + // @ToDo this is an amount between 1 and AbuseFilterProfileActionsCap, which means that the // reliability of this number may strongly vary. We should instead use a fixed one. $totalActions = $stash->get( self::filterUsedKey( $group ) ); @@ -2648,7 +2649,7 @@ class AbuseFilter { } $globalRulesKey = self::getGlobalRulesKey( $group ); - ObjectCache::getMainWANInstance()->touchCheckKey( $globalRulesKey ); + MediaWikiServices::getInstance()->getMainWANObjectCache()->touchCheckKey( $globalRulesKey ); } // Logging diff --git a/includes/AbuseFilterHooks.php b/includes/AbuseFilterHooks.php index 3d64f37d3..ed6919dcf 100644 --- a/includes/AbuseFilterHooks.php +++ b/includes/AbuseFilterHooks.php @@ -317,7 +317,7 @@ class AbuseFilterHooks { $key, 30, function () use ( $key ) { - return (int)ObjectCache::getMainStashInstance()->get( $key ); + return (int)MediaWikiServices::getInstance()->getMainObjectStash()->get( $key ); } ); diff --git a/includes/Views/AbuseFilterViewEdit.php b/includes/Views/AbuseFilterViewEdit.php index b64d2be08..9b31b2e66 100644 --- a/includes/Views/AbuseFilterViewEdit.php +++ b/includes/Views/AbuseFilterViewEdit.php @@ -1,5 +1,7 @@ getMainObjectStash(); $matches_count = (int)$stash->get( AbuseFilter::filterMatchesKey( $filter ) ); $total = (int)$stash->get( AbuseFilter::filterUsedKey( $row->af_group ) ); diff --git a/includes/Views/AbuseFilterViewList.php b/includes/Views/AbuseFilterViewList.php index ad92ad6c7..c0e99cd21 100644 --- a/includes/Views/AbuseFilterViewList.php +++ b/includes/Views/AbuseFilterViewList.php @@ -1,5 +1,7 @@ getMainObjectStash(); $overflow_count = (int)$stash->get( AbuseFilter::filterLimitReachedKey() ); $match_count = (int)$stash->get( AbuseFilter::filterMatchesKey() ); $total_count = 0; diff --git a/includes/Views/AbuseFilterViewRevert.php b/includes/Views/AbuseFilterViewRevert.php index 38a0d0731..d8b1ba9b3 100644 --- a/includes/Views/AbuseFilterViewRevert.php +++ b/includes/Views/AbuseFilterViewRevert.php @@ -1,5 +1,7 @@ publish( $logEntry->insert() ); return true; case 'blockautopromote': - ObjectCache::getMainStashInstance()->delete( + MediaWikiServices::getInstance()->getMainObjectStash()->delete( AbuseFilter::autoPromoteBlockKey( User::newFromId( $result['userid'] ) ) ); return true; diff --git a/includes/api/ApiAbuseFilterUnblockAutopromote.php b/includes/api/ApiAbuseFilterUnblockAutopromote.php index 195e72d33..70165c649 100644 --- a/includes/api/ApiAbuseFilterUnblockAutopromote.php +++ b/includes/api/ApiAbuseFilterUnblockAutopromote.php @@ -1,5 +1,7 @@ getMainObjectStash(); if ( !$stash->get( $key ) ) { $this->dieWithError( [ 'abusefilter-reautoconfirm-none', $user->getName() ], 'notsuspended' ); }