From 17d8a57bde68073290f4b548ad28658181a11d0e Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 16 Oct 2019 23:41:01 +0100 Subject: [PATCH] session: Add debug message for the used store class Follows-up 70cb2664805. Bug: T234361 Change-Id: Ifd6616b1a31f6cb915ec553865e999fcd974784e (cherry picked from commit f2e6fab93ff0d45c95498146b022c761c5bbcd14) --- includes/session/SessionManager.php | 1 + tests/phpunit/includes/session/PHPSessionHandlerTest.php | 6 +++++- tests/phpunit/includes/session/SessionManagerTest.php | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/session/SessionManager.php b/includes/session/SessionManager.php index a3380ff82f..79193d684e 100644 --- a/includes/session/SessionManager.php +++ b/includes/session/SessionManager.php @@ -177,6 +177,7 @@ final class SessionManager implements SessionManagerInterface { } else { $store = \ObjectCache::getInstance( $this->config->get( 'SessionCacheType' ) ); } + $this->logger->debug( 'SessionManager using store ' . get_class( $store ) ); $this->store = $store instanceof CachedBagOStuff ? $store : new CachedBagOStuff( $store ); register_shutdown_function( [ $this, 'shutdown' ] ); diff --git a/tests/phpunit/includes/session/PHPSessionHandlerTest.php b/tests/phpunit/includes/session/PHPSessionHandlerTest.php index 94ccd4b572..fdaa336dbd 100644 --- a/tests/phpunit/includes/session/PHPSessionHandlerTest.php +++ b/tests/phpunit/includes/session/PHPSessionHandlerTest.php @@ -71,7 +71,10 @@ class PHPSessionHandlerTest extends MediaWikiTestCase { ini_set( 'session.use_trans_sid', 1 ); $store = new TestBagOStuff(); - $logger = new \TestLogger(); + // Tolerate debug message, anything else is unexpected + $logger = new \TestLogger( false, function ( $m ) { + return preg_match( '/^SessionManager using store/', $m ) ? null : $m; + } ); $manager = new SessionManager( [ 'store' => $store, 'logger' => $logger, @@ -147,6 +150,7 @@ class PHPSessionHandlerTest extends MediaWikiTestCase { $expect = [ 'AuthenticationSessionTest' => $rand ]; session_write_close(); $this->assertSame( [ + [ LogLevel::DEBUG, 'SessionManager using store MediaWiki\Session\TestBagOStuff' ], [ LogLevel::WARNING, 'Something wrote to $_SESSION!' ], ], $logger->getBuffer() ); diff --git a/tests/phpunit/includes/session/SessionManagerTest.php b/tests/phpunit/includes/session/SessionManagerTest.php index b2f525d741..3b4009ee96 100644 --- a/tests/phpunit/includes/session/SessionManagerTest.php +++ b/tests/phpunit/includes/session/SessionManagerTest.php @@ -34,7 +34,9 @@ class SessionManagerTest extends MediaWikiTestCase { ] ] ); $this->logger = new \TestLogger( false, function ( $m ) { - return substr( $m, 0, 15 ) === 'SessionBackend ' ? null : $m; + return ( strpos( $m, 'SessionBackend ' ) === 0 + || strpos( $m, 'SessionManager using store ' ) === 0 + ) ? null : $m; } ); $this->store = new TestBagOStuff(); -- 2.20.1