session: Avoid deprecated wfMemcKey()
Change-Id: I4d77c2c52ef43cbc54878ce920595befd270a28e
This commit is contained in:
parent
2e553e1967
commit
7e48fdd76f
4 changed files with 15 additions and 13 deletions
|
|
@ -132,7 +132,7 @@ final class SessionBackend {
|
|||
$this->forceHTTPS = $info->forceHTTPS();
|
||||
$this->providerMetadata = $info->getProviderMetadata();
|
||||
|
||||
$blob = $store->get( wfMemcKey( 'MWSession', (string)$this->id ) );
|
||||
$blob = $store->get( $store->makeKey( 'MWSession', (string)$this->id ) );
|
||||
if ( !is_array( $blob ) ||
|
||||
!isset( $blob['metadata'] ) || !is_array( $blob['metadata'] ) ||
|
||||
!isset( $blob['data'] ) || !is_array( $blob['data'] )
|
||||
|
|
@ -249,7 +249,7 @@ final class SessionBackend {
|
|||
$this->autosave();
|
||||
|
||||
// Delete the data for the old session ID now
|
||||
$this->store->delete( wfMemcKey( 'MWSession', $oldId ) );
|
||||
$this->store->delete( $this->store->makeKey( 'MWSession', $oldId ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ final class SessionBackend {
|
|||
|
||||
// Delete the session data, so the local cache-only write in
|
||||
// self::save() doesn't get things out of sync with the backend.
|
||||
$this->store->delete( wfMemcKey( 'MWSession', (string)$this->id ) );
|
||||
$this->store->delete( $this->store->makeKey( 'MWSession', (string)$this->id ) );
|
||||
|
||||
$this->autosave();
|
||||
}
|
||||
|
|
@ -729,7 +729,7 @@ final class SessionBackend {
|
|||
$flags = $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY;
|
||||
$flags |= CachedBagOStuff::WRITE_SYNC; // write to all datacenters
|
||||
$this->store->set(
|
||||
wfMemcKey( 'MWSession', (string)$this->id ),
|
||||
$this->store->makeKey( 'MWSession', (string)$this->id ),
|
||||
[
|
||||
'data' => $this->data,
|
||||
'metadata' => $metadata,
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ final class SessionManager implements SessionManagerInterface {
|
|||
}
|
||||
|
||||
// Test if the session is in storage, and if so try to load it.
|
||||
$key = wfMemcKey( 'MWSession', $id );
|
||||
$key = $this->store->makeKey( 'MWSession', $id );
|
||||
if ( is_array( $this->store->get( $key ) ) ) {
|
||||
$create = false; // If loading fails, don't bother creating because it probably will fail too.
|
||||
if ( $this->loadSessionInfoFromStore( $info, $request ) ) {
|
||||
|
|
@ -255,7 +255,7 @@ final class SessionManager implements SessionManagerInterface {
|
|||
throw new \InvalidArgumentException( 'Invalid session ID' );
|
||||
}
|
||||
|
||||
$key = wfMemcKey( 'MWSession', $id );
|
||||
$key = $this->store->makeKey( 'MWSession', $id );
|
||||
if ( is_array( $this->store->get( $key ) ) ) {
|
||||
throw new \InvalidArgumentException( 'Session ID already exists' );
|
||||
}
|
||||
|
|
@ -545,7 +545,7 @@ final class SessionManager implements SessionManagerInterface {
|
|||
* @return bool Whether the session info matches the stored data (if any)
|
||||
*/
|
||||
private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) {
|
||||
$key = wfMemcKey( 'MWSession', $info->getId() );
|
||||
$key = $this->store->makeKey( 'MWSession', $info->getId() );
|
||||
$blob = $this->store->get( $key );
|
||||
|
||||
// If we got data from the store and the SessionInfo says to force use,
|
||||
|
|
@ -934,7 +934,7 @@ final class SessionManager implements SessionManagerInterface {
|
|||
public function generateSessionId() {
|
||||
do {
|
||||
$id = \Wikimedia\base_convert( \MWCryptRand::generateHex( 40 ), 16, 32, 32 );
|
||||
$key = wfMemcKey( 'MWSession', $id );
|
||||
$key = $this->store->makeKey( 'MWSession', $id );
|
||||
} while ( isset( $this->allSessionIds[$id] ) || is_array( $this->store->get( $key ) ) );
|
||||
return $id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -330,7 +330,9 @@ class SessionBackendTest extends MediaWikiTestCase {
|
|||
$backend->unpersist();
|
||||
$this->assertFalse( $backend->isPersistent() );
|
||||
$this->assertFalse( $this->store->getSession( self::SESSIONID ) );
|
||||
$this->assertNotFalse( $wrap->store->get( wfMemcKey( 'MWSession', self::SESSIONID ) ) );
|
||||
$this->assertNotFalse(
|
||||
$wrap->store->get( $wrap->store->makeKey( 'MWSession', self::SESSIONID ) )
|
||||
);
|
||||
}
|
||||
|
||||
public function testRememberUser() {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class TestBagOStuff extends \CachedBagOStuff {
|
|||
$expiry = \RequestContext::getMain()->getConfig()->get( 'ObjectCacheSessionExpiry' );
|
||||
}
|
||||
|
||||
$this->set( wfMemcKey( 'MWSession', $id ), $blob, $expiry );
|
||||
$this->set( $this->makeKey( 'MWSession', $id ), $blob, $expiry );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,7 +69,7 @@ class TestBagOStuff extends \CachedBagOStuff {
|
|||
* @return mixed
|
||||
*/
|
||||
public function getSession( $id ) {
|
||||
return $this->get( wfMemcKey( 'MWSession', $id ) );
|
||||
return $this->get( $this->makeKey( 'MWSession', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -77,14 +77,14 @@ class TestBagOStuff extends \CachedBagOStuff {
|
|||
* @return mixed
|
||||
*/
|
||||
public function getSessionFromBackend( $id ) {
|
||||
return $this->backend->get( wfMemcKey( 'MWSession', $id ) );
|
||||
return $this->backend->get( $this->makeKey( 'MWSession', $id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id Session ID
|
||||
*/
|
||||
public function deleteSession( $id ) {
|
||||
$this->delete( wfMemcKey( 'MWSession', $id ) );
|
||||
$this->delete( $this->makeKey( 'MWSession', $id ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue