Gerrit Patch Uploader has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/337803 )
Change subject: Fix issues related to sharing a session between multiple mediawiki instances with $wgCookieDomain ...................................................................... Fix issues related to sharing a session between multiple mediawiki instances with $wgCookieDomain Change-Id: I109ec6ac8f4001f9e56dee70243168d9c4e63505 --- M includes/session/SessionBackend.php M includes/session/SessionManager.php M tests/phpunit/includes/session/SessionBackendTest.php M tests/phpunit/includes/session/TestBagOStuff.php 4 files changed, 13 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/03/337803/1 diff --git a/includes/session/SessionBackend.php b/includes/session/SessionBackend.php index 8633715..455289f 100644 --- a/includes/session/SessionBackend.php +++ b/includes/session/SessionBackend.php @@ -132,7 +132,7 @@ $this->forceHTTPS = $info->forceHTTPS(); $this->providerMetadata = $info->getProviderMetadata(); - $blob = $store->get( wfMemcKey( 'MWSession', (string)$this->id ) ); + $blob = $store->get( wfGlobalCacheKey( 'MWSession', (string)$this->id ) ); if ( !is_array( $blob ) || !isset( $blob['metadata'] ) || !is_array( $blob['metadata'] ) || !isset( $blob['data'] ) || !is_array( $blob['data'] ) @@ -249,7 +249,7 @@ $this->autosave(); // Delete the data for the old session ID now - $this->store->delete( wfMemcKey( 'MWSession', $oldId ) ); + $this->store->delete( wfGlobalCacheKey( 'MWSession', $oldId ) ); } } @@ -317,7 +317,7 @@ // 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( wfGlobalCacheKey( 'MWSession', (string)$this->id ) ); $this->autosave(); } @@ -729,7 +729,7 @@ $flags = $this->persist ? 0 : CachedBagOStuff::WRITE_CACHE_ONLY; $flags |= CachedBagOStuff::WRITE_SYNC; // write to all datacenters $this->store->set( - wfMemcKey( 'MWSession', (string)$this->id ), + wfGlobalCacheKey( 'MWSession', (string)$this->id ), [ 'data' => $this->data, 'metadata' => $metadata, diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index 0041450..5e818bf 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -214,7 +214,7 @@ } // Test if the session is in storage, and if so try to load it. - $key = wfMemcKey( 'MWSession', $id ); + $key = wfGlobalCacheKey( 'MWSession', $id ); if ( is_array( $this->store->get( $key ) ) ) { $create = false; // If loading fails, don't bother creating because it probably will fail too. if ( $this->loadSessionInfoFromStore( $info, $request ) ) { @@ -255,7 +255,7 @@ throw new \InvalidArgumentException( 'Invalid session ID' ); } - $key = wfMemcKey( 'MWSession', $id ); + $key = wfGlobalCacheKey( 'MWSession', $id ); if ( is_array( $this->store->get( $key ) ) ) { throw new \InvalidArgumentException( 'Session ID already exists' ); } @@ -545,7 +545,7 @@ * @return bool Whether the session info matches the stored data (if any) */ private function loadSessionInfoFromStore( SessionInfo &$info, WebRequest $request ) { - $key = wfMemcKey( 'MWSession', $info->getId() ); + $key = wfGlobalCacheKey( 'MWSession', $info->getId() ); $blob = $this->store->get( $key ); // If we got data from the store and the SessionInfo says to force use, @@ -933,7 +933,7 @@ public function generateSessionId() { do { $id = \Wikimedia\base_convert( \MWCryptRand::generateHex( 40 ), 16, 32, 32 ); - $key = wfMemcKey( 'MWSession', $id ); + $key = wfGlobalCacheKey( 'MWSession', $id ); } while ( isset( $this->allSessionIds[$id] ) || is_array( $this->store->get( $key ) ) ); return $id; } diff --git a/tests/phpunit/includes/session/SessionBackendTest.php b/tests/phpunit/includes/session/SessionBackendTest.php index 8a0adba..c35f16f 100644 --- a/tests/phpunit/includes/session/SessionBackendTest.php +++ b/tests/phpunit/includes/session/SessionBackendTest.php @@ -327,7 +327,7 @@ $backend->unpersist(); $this->assertFalse( $backend->isPersistent() ); $this->assertFalse( $this->store->getSession( self::SESSIONID ) ); - $this->assertNotFalse( $wrap->store->get( wfMemcKey( 'MWSession', self::SESSIONID ) ) ); + $this->assertNotFalse( $wrap->store->get( wfGlobalCacheKey( 'MWSession', self::SESSIONID ) ) ); } public function testRememberUser() { diff --git a/tests/phpunit/includes/session/TestBagOStuff.php b/tests/phpunit/includes/session/TestBagOStuff.php index 759eca6..ce35f1c 100644 --- a/tests/phpunit/includes/session/TestBagOStuff.php +++ b/tests/phpunit/includes/session/TestBagOStuff.php @@ -61,7 +61,7 @@ $expiry = \RequestContext::getMain()->getConfig()->get( 'ObjectCacheSessionExpiry' ); } - $this->set( wfMemcKey( 'MWSession', $id ), $blob, $expiry ); + $this->set( wfGlobalCacheKey( 'MWSession', $id ), $blob, $expiry ); } /** @@ -69,7 +69,7 @@ * @return mixed */ public function getSession( $id ) { - return $this->get( wfMemcKey( 'MWSession', $id ) ); + return $this->get( wfGlobalCacheKey( 'MWSession', $id ) ); } /** @@ -77,14 +77,14 @@ * @return mixed */ public function getSessionFromBackend( $id ) { - return $this->backend->get( wfMemcKey( 'MWSession', $id ) ); + return $this->backend->get( wfGlobalCacheKey( 'MWSession', $id ) ); } /** * @param string $id Session ID */ public function deleteSession( $id ) { - $this->delete( wfMemcKey( 'MWSession', $id ) ); + $this->delete( wfGlobalCacheKey( 'MWSession', $id ) ); } } -- To view, visit https://gerrit.wikimedia.org/r/337803 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I109ec6ac8f4001f9e56dee70243168d9c4e63505 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits