From c3ea1b85b420ef6f58a92d65f90df3b23816caf3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Sun, 25 Oct 2015 19:00:24 -0700 Subject: [PATCH] Move PSR-3 support check right after autoloader setup This ensures that, in case "composer install" has not been run, the user will see the error message about setting up dependencies (as opposed a plain "Class not found" error because some other dependency was used first). Change-Id: Ib6026123770d21cc9f8960a1de361c8178b1b044 --- includes/WebStart.php | 15 +++++++++++++++ includes/debug/logger/LoggerFactory.php | 18 ------------------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/includes/WebStart.php b/includes/WebStart.php index adce346b7f..82d3955599 100644 --- a/includes/WebStart.php +++ b/includes/WebStart.php @@ -103,6 +103,21 @@ if ( is_readable( "$IP/vendor/autoload.php" ) ) { require_once "$IP/vendor/autoload.php"; } +# assert that composer dependencies were successfully loaded +if ( !interface_exists( '\Psr\Log\LoggerInterface' ) ) { + $message = ( + 'MediaWiki requires the 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.\n\n" . + 'Please see mediawiki.org for help on installing ' . + 'the required components.' + ); + echo $message; + trigger_error( $message, E_USER_ERROR ); + die( 1 ); +} + if ( defined( 'MW_CONFIG_CALLBACK' ) ) { # Use a callback function to configure MediaWiki call_user_func( MW_CONFIG_CALLBACK ); diff --git a/includes/debug/logger/LoggerFactory.php b/includes/debug/logger/LoggerFactory.php index b0a10cecf8..e0c4989bf0 100644 --- a/includes/debug/logger/LoggerFactory.php +++ b/includes/debug/logger/LoggerFactory.php @@ -94,24 +94,6 @@ class LoggerFactory { * @return \Psr\Log\LoggerInterface */ public static function getInstance( $channel ) { - static $hasPSR3Interface = null; - if ( $hasPSR3Interface === null ) { - $hasPSR3Interface = interface_exists( 'Psr\Log\LoggerInterface' ); - if ( !$hasPSR3Interface ) { - $message = ( - 'MediaWiki requires the 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.\n\n" . - 'Please see mediawiki.org for help on installing ' . - 'the required components.' - ); - echo $message; - trigger_error( $message, E_USER_ERROR ); - die( 1 ); - } - } - return self::getProvider()->getLogger( $channel ); } -- 2.20.1