private $shutdown = false;
/**
- * @param SessionId $id Session ID object
+ * @param SessionId $id
* @param SessionInfo $info Session info to populate from
* @param CachedBagOStuff $store Backend data store
* @param LoggerInterface $logger
$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'] )
if ( $restart ) {
session_id( (string)$this->id );
- \MediaWiki\quietCall( 'session_start' );
+ \Wikimedia\quietCall( 'session_start' );
}
$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 ) );
}
}
// 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();
}
*
* Calls to save() will not be delayed.
*
- * @return \ScopedCallback When this goes out of scope, a save will be triggered
+ * @return \Wikimedia\ScopedCallback When this goes out of scope, a save will be triggered
*/
public function delaySave() {
$this->delaySave++;
- return new \ScopedCallback( function () {
+ return new \Wikimedia\ScopedCallback( function () {
if ( --$this->delaySave <= 0 ) {
$this->delaySave = 0;
$this->save();
}
/**
- * Save and persist session data, unless delayed
+ * Save the session, unless delayed
+ * @see SessionBackend::save()
*/
private function autosave() {
if ( $this->delaySave <= 0 ) {
}
/**
- * Save and persist session data
+ * Save the session
+ *
+ * Update both the backend data and the associated WebRequest(s) to
+ * reflect the state of the the SessionBackend. This might include
+ * persisting or unpersisting the session.
+ *
* @param bool $closing Whether the session is being closed
*/
public function save( $closing = false ) {
] );
$this->user->setToken();
if ( !wfReadOnly() ) {
- $this->user->saveSettings();
+ // Promise that the token set here will be valid; save it at end of request
+ $user = $this->user;
+ \DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+ $user->saveSettings();
+ } );
}
$this->metaDirty = true;
}
$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,
private function checkPHPSession() {
if ( !$this->checkPHPSessionRecursionGuard ) {
$this->checkPHPSessionRecursionGuard = true;
- $reset = new \ScopedCallback( function () {
+ $reset = new \Wikimedia\ScopedCallback( function () {
$this->checkPHPSessionRecursionGuard = false;
} );
'session' => $this->id,
] );
session_id( (string)$this->id );
- \MediaWiki\quietCall( 'session_start' );
+ \Wikimedia\quietCall( 'session_start' );
}
}
}