X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSetup.php;h=e57b96a8b6294a746d270edf83062cddbc125c85;hb=54d58ef506653ad916deb11882e264dd4f0eb0bf;hp=d7f1189a776e22461b774b9db1aaf5efaa99ac9e;hpb=bb333d91a4c29e025303d44c705414840b68249c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Setup.php b/includes/Setup.php index d7f1189a77..e57b96a8b6 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -23,6 +23,7 @@ * * @file */ +use MediaWiki\MediaWikiServices; /** * This file is not a valid entry point, perform no further processing unless @@ -290,25 +291,6 @@ if ( $wgSkipSkin ) { $wgSkipSkins[] = $wgSkipSkin; } -// Register skins -// Use a closure to avoid leaking into global state -call_user_func( function () use ( $wgValidSkinNames ) { - $factory = SkinFactory::getDefaultInstance(); - foreach ( $wgValidSkinNames as $name => $skin ) { - $factory->register( $name, $skin, function () use ( $name, $skin ) { - $class = "Skin$skin"; - return new $class( $name ); - } ); - } - // Register a hidden "fallback" skin - $factory->register( 'fallback', 'Fallback', function () { - return new SkinFallback; - } ); - // Register a hidden skin for api output - $factory->register( 'apioutput', 'ApiOutput', function () { - return new SkinApi; - } ); -} ); $wgSkipSkins[] = 'fallback'; $wgSkipSkins[] = 'apioutput'; @@ -361,11 +343,6 @@ if ( $wgEnableEmail ) { $wgUsersNotifiedOnAllChanges = []; } -// Doesn't make sense to have if disabled. -if ( !$wgEnotifMinorEdits ) { - $wgHiddenPrefs[] = 'enotifminoredits'; -} - if ( $wgMetaNamespace === false ) { $wgMetaNamespace = str_replace( ' ', '_', $wgSitename ); } @@ -473,6 +450,22 @@ if ( $wgProfileOnly ) { $wgDebugLogFile = ''; } +// Disable AuthManager API modules if $wgDisableAuthManager +if ( $wgDisableAuthManager ) { + $wgAPIModules += [ + 'clientlogin' => 'ApiDisabled', + 'createaccount' => 'ApiCreateAccount', // Use the non-AuthManager version + 'linkaccount' => 'ApiDisabled', + 'unlinkaccount' => 'ApiDisabled', + 'changeauthenticationdata' => 'ApiDisabled', + 'removeauthenticationdata' => 'ApiDisabled', + 'resetpassword' => 'ApiDisabled', + ]; + $wgAPIMetaModules += [ + 'authmanagerinfo' => 'ApiQueryDisabled', + ]; +} + // Backwards compatibility with old password limits if ( $wgMinimalPasswordLength !== false ) { $wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = $wgMinimalPasswordLength; @@ -522,6 +515,14 @@ if ( !class_exists( 'AutoLoader' ) ) { require_once "$IP/includes/AutoLoader.php"; } +// Reset the global service locator, so any services that have already been created will be +// re-created while taking into account any custom settings and extensions. +MediaWikiServices::resetGlobalInstance( new GlobalVarConfig() ); + +// Define a constant that indicates that the bootstrapping of the service locator +// is complete. +define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 ); + // Install a header callback to prevent caching of responses with cookies (T127993) if ( !$wgCommandLineMode ) { header_register_callback( function () { @@ -623,10 +624,9 @@ if ( $wgMainWANCache === false ) { // Sites using multiple datacenters can configure a relayer. $wgMainWANCache = 'mediawiki-main-default'; $wgWANObjectCaches[$wgMainWANCache] = [ - 'class' => 'WANObjectCache', - 'cacheId' => $wgMainCacheType, - 'pool' => 'mediawiki-main-default', - 'relayerConfig' => [ 'class' => 'EventRelayerNull' ] + 'class' => 'WANObjectCache', + 'cacheId' => $wgMainCacheType, + 'channels' => [ 'purge' => 'wancache-main-default-purge' ] ]; } @@ -708,9 +708,22 @@ $wgContLang->initContLang(); $wgRequest->interpolateTitle(); if ( !is_object( $wgAuth ) ) { - $wgAuth = new AuthPlugin; + $wgAuth = $wgDisableAuthManager ? new AuthPlugin : new MediaWiki\Auth\AuthManagerAuthPlugin; Hooks::run( 'AuthPluginSetup', [ &$wgAuth ] ); } +if ( !$wgDisableAuthManager && + $wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin +) { + MediaWiki\Auth\AuthManager::singleton()->forcePrimaryAuthenticationProviders( [ + new MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider( [ + 'authoritative' => false, + ] ), + new MediaWiki\Auth\AuthPluginPrimaryAuthenticationProvider( $wgAuth ), + new MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProvider( [ + 'authoritative' => true, + ] ), + ], '$wgAuth is ' . get_class( $wgAuth ) ); +} // Set up the session $ps_session = Profiler::instance()->scopedProfileIn( $fname . '-session' ); @@ -836,7 +849,15 @@ 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' ); - MediaWiki\Session\SessionManager::autoCreateUser( $sessionUser ); + if ( $wgDisableAuthManager ) { + MediaWiki\Session\SessionManager::autoCreateUser( $sessionUser ); + } else { + MediaWiki\Auth\AuthManager::singleton()->autoCreateUser( + $sessionUser, + MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSSION, + true + ); + } Profiler::instance()->scopedProfileOut( $ps_autocreate ); } unset( $sessionUser );