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 */
+ /** @var CachedBagOStuff */
private $store;
/** @var LoggerInterface */
/**
* @param SessionId $id Session ID object
* @param SessionInfo $info Session info to populate from
- * @param BagOStuff $store Backend data store
+ * @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 $store, LoggerInterface $logger, $lifetime
+ SessionId $id, SessionInfo $info, CachedBagOStuff $store, LoggerInterface $logger, $lifetime
) {
$phpSessionHandling = \RequestContext::getMain()->getConfig()->get( 'PHPSessionHandling' );
$this->usePhpSessionHandling = $phpSessionHandling !== 'disable';
// Ensure the user has a token
// @codeCoverageIgnoreStart
$anon = $this->user->isAnon();
- if ( !$anon && !$this->user->getToken() ) {
+ if ( !$anon && !$this->user->getToken( false ) ) {
$this->logger->debug(
"SessionBackend $this->id creating token for user {$this->user} on save"
);
'provider' => (string)$this->provider,
'providerMetadata' => $this->providerMetadata,
'userId' => $anon ? 0 : $this->user->getId(),
- 'userName' => $anon ? null : $this->user->getName(),
+ 'userName' => User::isValidUserName( $this->user->getName() ) ? $this->user->getName() : null,
'userToken' => $anon ? null : $this->user->getToken(),
'remember' => !$anon && $this->remember,
'forceHTTPS' => $this->forceHTTPS,
'data' => $this->data,
'metadata' => $metadata,
),
- $metadata['expires']
+ $metadata['expires'],
+ $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY
);
$this->metaDirty = 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' );
}
}