Conversion to using getMainStashInstance()

Bug: T97620
Change-Id: I7fc2c0a42bf295d71b9e0721ab4261290334cdec
This commit is contained in:
Aaron Schulz 2015-05-21 14:54:30 -07:00
parent 86c3502c03
commit 9ffa400322
4 changed files with 11 additions and 13 deletions

View file

@ -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',

5
AbuseFilter.hooks.php Normal file → Executable file
View file

@ -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();
}

6
Views/AbuseFilterViewRevert.php Normal file → Executable file
View file

@ -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.

7
api/ApiAbuseFilterUnblockAutopromote.php Normal file → Executable file
View file

@ -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 );