X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsession%2FSessionBackend.php;h=263cb11f54212f088634c8c725cc1927a198d8ac;hb=c07567928973c22f1b85969f5ba20285e59b877d;hp=2626aa88134a998372e60c1dfa763f6e82f53d32;hpb=01a2a52dda8063501aa602d19c0c8bea7f8e7710;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/session/SessionBackend.php b/includes/session/SessionBackend.php index 2626aa8813..263cb11f54 100644 --- a/includes/session/SessionBackend.php +++ b/includes/session/SessionBackend.php @@ -94,6 +94,8 @@ final class SessionBackend { private $usePhpSessionHandling = true; private $checkPHPSessionRecursionGuard = false; + private $shutdown = false; + /** * @param SessionId $id Session ID object * @param SessionInfo $info Session info to populate from @@ -181,12 +183,21 @@ final class SessionBackend { */ 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 @@ -588,7 +599,8 @@ final class SessionBackend { } /** - * Save and persist session data, unless delayed + * Save the session, unless delayed + * @see SessionBackend::save() */ private function autosave() { if ( $this->delaySave <= 0 ) { @@ -597,7 +609,12 @@ final class SessionBackend { } /** - * 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 ) { @@ -705,6 +722,8 @@ final class SessionBackend { } } + $flags = $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY; + $flags |= CachedBagOStuff::WRITE_SYNC; // write to all datacenters $this->store->set( wfMemcKey( 'MWSession', (string)$this->id ), [ @@ -712,7 +731,7 @@ final class SessionBackend { 'metadata' => $metadata, ], $metadata['expires'], - $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY + $flags ); $this->metaDirty = false;