X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSetup.php;h=d6f4b2fe4c0b28cf9ee57e240dd0f0ad83ec8fa1;hb=36f4daf32c591d6b7e2435629fc6e431398b641a;hp=d4612dd2c69054b6a808b3718ad73784d6ff46aa;hpb=db9cebf59c3f620d8ea3d65e98be3aa1708dbd57;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Setup.php b/includes/Setup.php index d4612dd2c6..d6f4b2fe4c 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -33,6 +33,82 @@ if ( !defined( 'MEDIAWIKI' ) ) { exit( 1 ); } +/** + * Pre-config setup: Before loading LocalSettings.php + */ + +// Get profiler configuraton +$wgProfiler = []; +if ( file_exists( "$IP/StartProfiler.php" ) ) { + require "$IP/StartProfiler.php"; +} + +// Start the autoloader, so that extensions can derive classes from core files +require_once "$IP/includes/AutoLoader.php"; + +// Load up some global defines +require_once "$IP/includes/Defines.php"; + +// Load default settings +require_once "$IP/includes/DefaultSettings.php"; + +// Load global functions +require_once "$IP/includes/GlobalFunctions.php"; + +// Load composer's autoloader if present +if ( is_readable( "$IP/vendor/autoload.php" ) ) { + require_once "$IP/vendor/autoload.php"; +} + +// Assert that composer dependencies were successfully loaded +// Purposely no leading \ due to it breaking HHVM RepoAuthorative mode +// PHP works fine with both versions +// See https://github.com/facebook/hhvm/issues/5833 +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 ); +} + +// Install a header callback +MediaWiki\HeaderCallback::register(); + +/** + * Load LocalSettings.php + */ + +if ( defined( 'MW_CONFIG_CALLBACK' ) ) { + call_user_func( MW_CONFIG_CALLBACK ); +} else { + if ( !defined( 'MW_CONFIG_FILE' ) ) { + define( 'MW_CONFIG_FILE', "$IP/LocalSettings.php" ); + } + require_once MW_CONFIG_FILE; +} + +/** + * Customization point after all loading (constants, functions, classes, + * DefaultSettings, LocalSettings). Specifically, this is before usage of + * settings, before instantiation of Profiler (and other singletons), and + * before any setup functions or hooks run. + */ + +if ( defined( 'MW_SETUP_CALLBACK' ) ) { + call_user_func( MW_SETUP_CALLBACK ); +} + +/** + * Main setup + */ + $fname = 'Setup.php'; $ps_setup = Profiler::instance()->scopedProfileIn( $fname ); @@ -658,14 +734,22 @@ if ( !$wgDBerrorLogTZ ) { $wgDBerrorLogTZ = $wgLocaltimezone; } -// initialize the request object in $wgRequest +// Initialize the request object in $wgRequest $wgRequest = RequestContext::getMain()->getRequest(); // BackCompat -// Set user IP/agent information for causal consistency purposes +// Set user IP/agent information for causal consistency purposes. +// The cpPosTime cookie has no prefix and is set by MediaWiki::preOutputCommit(). +$cpPosTime = $wgRequest->getFloat( 'cpPosTime', $wgRequest->getCookie( 'cpPosTime', '' ) ); MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [ 'IPAddress' => $wgRequest->getIP(), 'UserAgent' => $wgRequest->getHeader( 'User-Agent' ), - 'ChronologyProtection' => $wgRequest->getHeader( 'ChronologyProtection' ) + 'ChronologyProtection' => $wgRequest->getHeader( 'ChronologyProtection' ), + 'ChronologyPositionTime' => $cpPosTime ] ); +// Make sure that caching does not compromise the consistency improvements +if ( $cpPosTime ) { + MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching( false ); +} +unset( $cpPosTime ); // Useful debug output if ( $wgCommandLineMode ) {