private $usePhpSessionHandling = true;
private $checkPHPSessionRecursionGuard = false;
+ private $shutdown = false;
+
/**
* @param SessionId $id Session ID object
* @param SessionInfo $info Session info to populate from
*/
public function deregisterSession( $index ) {
unset( $this->requests[$index] );
- if ( !count( $this->requests ) ) {
+ if ( !$this->shutdown && !count( $this->requests ) ) {
$this->save( true );
$this->provider->getManager()->deregisterSessionBackend( $this );
}
}
+ /**
+ * Shut down a session
+ * @private For use by \MediaWiki\Session\SessionManager::shutdown() only
+ */
+ public function shutdown() {
+ $this->save( true );
+ $this->shutdown = true;
+ }
+
/**
* Returns the session ID.
* @return string
}
/**
- * 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 ) {
}
}
+ $flags = $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY;
+ $flags |= CachedBagOStuff::WRITE_SYNC; // write to all datacenters
$this->store->set(
wfMemcKey( 'MWSession', (string)$this->id ),
[
'metadata' => $metadata,
],
$metadata['expires'],
- $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY
+ $flags
);
$this->metaDirty = false;