dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Introduce User::INVALID_TOKEN"
[lhc/web/wiklou.git]
/
includes
/
session
/
SessionManager.php
diff --git
a/includes/session/SessionManager.php
b/includes/session/SessionManager.php
index
c1bbc8f
..
f03260f
100644
(file)
--- a/
includes/session/SessionManager.php
+++ b/
includes/session/SessionManager.php
@@
-25,6
+25,7
@@
namespace MediaWiki\Session;
use Psr\Log\LoggerInterface;
use BagOStuff;
use Psr\Log\LoggerInterface;
use BagOStuff;
+use CachedBagOStuff;
use Config;
use FauxRequest;
use Language;
use Config;
use FauxRequest;
use Language;
@@
-54,11
+55,8
@@
final class SessionManager implements SessionManagerInterface {
/** @var Config */
private $config;
/** @var Config */
private $config;
- /** @var BagOStuff|null */
- private $tempStore;
-
- /** @var BagOStuff|null */
- private $permStore;
+ /** @var CachedBagOStuff|null */
+ private $store;
/** @var SessionProvider[] */
private $sessionProviders = null;
/** @var SessionProvider[] */
private $sessionProviders = null;
@@
-162,18
+160,18
@@
final class SessionManager implements SessionManagerInterface {
$this->setLogger( \MediaWiki\Logger\LoggerFactory::getInstance( 'session' ) );
}
$this->setLogger( \MediaWiki\Logger\LoggerFactory::getInstance( 'session' ) );
}
- $this->tempStore = new \HashBagOStuff;
if ( isset( $options['store'] ) ) {
if ( !$options['store'] instanceof BagOStuff ) {
throw new \InvalidArgumentException(
'$options[\'store\'] must be an instance of BagOStuff'
);
}
if ( isset( $options['store'] ) ) {
if ( !$options['store'] instanceof BagOStuff ) {
throw new \InvalidArgumentException(
'$options[\'store\'] must be an instance of BagOStuff'
);
}
- $
this->permS
tore = $options['store'];
+ $
s
tore = $options['store'];
} else {
} else {
- $
this->permS
tore = \ObjectCache::getInstance( $this->config->get( 'SessionCacheType' ) );
- $
this->permS
tore->setLogger( $this->logger );
+ $
s
tore = \ObjectCache::getInstance( $this->config->get( 'SessionCacheType' ) );
+ $
s
tore->setLogger( $this->logger );
}
}
+ $this->store = $store instanceof CachedBagOStuff ? $store : new CachedBagOStuff( $store );
register_shutdown_function( array( $this, 'shutdown' ) );
}
register_shutdown_function( array( $this, 'shutdown' ) );
}
@@
-206,14
+204,7
@@
final class SessionManager implements SessionManagerInterface {
// Test this here to provide a better log message for the common case
// of "no such ID"
$key = wfMemcKey( 'MWSession', $id );
// Test this here to provide a better log message for the common case
// of "no such ID"
$key = wfMemcKey( 'MWSession', $id );
- $existing = $this->tempStore->get( $key );
- if ( $existing === false ) {
- $existing = $this->permStore->get( $key );
- if ( $existing !== false ) {
- $this->tempStore->set( $key, $existing );
- }
- }
- if ( is_array( $existing ) ) {
+ if ( is_array( $this->store->get( $key ) ) ) {
$info = new SessionInfo( SessionInfo::MIN_PRIORITY, array( 'id' => $id, 'idIsSafe' => true ) );
if ( $this->loadSessionInfoFromStore( $info, $request ) ) {
$session = $this->getSessionFromInfo( $info, $request );
$info = new SessionInfo( SessionInfo::MIN_PRIORITY, array( 'id' => $id, 'idIsSafe' => true ) );
if ( $this->loadSessionInfoFromStore( $info, $request ) ) {
$session = $this->getSessionFromInfo( $info, $request );
@@
-251,14
+242,7
@@
final class SessionManager implements SessionManagerInterface {
}
$key = wfMemcKey( 'MWSession', $id );
}
$key = wfMemcKey( 'MWSession', $id );
- $existing = $this->tempStore->get( $key );
- if ( $existing === false ) {
- $existing = $this->permStore->get( $key );
- if ( $existing !== false ) {
- $this->tempStore->set( $key, $existing );
- }
- }
- if ( is_array( $existing ) ) {
+ if ( is_array( $this->store->get( $key ) ) ) {
throw new \InvalidArgumentException( 'Session ID already exists' );
}
}
throw new \InvalidArgumentException( 'Session ID already exists' );
}
}
@@
-671,13
+655,7
@@
final class SessionManager implements SessionManagerInterface {
*/
private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) {
$key = wfMemcKey( 'MWSession', $info->getId() );
*/
private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) {
$key = wfMemcKey( 'MWSession', $info->getId() );
- $blob = $this->tempStore->get( $key );
- if ( $blob === false ) {
- $blob = $this->permStore->get( $key );
- if ( $blob !== false ) {
- $this->tempStore->set( $key, $blob );
- }
- }
+ $blob = $this->store->get( $key );
$newParams = array();
$newParams = array();
@@
-685,8
+663,7
@@
final class SessionManager implements SessionManagerInterface {
// Sanity check: blob must be an array, if it's saved at all
if ( !is_array( $blob ) ) {
$this->logger->warning( "Session $info: Bad data" );
// Sanity check: blob must be an array, if it's saved at all
if ( !is_array( $blob ) ) {
$this->logger->warning( "Session $info: Bad data" );
- $this->tempStore->delete( $key );
- $this->permStore->delete( $key );
+ $this->store->delete( $key );
return false;
}
return false;
}
@@
-695,8
+672,7
@@
final class SessionManager implements SessionManagerInterface {
!isset( $blob['metadata'] ) || !is_array( $blob['metadata'] )
) {
$this->logger->warning( "Session $info: Bad data structure" );
!isset( $blob['metadata'] ) || !is_array( $blob['metadata'] )
) {
$this->logger->warning( "Session $info: Bad data structure" );
- $this->tempStore->delete( $key );
- $this->permStore->delete( $key );
+ $this->store->delete( $key );
return false;
}
return false;
}
@@
-711,8
+687,7
@@
final class SessionManager implements SessionManagerInterface {
!array_key_exists( 'provider', $metadata )
) {
$this->logger->warning( "Session $info: Bad metadata" );
!array_key_exists( 'provider', $metadata )
) {
$this->logger->warning( "Session $info: Bad metadata" );
- $this->tempStore->delete( $key );
- $this->permStore->delete( $key );
+ $this->store->delete( $key );
return false;
}
return false;
}
@@
-722,8
+697,7
@@
final class SessionManager implements SessionManagerInterface {
$newParams['provider'] = $provider = $this->getProvider( $metadata['provider'] );
if ( !$provider ) {
$this->logger->warning( "Session $info: Unknown provider, " . $metadata['provider'] );
$newParams['provider'] = $provider = $this->getProvider( $metadata['provider'] );
if ( !$provider ) {
$this->logger->warning( "Session $info: Unknown provider, " . $metadata['provider'] );
- $this->tempStore->delete( $key );
- $this->permStore->delete( $key );
+ $this->store->delete( $key );
return false;
}
} elseif ( $metadata['provider'] !== (string)$provider ) {
return false;
}
} elseif ( $metadata['provider'] !== (string)$provider ) {
@@
-914,8
+888,7
@@
final class SessionManager implements SessionManagerInterface {
$backend = new SessionBackend(
$this->allSessionIds[$id],
$info,
$backend = new SessionBackend(
$this->allSessionIds[$id],
$info,
- $this->tempStore,
- $this->permStore,
+ $this->store,
$this->logger,
$this->config->get( 'ObjectCacheSessionExpiry' )
);
$this->logger,
$this->config->get( 'ObjectCacheSessionExpiry' )
);
@@
-992,9
+965,7
@@
final class SessionManager implements SessionManagerInterface {
do {
$id = wfBaseConvert( \MWCryptRand::generateHex( 40 ), 16, 32, 32 );
$key = wfMemcKey( 'MWSession', $id );
do {
$id = wfBaseConvert( \MWCryptRand::generateHex( 40 ), 16, 32, 32 );
$key = wfMemcKey( 'MWSession', $id );
- } while ( isset( $this->allSessionIds[$id] ) ||
- is_array( $this->tempStore->get( $key ) ) || is_array( $this->permStore->get( $key ) )
- );
+ } while ( isset( $this->allSessionIds[$id] ) || is_array( $this->store->get( $key ) ) );
return $id;
}
return $id;
}
@@
-1004,7
+975,7
@@
final class SessionManager implements SessionManagerInterface {
* @param PHPSessionHandler $handler
*/
public function setupPHPSessionHandler( PHPSessionHandler $handler ) {
* @param PHPSessionHandler $handler
*/
public function setupPHPSessionHandler( PHPSessionHandler $handler ) {
- $handler->setManager( $this, $this->
permS
tore, $this->logger );
+ $handler->setManager( $this, $this->
s
tore, $this->logger );
}
/**
}
/**