From ed6af3296eef5fc53c04de589331a94a29202ef5 Mon Sep 17 00:00:00 2001 From: Bryan Davis Date: Thu, 30 Oct 2014 18:51:06 -0600 Subject: [PATCH] die() with explanation when \Psr\Log\LoggerInterface is missing Add an explicit check for the \Psr\Log\LoggerInterface in the source file that declares MWLogger and `die()` with an explanation and links to documentation if the interface is not present. MediaWiki requires the PSR-3 logging library to be present in the PHP search path or via an autoloader after I1e5596d. The composer.json for MediaWiki requires the necessary library, but usage of Composer with MediaWiki is not wide spread yet and users may be caught unaware by the new dependency. The default log messages generated when PHP fails to load the required interfaces and classes are not instructive as to how to correct the problem. Bug: 72777 Change-Id: I3db489702ed5d7973c6b5963eac22f181ca28c72 --- includes/debug/logger/Logger.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/includes/debug/logger/Logger.php b/includes/debug/logger/Logger.php index 7164bfabc8..f5d2445387 100644 --- a/includes/debug/logger/Logger.php +++ b/includes/debug/logger/Logger.php @@ -19,6 +19,17 @@ * @file */ +if ( !interface_exists( '\Psr\Log\LoggerInterface' ) ) { + $message = <<PSR-3 logging library to be present. This library is not embedded directly in MediaWiki's git repository and must be installed separately by the end user. + +Please see mediawiki.org for help on installing the required components. +TXT; + echo $message; + trigger_error( $message, E_USER_ERROR ); + die( 1 ); +} + /** * PSR-3 logging service. * -- 2.20.1