From 9ffa4003226c46813dfd6616ce173252b1f258c2 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 21 May 2015 14:54:30 -0700 Subject: [PATCH] Conversion to using getMainStashInstance() Bug: T97620 Change-Id: I7fc2c0a42bf295d71b9e0721ab4261290334cdec --- AbuseFilter.class.php | 6 ++++-- AbuseFilter.hooks.php | 5 +---- Views/AbuseFilterViewRevert.php | 6 +++--- api/ApiAbuseFilterUnblockAutopromote.php | 7 +++---- 4 files changed, 11 insertions(+), 13 deletions(-) mode change 100644 => 100755 AbuseFilter.hooks.php mode change 100644 => 100755 Views/AbuseFilterViewRevert.php mode change 100644 => 100755 api/ApiAbuseFilterUnblockAutopromote.php diff --git a/AbuseFilter.class.php b/AbuseFilter.class.php index fff2ddba4..87f201042 100755 --- a/AbuseFilter.class.php +++ b/AbuseFilter.class.php @@ -1300,10 +1300,12 @@ class AbuseFilter { break; case 'blockautopromote': - global $wgUser, $wgMemc; + global $wgUser; if ( !$wgUser->isAnon() ) { $blockPeriod = (int)mt_rand( 3 * 86400, 7 * 86400 ); // Block for 3-7 days. - $wgMemc->set( self::autoPromoteBlockKey( $wgUser ), true, $blockPeriod ); + ObjectCache::getMainStashInstance()->set( + self::autoPromoteBlockKey( $wgUser ), true, $blockPeriod + ); $message = array( 'abusefilter-autopromote-blocked', diff --git a/AbuseFilter.hooks.php b/AbuseFilter.hooks.php old mode 100644 new mode 100755 index 892d90167..faaafb380 --- a/AbuseFilter.hooks.php +++ b/AbuseFilter.hooks.php @@ -277,11 +277,8 @@ class AbuseFilterHooks { * @return bool */ public static function onGetAutoPromoteGroups( $user, &$promote ) { - global $wgMemc; - $key = AbuseFilter::autoPromoteBlockKey( $user ); - - if ( $wgMemc->get( $key ) ) { + if ( ObjectCache::getMainStashInstance()->get( $key ) ) { $promote = array(); } diff --git a/Views/AbuseFilterViewRevert.php b/Views/AbuseFilterViewRevert.php old mode 100644 new mode 100755 index 941fa6650..c1a773886 --- a/Views/AbuseFilterViewRevert.php +++ b/Views/AbuseFilterViewRevert.php @@ -209,9 +209,9 @@ class AbuseFilterViewRevert extends AbuseFilterView { ); return true; case 'blockautopromote': - global $wgMemc; - $wgMemc->delete( AbuseFilter::autopromoteBlockKey( - User::newFromId( $result['userid'] ) ) ); + ObjectCache::getMainStashInstance()->delete( + AbuseFilter::autopromoteBlockKey( User::newFromId( $result['userid'] ) ) + ); return true; case 'degroup': // Pull the user's groups from the vars. diff --git a/api/ApiAbuseFilterUnblockAutopromote.php b/api/ApiAbuseFilterUnblockAutopromote.php old mode 100644 new mode 100755 index 73d15587c..6b3cb1785 --- a/api/ApiAbuseFilterUnblockAutopromote.php +++ b/api/ApiAbuseFilterUnblockAutopromote.php @@ -15,16 +15,15 @@ class ApiAbuseFilterUnblockAutopromote extends ApiBase { $this->dieUsage( $msg, 'notsuspended' ); } - global $wgMemc; $key = AbuseFilter::autoPromoteBlockKey( $user ); - - if ( !$wgMemc->get( $key ) ) { + $stash = ObjectCache::getMainStashInstance(); + if ( !$stash->get( $key ) ) { // Same as above :( $msg = wfMessage( 'abusefilter-reautoconfirm-none', $params['user'] )->text(); $this->dieUsage( $msg, 'notsuspended' ); } - $wgMemc->delete( $key ); + $stash->delete( $key ); $res = array( 'user' => $params['user'] ); $this->getResult()->addValue( null, $this->getModuleName(), $res );