die() with explanation when \Psr\Log\LoggerInterface is missing
authorBryan Davis <bd808@wikimedia.org>
Fri, 31 Oct 2014 00:51:06 +0000 (18:51 -0600)
committerBryan Davis <bd808@wikimedia.org>
Mon, 3 Nov 2014 16:16:35 +0000 (09:16 -0700)
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

index 7164bfa..f5d2445 100644 (file)
  * @file
  */
 
+if ( !interface_exists( '\Psr\Log\LoggerInterface' ) ) {
+       $message = <<<TXT
+MediaWiki requires the <a href="https://github.com/php-fig/log">PSR-3 logging library</a> 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 <a href="https://www.mediawiki.org/wiki/Download_from_Git#Fetch_external_libraries">mediawiki.org</a> for help on installing the required components.
+TXT;
+       echo $message;
+       trigger_error( $message, E_USER_ERROR );
+       die( 1 );
+}
+
 /**
  * PSR-3 logging service.
  *