From 81d611a8082bfab74a92463d9ca835206bbc0b85 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 28 Jun 2019 09:45:15 -0700 Subject: [PATCH] Import PSR NullLogger instead of using absolute class references Change-Id: Ie09170f51e203e0a4c9a780a53cc9f3829139c31 --- includes/libs/filebackend/FileBackend.php | 3 ++- includes/libs/lockmanager/LockManager.php | 3 ++- includes/libs/mime/MimeAnalyzer.php | 3 ++- includes/libs/redis/RedisConnectionPool.php | 3 ++- includes/session/PHPSessionHandler.php | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/includes/libs/filebackend/FileBackend.php b/includes/libs/filebackend/FileBackend.php index 53a0ca040f..4ad48c70c1 100644 --- a/includes/libs/filebackend/FileBackend.php +++ b/includes/libs/filebackend/FileBackend.php @@ -30,6 +30,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; use Wikimedia\ScopedCallback; +use Psr\Log\NullLogger; /** * @brief Base class for all file backend classes (including multi-write backends). @@ -190,7 +191,7 @@ abstract class FileBackend implements LoggerAwareInterface { if ( !is_callable( $this->profiler ) ) { $this->profiler = null; } - $this->logger = $config['logger'] ?? new \Psr\Log\NullLogger(); + $this->logger = $config['logger'] ?? new NullLogger(); $this->statusWrapper = $config['statusWrapper'] ?? null; $this->tmpDirectory = $config['tmpDirectory'] ?? null; } diff --git a/includes/libs/lockmanager/LockManager.php b/includes/libs/lockmanager/LockManager.php index d152c65ec0..b8d3ad2c60 100644 --- a/includes/libs/lockmanager/LockManager.php +++ b/includes/libs/lockmanager/LockManager.php @@ -4,6 +4,7 @@ * @ingroup FileBackend */ use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; use Wikimedia\WaitConditionLoop; /** @@ -101,7 +102,7 @@ abstract class LockManager { } $this->session = md5( implode( '-', $random ) ); - $this->logger = $config['logger'] ?? new \Psr\Log\NullLogger(); + $this->logger = $config['logger'] ?? new NullLogger(); } /** diff --git a/includes/libs/mime/MimeAnalyzer.php b/includes/libs/mime/MimeAnalyzer.php index 42146f4f85..24621748ed 100644 --- a/includes/libs/mime/MimeAnalyzer.php +++ b/includes/libs/mime/MimeAnalyzer.php @@ -21,6 +21,7 @@ */ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; /** * Implements functions related to MIME types such as detection and mapping to file extension @@ -199,7 +200,7 @@ EOT; $this->detectCallback = $params['detectCallback'] ?? null; $this->guessCallback = $params['guessCallback'] ?? null; $this->extCallback = $params['extCallback'] ?? null; - $this->logger = $params['logger'] ?? new \Psr\Log\NullLogger(); + $this->logger = $params['logger'] ?? new NullLogger(); $this->loadFiles(); } diff --git a/includes/libs/redis/RedisConnectionPool.php b/includes/libs/redis/RedisConnectionPool.php index 9a8086f529..b4778550b5 100644 --- a/includes/libs/redis/RedisConnectionPool.php +++ b/includes/libs/redis/RedisConnectionPool.php @@ -23,6 +23,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; /** * Helper class to manage Redis connections. @@ -81,7 +82,7 @@ class RedisConnectionPool implements LoggerAwareInterface { __CLASS__ . ' requires a Redis client library. ' . 'See https://www.mediawiki.org/wiki/Redis#Setup' ); } - $this->logger = $options['logger'] ?? new \Psr\Log\NullLogger(); + $this->logger = $options['logger'] ?? new NullLogger(); $this->connectTimeout = $options['connectTimeout']; $this->readTimeout = $options['readTimeout']; $this->persistent = $options['persistent']; diff --git a/includes/session/PHPSessionHandler.php b/includes/session/PHPSessionHandler.php index 4d447d3996..64c2b84d8d 100644 --- a/includes/session/PHPSessionHandler.php +++ b/includes/session/PHPSessionHandler.php @@ -25,6 +25,7 @@ namespace MediaWiki\Session; use Psr\Log\LoggerInterface; use BagOStuff; +use Psr\Log\NullLogger; /** * Adapter for PHP's session handling @@ -299,7 +300,7 @@ class PHPSessionHandler implements \SessionHandlerInterface { } // Anything deleted in $_SESSION and unchanged in Session should be deleted too // (but not if $_SESSION can't represent it at all) - \Wikimedia\PhpSessionSerializer::setLogger( new \Psr\Log\NullLogger() ); + \Wikimedia\PhpSessionSerializer::setLogger( new NullLogger() ); foreach ( $cache as $key => $value ) { if ( !array_key_exists( $key, $data ) && $session->exists( $key ) && \Wikimedia\PhpSessionSerializer::encode( [ $key => true ] ) -- 2.20.1