Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/234839
Change subject: Converted api-token store to CentralAuthUser::getSessionCache() ...................................................................... Converted api-token store to CentralAuthUser::getSessionCache() Bug: T108253 Change-Id: I4d42aa2135c7d2b8ace3084d80c317a0a024ceff --- M includes/CentralAuthHooks.php M includes/CentralAuthUser.php M includes/api/ApiCentralAuthToken.php 3 files changed, 13 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth refs/changes/39/234839/1 diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php index d1fc927..f8741d1 100644 --- a/includes/CentralAuthHooks.php +++ b/includes/CentralAuthHooks.php @@ -260,17 +260,18 @@ return null; } - global $wgRequest, $wgMemc; + global $wgRequest; static $cachedUser = false; + $cache = CentralAuthUser::getSessionCache(); if ( $cachedUser === false ) { $loginToken = $wgRequest->getVal( 'centralauthtoken' ); $key = CentralAuthUser::memcKey( 'api-token', $loginToken ); $cachedUser = null; - $data = $wgMemc->get( $key ); + $data = $cache->get( $key ); if ( $invalidateToken ) { - $wgMemc->delete( $key ); + $cache->delete( $key ); } if ( !is_array( $data ) ) { return null; @@ -302,7 +303,7 @@ } elseif ( $invalidateToken ) { $loginToken = $wgRequest->getVal( 'centralauthtoken' ); $key = CentralAuthUser::memcKey( 'api-token', $loginToken ); - $wgMemc->delete( $key ); + $cache->delete( $key ); } return $cachedUser; @@ -1741,14 +1742,16 @@ if ( !$wgUser->isAnon() && !self::hasApiToken() ) { $centralUser = CentralAuthUser::getInstance( $wgUser ); if ( $centralUser->exists() && $centralUser->isAttached() ) { + $loginToken = MWCryptRand::generateHex( 32 ) . dechex( $centralUser->getId() ); + $data = array( 'userName' => $wgUser->getName(), 'token' => $centralUser->getAuthToken(), ); - global $wgMemc; - $loginToken = MWCryptRand::generateHex( 32 ) . dechex( $centralUser->getId() ); + $key = CentralAuthUser::memcKey( 'api-token', $loginToken ); - $wgMemc->add( $key, $data, 60 ); + CentralAuthUser::getSessionCache()->add( $key, $data, 60 ); + return $loginToken; } } diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php index e7e4cf2..bbff277 100644 --- a/includes/CentralAuthUser.php +++ b/includes/CentralAuthUser.php @@ -2822,7 +2822,7 @@ /** * @return BagOStuff */ - private static function getSessionCache() { + public static function getSessionCache() { global $wgSessionsInObjectCache, $wgSessionCacheType; return $wgSessionsInObjectCache diff --git a/includes/api/ApiCentralAuthToken.php b/includes/api/ApiCentralAuthToken.php index dc0127b..2b1bd3b 100644 --- a/includes/api/ApiCentralAuthToken.php +++ b/includes/api/ApiCentralAuthToken.php @@ -59,10 +59,10 @@ 'userName' => $user->getName(), 'token' => $centralUser->getAuthToken(), ); - global $wgMemc; + $loginToken = MWCryptRand::generateHex( 32 ) . dechex( $centralUser->getId() ); $key = CentralAuthUser::memcKey( 'api-token', $loginToken ); - $wgMemc->add( $key, $data, 60 ); + CentralAuthUser::getSessionCache()->add( $key, $data, 60 ); $this->getResult()->addValue( null, $this->getModuleName(), array( 'centralauthtoken' => $loginToken -- To view, visit https://gerrit.wikimedia.org/r/234839 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4d42aa2135c7d2b8ace3084d80c317a0a024ceff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CentralAuth Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits