X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSetup.php;h=4d9c495212111232645b046ad2c5b2775d2ac87a;hb=4aa6454d454df807059db5e794ef620896ff2e3d;hp=6825c7b70ff79ac4e9ce1f7f3b071ebcdf67e24e;hpb=b1b0070dc7557311cc38e7cc99e4231ac4b92940;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Setup.php b/includes/Setup.php index 6825c7b70f..4d9c495212 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -24,6 +24,8 @@ * @file */ use MediaWiki\MediaWikiServices; +use Wikimedia\Rdbms\LBFactory; +use Wikimedia\Rdbms\ChronologyProtector; /** * This file is not a valid entry point, perform no further processing unless @@ -276,7 +278,7 @@ $wgGalleryOptions += [ ]; /** - * Initialise $wgLocalFileRepo from backwards-compatible settings + * Shortcuts for $wgLocalFileRepo */ if ( !$wgLocalFileRepo ) { $wgLocalFileRepo = [ @@ -292,8 +294,15 @@ if ( !$wgLocalFileRepo ) { 'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0 ]; } + +if ( !isset( $wgLocalFileRepo['backend'] ) ) { + // Create a default FileBackend name. + // FileBackendGroup will register a default, if absent from $wgFileBackends. + $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend'; +} + /** - * Initialise shared repo from backwards-compatible settings + * Shortcuts for $wgForeignFileRepos */ if ( $wgUseSharedUploads ) { if ( $wgSharedUploadDBname ) { @@ -344,13 +353,6 @@ if ( $wgUseInstantCommons ) { 'apiThumbCacheExpiry' => 0, ]; } -/* - * Add on default file backend config for file repos. - * FileBackendGroup will handle initializing the backends. - */ -if ( !isset( $wgLocalFileRepo['backend'] ) ) { - $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend'; -} foreach ( $wgForeignFileRepos as &$repo ) { if ( !isset( $repo['directory'] ) && $repo['class'] === ForeignAPIRepo::class ) { $repo['directory'] = $wgUploadDirectory; // b/c @@ -361,12 +363,6 @@ foreach ( $wgForeignFileRepos as &$repo ) { } unset( $repo ); // no global pollution; destroy reference -// Convert this deprecated setting to modern system -if ( $wgExperimentalHtmlIds ) { - wfDeprecated( '$wgExperimentalHtmlIds', '1.30' ); - $wgFragmentMode = [ 'html5-legacy', 'html5' ]; -} - $rcMaxAgeDays = $wgRCMaxAge / ( 3600 * 24 ); if ( $wgRCFilterByAge ) { // Trim down $wgRCLinkDays so that it only lists links which are valid @@ -537,7 +533,7 @@ if ( $wgInvalidateCacheOnLocalSettingsChange ) { } if ( $wgNewUserLog ) { - // Add a new log type + // Add new user log type $wgLogTypes[] = 'newusers'; $wgLogNames['newusers'] = 'newuserlogpage'; $wgLogHeaders['newusers'] = 'newuserlogpagetext'; @@ -548,6 +544,12 @@ if ( $wgNewUserLog ) { $wgLogActionsHandlers['newusers/autocreate'] = NewUsersLogFormatter::class; } +if ( $wgPageCreationLog ) { + // Add page creation log type + $wgLogTypes[] = 'create'; + $wgLogActionsHandlers['create/create'] = LogFormatter::class; +} + if ( $wgPageLanguageUseDB ) { $wgLogTypes[] = 'pagelang'; $wgLogActionsHandlers['pagelang/pagelang'] = PageLangLogFormatter::class; @@ -631,10 +633,6 @@ define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 ); MWExceptionHandler::installHandler(); -require_once "$IP/includes/compat/normal/UtfNormalUtil.php"; - -$ps_validation = Profiler::instance()->scopedProfileIn( $fname . '-validation' ); - // T48998: Bail out early if $wgArticlePath is non-absolute foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) { if ( $$varName && !preg_match( '/^(https?:\/\/|\/)/', $$varName ) ) { @@ -647,8 +645,6 @@ foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) { } } -Profiler::instance()->scopedProfileOut( $ps_validation ); - $ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' ); if ( $wgCanonicalServer === false ) { @@ -709,7 +705,7 @@ if ( $wgMainWANCache === false ) { Profiler::instance()->scopedProfileOut( $ps_default2 ); -$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc1' ); +$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc' ); // Raise the memory limit if it's too low wfMemoryLimit(); @@ -740,14 +736,20 @@ if ( !$wgDBerrorLogTZ ) { // Initialize the request object in $wgRequest $wgRequest = RequestContext::getMain()->getRequest(); // BackCompat // Set user IP/agent information for agent session consistency purposes +$cpPosInfo = LBFactory::getCPInfoFromCookieValue( + // The cookie has no prefix and is set by MediaWiki::preOutputCommit() + $wgRequest->getCookie( 'cpPosIndex', '' ), + // Mitigate broken client-side cookie expiration handling (T190082) + time() - ChronologyProtector::POSITION_COOKIE_TTL +); MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->setRequestInfo( [ 'IPAddress' => $wgRequest->getIP(), 'UserAgent' => $wgRequest->getHeader( 'User-Agent' ), 'ChronologyProtection' => $wgRequest->getHeader( 'ChronologyProtection' ), - // The cpPosIndex cookie has no prefix and is set by MediaWiki::preOutputCommit() - 'ChronologyPositionIndex' => - $wgRequest->getInt( 'cpPosIndex', (int)$wgRequest->getCookie( 'cpPosIndex', '' ) ) + 'ChronologyPositionIndex' => $wgRequest->getInt( 'cpPosIndex', $cpPosInfo['index'] ), + 'ChronologyClientId' => $cpPosInfo['clientId'] ] ); +unset( $cpPosInfo ); // Make sure that object caching does not undermine the ChronologyProtector improvements if ( $wgRequest->getCookie( 'UseDC', '' ) === 'master' ) { // The user is pinned to the primary DC, meaning that they made recent changes which should @@ -772,19 +774,9 @@ if ( $wgCommandLineMode ) { wfDebug( $debug ); } -Profiler::instance()->scopedProfileOut( $ps_misc ); -$ps_memcached = Profiler::instance()->scopedProfileIn( $fname . '-memcached' ); - $wgMemc = wfGetMainCache(); $messageMemc = wfGetMessageCacheStorage(); -/** - * @deprecated since 1.30 - */ -$parserMemc = new DeprecatedGlobal( 'parserMemc', function () { - return MediaWikiServices::getInstance()->getParserCache()->getCacheStorage(); -}, '1.30' ); - wfDebugLog( 'caches', 'cluster: ' . get_class( $wgMemc ) . ', WAN: ' . ( $wgMainWANCache === CACHE_NONE ? 'CACHE_NONE' : $wgMainWANCache ) . @@ -793,7 +785,7 @@ wfDebugLog( 'caches', ', session: ' . get_class( ObjectCache::getInstance( $wgSessionCacheType ) ) ); -Profiler::instance()->scopedProfileOut( $ps_memcached ); +Profiler::instance()->scopedProfileOut( $ps_misc ); // Most of the config is out, some might want to run hooks here. Hooks::run( 'SetupAfterCache' ); @@ -825,8 +817,6 @@ if ( $wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin ) { ], '$wgAuth is ' . get_class( $wgAuth ) ); } -// Set up the session -$ps_session = Profiler::instance()->scopedProfileIn( $fname . '-session' ); /** * @var MediaWiki\Session\SessionId|null $wgInitialSessionId The persistent * session ID (if any) loaded at startup @@ -835,7 +825,7 @@ $wgInitialSessionId = null; if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) { // If session.auto_start is there, we can't touch session name if ( $wgPHPSessionHandling !== 'disable' && !wfIniGetBool( 'session.auto_start' ) ) { - session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' ); + session_name( $wgSessionName ?: $wgCookiePrefix . '_session' ); } // Create the SessionManager singleton and set up our session handler, @@ -890,7 +880,6 @@ if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) { ); } } -Profiler::instance()->scopedProfileOut( $ps_session ); /** * @var User $wgUser @@ -927,22 +916,7 @@ $ps_extensions = Profiler::instance()->scopedProfileIn( $fname . '-extensions' ) // of the extension file. This allows the extension to perform // any necessary initialisation in the fully initialised environment foreach ( $wgExtensionFunctions as $func ) { - // Allow closures in PHP 5.3+ - if ( is_object( $func ) && $func instanceof Closure ) { - $profName = $fname . '-extensions-closure'; - } elseif ( is_array( $func ) ) { - if ( is_object( $func[0] ) ) { - $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1]; - } else { - $profName = $fname . '-extensions-' . implode( '::', $func ); - } - } else { - $profName = $fname . '-extensions-' . strval( $func ); - } - - $ps_ext_func = Profiler::instance()->scopedProfileIn( $profName ); call_user_func( $func ); - Profiler::instance()->scopedProfileOut( $ps_ext_func ); } // If the session user has a 0 id but a valid name, that means we need to @@ -950,13 +924,11 @@ foreach ( $wgExtensionFunctions as $func ) { if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) { $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser(); if ( $sessionUser->getId() === 0 && User::isValidUserName( $sessionUser->getName() ) ) { - $ps_autocreate = Profiler::instance()->scopedProfileIn( $fname . '-autocreate' ); $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser( $sessionUser, MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION, true ); - Profiler::instance()->scopedProfileOut( $ps_autocreate ); \MediaWiki\Logger\LoggerFactory::getInstance( 'authevents' )->info( 'Autocreation attempt', [ 'event' => 'autocreate', 'status' => $res,