namespace MediaWiki\Session;
-use BagOStuff;
+use CachedBagOStuff;
use Psr\Log\LoggerInterface;
use User;
use WebRequest;
/** @var string Used to detect subarray modifications */
private $dataHash = null;
- /** @var BagOStuff */
- private $tempStore;
- /** @var BagOStuff */
- private $permStore;
+ /** @var CachedBagOStuff */
+ private $store;
/** @var LoggerInterface */
private $logger;
/**
* @param SessionId $id Session ID object
* @param SessionInfo $info Session info to populate from
- * @param BagOStuff $tempStore In-process data store
- * @param BagOStuff $permstore Backend data store for persisted sessions
+ * @param CachedBagOStuff $store Backend data store
* @param LoggerInterface $logger
* @param int $lifetime Session data lifetime in seconds
*/
public function __construct(
- SessionId $id, SessionInfo $info, BagOStuff $tempStore, BagOStuff $permStore,
- LoggerInterface $logger, $lifetime
+ SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger, $lifetime
) {
$phpSessionHandling = \RequestContext::getMain()->getConfig()->get( 'PHPSessionHandling' );
$this->usePhpSessionHandling = $phpSessionHandling !== 'disable';
$this->id = $id;
$this->user = $info->getUserInfo() ? $info->getUserInfo()->getUser() : new User;
- $this->tempStore = $tempStore;
- $this->permStore = $permStore;
+ $this->store = $store;
$this->logger = $logger;
$this->lifetime = $lifetime;
$this->provider = $info->getProvider();
$this->forceHTTPS = $info->forceHTTPS();
$this->providerMetadata = $info->getProviderMetadata();
- $key = wfMemcKey( 'MWSession', (string)$this->id );
- $blob = $tempStore->get( $key );
- if ( $blob === false ) {
- $blob = $permStore->get( $key );
- if ( $blob !== false ) {
- $tempStore->set( $key, $blob );
- }
- }
+ $blob = $store->get( wfMemcKey( 'MWSession', (string)$this->id ) );
if ( !is_array( $blob ) ||
!isset( $blob['metadata'] ) || !is_array( $blob['metadata'] ) ||
!isset( $blob['data'] ) || !is_array( $blob['data'] )
$this->autosave();
// Delete the data for the old session ID now
- $this->tempStore->delete( wfMemcKey( 'MWSession', $oldId ) );
- $this->permStore->delete( wfMemcKey( 'MWSession', $oldId ) );
+ $this->store->delete( wfMemcKey( 'MWSession', $oldId ) );
}
}
}
}
- $this->tempStore->set(
+ $this->store->set(
wfMemcKey( 'MWSession', (string)$this->id ),
array(
'data' => $this->data,
'metadata' => $metadata,
),
- $metadata['expires']
+ $metadata['expires'],
+ $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY
);
- if ( $this->persist ) {
- $this->permStore->set(
- wfMemcKey( 'MWSession', (string)$this->id ),
- array(
- 'data' => $this->data,
- 'metadata' => $metadata,
- ),
- $metadata['expires']
- );
- }
$this->metaDirty = false;
$this->dataDirty = false;
) {
$this->logger->debug( "SessionBackend $this->id: Taking over PHP session" );
session_id( (string)$this->id );
- \MediaWiki\quietCall( 'session_cache_limiter', 'private, must-revalidate' );
\MediaWiki\quietCall( 'session_start' );
}
}