2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2020-03-14 18:56:18 +00:00
|
|
|
* The setup for all MediaWiki processes (both web-based and CLI).
|
2014-04-13 20:07:50 +00:00
|
|
|
*
|
2022-05-04 18:12:23 +00:00
|
|
|
* The entry point (such as WebStart.php and doMaintenance.php) has these responsibilities:
|
|
|
|
|
* - The entry point MUST:
|
2020-04-12 20:22:41 +00:00
|
|
|
* - define the 'MEDIAWIKI' constant.
|
2022-05-04 18:12:23 +00:00
|
|
|
* - The entry point SHOULD:
|
|
|
|
|
* - define the 'MW_ENTRY_POINT' constant.
|
|
|
|
|
* - display an error if MW_CONFIG_CALLBACK is not defined and the
|
|
|
|
|
* file specified in MW_CONFIG_FILE (or the LocalSettings.php default location)
|
|
|
|
|
* does not exist. The error should either be sent before and instead
|
|
|
|
|
* of the Setup.php inclusion, or (if it needs classes and dependencies
|
|
|
|
|
* from core) the error can be displayed via a MW_CONFIG_CALLBACK,
|
|
|
|
|
* which must then abort the process to prevent the rest of Setup.php
|
|
|
|
|
* from executing.
|
2020-03-14 18:56:18 +00:00
|
|
|
*
|
2022-05-04 18:12:23 +00:00
|
|
|
* This file does:
|
2020-03-14 18:56:18 +00:00
|
|
|
* - run-time environment checks,
|
2022-05-04 18:12:23 +00:00
|
|
|
* - define MW_INSTALL_PATH, $IP, and $wgBaseDirectory,
|
2020-03-14 18:56:18 +00:00
|
|
|
* - load autoloaders, constants, default settings, and global functions,
|
|
|
|
|
* - load the site configuration (e.g. LocalSettings.php),
|
|
|
|
|
* - load the enabled extensions (via ExtensionRegistry),
|
2021-07-26 16:48:37 +00:00
|
|
|
* - trivial expansion of site configuration defaults and shortcuts
|
|
|
|
|
* (no calls to MediaWikiServices or other parts of MediaWiki),
|
2020-03-14 18:56:18 +00:00
|
|
|
* - initialization of:
|
|
|
|
|
* - PHP run-time (setlocale, memory limit, default date timezone)
|
|
|
|
|
* - the debug logger (MWDebug)
|
|
|
|
|
* - the service container (MediaWikiServices)
|
|
|
|
|
* - the exception handler (MWExceptionHandler)
|
|
|
|
|
* - the session manager (SessionManager)
|
2021-07-26 16:48:37 +00:00
|
|
|
* - complex expansion of site configuration defaults (those that require
|
|
|
|
|
* calling into MediaWikiServices, global functions, or other classes.).
|
2012-05-10 15:51:44 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-10-02 07:57:43 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2020-06-01 05:00:39 +00:00
|
|
|
|
2022-02-21 16:21:36 +00:00
|
|
|
// phpcs:disable MediaWiki.Usage.DeprecatedGlobalVariables
|
2020-06-01 05:00:39 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
2022-04-01 15:58:32 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2022-05-02 19:46:38 +00:00
|
|
|
use MediaWiki\MainConfigSchema;
|
2016-05-01 19:29:11 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2022-11-02 17:22:08 +00:00
|
|
|
use MediaWiki\Request\HeaderCallback;
|
2021-11-11 17:50:14 +00:00
|
|
|
use MediaWiki\Settings\Config\GlobalConfigBuilder;
|
2021-11-24 16:20:29 +00:00
|
|
|
use MediaWiki\Settings\Config\PhpIniSink;
|
2022-04-24 16:14:51 +00:00
|
|
|
use MediaWiki\Settings\DynamicDefaultValues;
|
2022-02-22 16:41:08 +00:00
|
|
|
use MediaWiki\Settings\LocalSettingsLoader;
|
2021-11-11 20:31:47 +00:00
|
|
|
use MediaWiki\Settings\SettingsBuilder;
|
2021-12-08 20:04:36 +00:00
|
|
|
use MediaWiki\Settings\Source\PhpSettingsSource;
|
2022-05-02 19:46:38 +00:00
|
|
|
use MediaWiki\Settings\Source\ReflectionSchemaSource;
|
2021-12-12 21:20:17 +00:00
|
|
|
use MediaWiki\Settings\WikiFarmSettingsLoader;
|
2022-10-25 16:58:49 +00:00
|
|
|
use MediaWiki\StubObject\StubGlobalUser;
|
|
|
|
|
use MediaWiki\StubObject\StubUserLang;
|
2019-10-03 04:01:38 +00:00
|
|
|
use Psr\Log\LoggerInterface;
|
2021-01-06 05:23:15 +00:00
|
|
|
use Wikimedia\RequestTimeout\RequestTimeout;
|
2004-09-02 23:28:24 +00:00
|
|
|
|
|
|
|
|
/**
|
2020-03-13 16:20:13 +00:00
|
|
|
* Environment checks
|
|
|
|
|
*
|
|
|
|
|
* These are inline checks done before we include any source files,
|
|
|
|
|
* and thus these conditions may be assumed by all source code.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2020-03-13 16:20:13 +00:00
|
|
|
|
|
|
|
|
// This file must be included from a valid entry point (e.g. WebStart.php, Maintenance.php)
|
2011-01-14 21:42:38 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
2006-07-14 05:35:31 +00:00
|
|
|
exit( 1 );
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
2004-08-06 22:30:47 +00:00
|
|
|
|
2020-03-13 16:20:13 +00:00
|
|
|
// PHP must not be configured to overload mbstring functions. (T5782, T122807)
|
|
|
|
|
// This was deprecated by upstream in PHP 7.2, likely to be removed in PHP 8.0.
|
2018-04-17 22:07:48 +00:00
|
|
|
if ( ini_get( 'mbstring.func_overload' ) ) {
|
|
|
|
|
die( 'MediaWiki does not support installations where mbstring.func_overload is non-zero.' );
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-13 16:20:13 +00:00
|
|
|
// The MW_ENTRY_POINT constant must always exists, to make it safe to access.
|
2022-01-09 17:58:53 +00:00
|
|
|
// For compat, we do support older and custom MW entrypoints that don't set this,
|
2020-03-13 16:20:13 +00:00
|
|
|
// in which case we assign a default here.
|
2019-09-02 23:55:00 +00:00
|
|
|
if ( !defined( 'MW_ENTRY_POINT' ) ) {
|
|
|
|
|
/**
|
|
|
|
|
* The entry point, which may be either the script filename without the
|
|
|
|
|
* file extension, or "cli" for maintenance scripts, or "unknown" for any
|
|
|
|
|
* entry point that does not set the constant.
|
|
|
|
|
*/
|
|
|
|
|
define( 'MW_ENTRY_POINT', 'unknown' );
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-04 18:12:23 +00:00
|
|
|
// The $IP variable is defined for use by LocalSettings.php.
|
|
|
|
|
// It is made available as a global variable for backwards compatibility.
|
|
|
|
|
//
|
|
|
|
|
// Source code should instead use the MW_INSTALL_PATH constant, or the
|
|
|
|
|
// MainConfigNames::BaseDirectory setting. The BaseDirectory setting is set further
|
|
|
|
|
// down in Setup.php to the value of MW_INSTALL_PATH.
|
2022-04-27 19:33:22 +00:00
|
|
|
global $IP;
|
2022-05-04 18:12:23 +00:00
|
|
|
$IP = $IP = wfDetectInstallPath(); // ensure MW_INSTALL_PATH is defined
|
2022-01-27 20:24:12 +00:00
|
|
|
|
2020-03-13 16:20:13 +00:00
|
|
|
/**
|
|
|
|
|
* Pre-config setup: Before loading LocalSettings.php
|
|
|
|
|
*
|
|
|
|
|
* These are changes and additions to runtime that don't vary on site configuration.
|
|
|
|
|
*/
|
2022-05-04 18:12:23 +00:00
|
|
|
require_once MW_INSTALL_PATH . '/includes/AutoLoader.php';
|
|
|
|
|
require_once MW_INSTALL_PATH . '/includes/Defines.php';
|
2017-09-19 19:24:19 +00:00
|
|
|
|
|
|
|
|
// Assert that composer dependencies were successfully loaded
|
2019-10-03 04:01:38 +00:00
|
|
|
if ( !interface_exists( LoggerInterface::class ) ) {
|
2017-09-19 19:24:19 +00:00
|
|
|
$message = (
|
|
|
|
|
'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.\n\n" .
|
2021-11-14 07:05:27 +00:00
|
|
|
'Please see the <a href="https://www.mediawiki.org/wiki/Download_from_Git' .
|
|
|
|
|
'#Fetch_external_libraries">instructions for installing libraries</a> on mediawiki.org ' .
|
|
|
|
|
'for help on installing the required components.'
|
2017-09-19 19:24:19 +00:00
|
|
|
);
|
|
|
|
|
echo $message;
|
|
|
|
|
trigger_error( $message, E_USER_ERROR );
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-21 16:21:36 +00:00
|
|
|
// Set $wgCommandLineMode to false if it wasn't set to true.
|
2022-10-21 02:26:49 +00:00
|
|
|
$wgCommandLineMode ??= false;
|
2022-02-21 16:21:36 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* $wgConf hold the site configuration.
|
|
|
|
|
* Not used for much in a default install.
|
|
|
|
|
* @since 1.5
|
|
|
|
|
*/
|
|
|
|
|
$wgConf = new SiteConfiguration;
|
|
|
|
|
|
2022-10-21 02:26:49 +00:00
|
|
|
$wgAutoloadClasses ??= [];
|
2022-02-21 16:21:36 +00:00
|
|
|
|
2021-12-01 20:49:37 +00:00
|
|
|
$wgSettings = new SettingsBuilder(
|
2022-05-04 18:12:23 +00:00
|
|
|
MW_INSTALL_PATH,
|
2021-12-01 20:49:37 +00:00
|
|
|
ExtensionRegistry::getInstance(),
|
|
|
|
|
new GlobalConfigBuilder( 'wg' ),
|
|
|
|
|
new PhpIniSink()
|
|
|
|
|
);
|
2021-11-11 20:31:47 +00:00
|
|
|
|
2022-05-02 19:46:38 +00:00
|
|
|
if ( defined( 'MW_USE_CONFIG_SCHEMA_CLASS' ) ) {
|
|
|
|
|
// Load config schema from MainConfigSchema. Useful for running scripts that
|
|
|
|
|
// generate other representations of the config schema. This is slow, so it
|
|
|
|
|
// should not be used for serving web traffic.
|
|
|
|
|
$wgSettings->load( new ReflectionSchemaSource( MainConfigSchema::class ) );
|
|
|
|
|
} elseif ( getenv( 'MW_USE_LEGACY_DEFAULT_SETTINGS' ) || defined( 'MW_USE_LEGACY_DEFAULT_SETTINGS' ) ) {
|
2022-03-31 16:47:27 +00:00
|
|
|
// Load the old DefaultSettings.php file. Should be removed in 1.39. See T300129.
|
2022-05-04 18:12:23 +00:00
|
|
|
require_once MW_INSTALL_PATH . '/includes/DefaultSettings.php';
|
2022-02-21 16:21:36 +00:00
|
|
|
|
2022-03-31 16:47:27 +00:00
|
|
|
// This is temporary until we no longer need this mode.
|
2022-02-21 16:28:35 +00:00
|
|
|
// TODO: delete config-merge-strategies.php when this code is removed.
|
2022-05-04 18:12:23 +00:00
|
|
|
$wgSettings->load( new PhpSettingsSource( MW_INSTALL_PATH . '/includes/config-merge-strategies.php' ) );
|
2022-03-31 16:47:27 +00:00
|
|
|
} else {
|
2022-05-04 18:12:23 +00:00
|
|
|
$wgSettings->load( new PhpSettingsSource( MW_INSTALL_PATH . '/includes/config-schema.php' ) );
|
2022-02-21 16:21:36 +00:00
|
|
|
}
|
2021-11-11 20:31:47 +00:00
|
|
|
|
2022-05-04 18:12:23 +00:00
|
|
|
require_once MW_INSTALL_PATH . '/includes/GlobalFunctions.php';
|
2021-12-08 20:04:36 +00:00
|
|
|
|
2021-01-06 05:23:15 +00:00
|
|
|
HeaderCallback::register();
|
2017-09-19 19:24:19 +00:00
|
|
|
|
2019-08-25 18:22:26 +00:00
|
|
|
// Set the encoding used by PHP for reading HTTP input, and writing output.
|
2019-07-13 00:46:56 +00:00
|
|
|
// This is also the default for mbstring functions.
|
|
|
|
|
mb_internal_encoding( 'UTF-8' );
|
|
|
|
|
|
2017-09-19 19:24:19 +00:00
|
|
|
/**
|
|
|
|
|
* Load LocalSettings.php
|
|
|
|
|
*/
|
|
|
|
|
|
2022-01-28 19:17:51 +00:00
|
|
|
// Initialize some config settings with dynamic defaults, and
|
|
|
|
|
// make default settings available in globals for use in LocalSettings.php.
|
2022-02-20 21:15:06 +00:00
|
|
|
$wgSettings->putConfigValues( [
|
2022-05-04 18:12:23 +00:00
|
|
|
MainConfigNames::BaseDirectory => MW_INSTALL_PATH,
|
|
|
|
|
MainConfigNames::ExtensionDirectory => MW_INSTALL_PATH . '/extensions',
|
|
|
|
|
MainConfigNames::StyleDirectory => MW_INSTALL_PATH . '/skins',
|
|
|
|
|
MainConfigNames::ServiceWiringFiles => [ MW_INSTALL_PATH . '/includes/ServiceWiring.php' ],
|
2022-02-21 16:21:36 +00:00
|
|
|
'Version' => MW_VERSION,
|
2022-01-28 19:17:51 +00:00
|
|
|
] );
|
2021-11-11 20:31:47 +00:00
|
|
|
$wgSettings->apply();
|
|
|
|
|
|
2022-02-21 16:28:35 +00:00
|
|
|
// $wgSettings->apply() puts all configuration into global variables.
|
|
|
|
|
// If we are not in global scope, make all relevant globals available
|
|
|
|
|
// in this file's scope as well.
|
|
|
|
|
$wgScopeTest = 'MediaWiki Setup.php scope test';
|
|
|
|
|
if ( !isset( $GLOBALS['wgScopeTest'] ) || $GLOBALS['wgScopeTest'] !== $wgScopeTest ) {
|
|
|
|
|
foreach ( $wgSettings->getConfigSchema()->getDefinedKeys() as $key ) {
|
|
|
|
|
$var = "wg$key";
|
|
|
|
|
// phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix
|
|
|
|
|
global $$var;
|
|
|
|
|
}
|
|
|
|
|
unset( $key, $var );
|
|
|
|
|
}
|
|
|
|
|
unset( $wgScopeTest );
|
|
|
|
|
|
2017-09-19 19:24:19 +00:00
|
|
|
if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
|
2022-02-20 20:25:59 +00:00
|
|
|
call_user_func( MW_CONFIG_CALLBACK, $wgSettings );
|
2017-09-19 19:24:19 +00:00
|
|
|
} else {
|
2022-05-04 18:12:23 +00:00
|
|
|
wfDetectLocalSettingsFile( MW_INSTALL_PATH );
|
2021-11-16 18:22:57 +00:00
|
|
|
|
2022-02-22 16:41:08 +00:00
|
|
|
if ( getenv( 'MW_USE_LOCAL_SETTINGS_LOADER' ) ) {
|
|
|
|
|
// NOTE: This will not work for configuration variables that use a prefix
|
|
|
|
|
// other than "wg".
|
2022-05-04 18:12:23 +00:00
|
|
|
$localSettingsLoader = new LocalSettingsLoader( $wgSettings, MW_INSTALL_PATH );
|
2022-02-22 16:41:08 +00:00
|
|
|
$localSettingsLoader->loadLocalSettingsFile( MW_CONFIG_FILE );
|
|
|
|
|
unset( $localSettingsLoader );
|
2021-11-16 18:22:57 +00:00
|
|
|
} else {
|
2022-02-22 16:41:08 +00:00
|
|
|
if ( str_ends_with( MW_CONFIG_FILE, '.php' ) ) {
|
|
|
|
|
// make defaults available as globals
|
|
|
|
|
$wgSettings->apply();
|
|
|
|
|
require_once MW_CONFIG_FILE;
|
|
|
|
|
} else {
|
|
|
|
|
$wgSettings->loadFile( MW_CONFIG_FILE );
|
|
|
|
|
}
|
2017-09-19 19:24:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-11 20:31:47 +00:00
|
|
|
// Make settings loaded by LocalSettings.php available in globals for use here
|
|
|
|
|
$wgSettings->apply();
|
|
|
|
|
|
2017-09-19 19:24:19 +00:00
|
|
|
/**
|
|
|
|
|
* Customization point after all loading (constants, functions, classes,
|
2022-02-21 16:28:35 +00:00
|
|
|
* LocalSettings). Specifically, this is before usage of
|
2017-09-19 19:24:19 +00:00
|
|
|
* settings, before instantiation of Profiler (and other singletons), and
|
|
|
|
|
* before any setup functions or hooks run.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ( defined( 'MW_SETUP_CALLBACK' ) ) {
|
2022-01-26 17:46:06 +00:00
|
|
|
call_user_func( MW_SETUP_CALLBACK, $wgSettings );
|
2021-11-11 20:31:47 +00:00
|
|
|
// Make any additional settings available in globals for use here
|
|
|
|
|
$wgSettings->apply();
|
2017-09-19 19:24:19 +00:00
|
|
|
}
|
|
|
|
|
|
2021-12-12 21:20:17 +00:00
|
|
|
// If in a wiki-farm, load site-specific settings
|
2022-04-01 15:58:32 +00:00
|
|
|
if ( $wgSettings->getConfig()->get( MainConfigNames::WikiFarmSettingsDirectory ) ) {
|
2021-12-12 21:20:17 +00:00
|
|
|
$wikiFarmSettingsLoader = new WikiFarmSettingsLoader( $wgSettings );
|
|
|
|
|
$wikiFarmSettingsLoader->loadWikiFarmSettings();
|
|
|
|
|
unset( $wikiFarmSettingsLoader );
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-24 16:14:51 +00:00
|
|
|
// Apply dynamic defaults declared in config schema callbacks.
|
|
|
|
|
$dynamicDefaults = new DynamicDefaultValues( $wgSettings->getConfigSchema() );
|
|
|
|
|
$dynamicDefaults->applyDynamicDefaults( $wgSettings->getConfigBuilder() );
|
|
|
|
|
|
|
|
|
|
// Make updated config available in global scope.
|
|
|
|
|
$wgSettings->apply();
|
|
|
|
|
|
|
|
|
|
// Apply dynamic defaults implemented in SetupDynamicConfig.php.
|
|
|
|
|
// Ideally, all logic in SetupDynamicConfig would be converted to
|
|
|
|
|
// callbacks in the config schema.
|
|
|
|
|
require __DIR__ . '/SetupDynamicConfig.php';
|
|
|
|
|
|
2021-11-11 20:31:47 +00:00
|
|
|
// All settings should be loaded now.
|
2021-12-01 16:16:06 +00:00
|
|
|
$wgSettings->finalize();
|
2022-01-27 20:24:12 +00:00
|
|
|
if ( $wgBaseDirectory !== MW_INSTALL_PATH ) {
|
|
|
|
|
throw new FatalError(
|
|
|
|
|
'$wgBaseDirectory must not be modified in settings files! ' .
|
|
|
|
|
'Use the MW_INSTALL_PATH environment variable to override the installation root directory.'
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-11-11 20:31:47 +00:00
|
|
|
|
2021-01-06 05:23:15 +00:00
|
|
|
// Start time limit
|
|
|
|
|
if ( $wgRequestTimeLimit && !$wgCommandLineMode ) {
|
|
|
|
|
RequestTimeout::singleton()->setWallTimeLimit( $wgRequestTimeLimit );
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-19 19:24:19 +00:00
|
|
|
/**
|
2020-03-14 18:56:18 +00:00
|
|
|
* Load queued extensions
|
2017-09-19 19:24:19 +00:00
|
|
|
*/
|
|
|
|
|
|
Implement extension registration from an extension.json file
Introduces wfLoadExtension()/wfLoadSkin() which should be used in
LocalSettings.php rather than require-ing a PHP entry point.
Extensions and skins would add "extension.json" or "skin.json" files
in their root, which contains all the information typically
present in PHP entry point files (classes to autoload, special pages,
API modules, etc.) A full schema can be found at
docs/extension.schema.json, and a script to validate these to the
schema is provided. An additional script is provided to convert
typical PHP entry point files into their JSON equivalents.
The basic flow of loading an extension goes like:
* Get the ExtensionRegistry singleton instance
* ExtensionRegistry takes a filename, reads the file or tries
to get the parsed JSON from APC if possible.
* The JSON is run through a Processor instance,
which registers things with the appropriate
global settings.
* The output of the processor is cached in APC if possible.
* The extension/skin is marked as loaded in the
ExtensionRegistry and a callback function is executed
if one was specified.
For ideal performance, a batch loading method is also provided:
* The absolute path name to the JSON file is queued
in the ExtensionRegistry instance.
* When loadFromQueue() is called, it constructs a hash
unique to the members of the current queue, and sees
if the queue has been cached in APC. If not, it processes
each file individually, and combines the result of each
Processor into one giant array, which is cached in APC.
* The giant array then sets various global settings,
defines constants, and calls callbacks.
To invalidate the cached processed info, by default the mtime
of each JSON file is checked. However that can be slow if you
have a large number of extensions, so you can set $wgExtensionInfoMTime
to the mtime of one file, and `touch` it whenever you update
your extensions.
Change-Id: I7074b65d07c5c7d4e3f1fb0755d74a0b07ed4596
2014-10-15 00:31:15 +00:00
|
|
|
ExtensionRegistry::getInstance()->loadFromQueue();
|
2016-12-03 17:46:48 +00:00
|
|
|
// Don't let any other extensions load
|
|
|
|
|
ExtensionRegistry::getInstance()->finish();
|
Implement extension registration from an extension.json file
Introduces wfLoadExtension()/wfLoadSkin() which should be used in
LocalSettings.php rather than require-ing a PHP entry point.
Extensions and skins would add "extension.json" or "skin.json" files
in their root, which contains all the information typically
present in PHP entry point files (classes to autoload, special pages,
API modules, etc.) A full schema can be found at
docs/extension.schema.json, and a script to validate these to the
schema is provided. An additional script is provided to convert
typical PHP entry point files into their JSON equivalents.
The basic flow of loading an extension goes like:
* Get the ExtensionRegistry singleton instance
* ExtensionRegistry takes a filename, reads the file or tries
to get the parsed JSON from APC if possible.
* The JSON is run through a Processor instance,
which registers things with the appropriate
global settings.
* The output of the processor is cached in APC if possible.
* The extension/skin is marked as loaded in the
ExtensionRegistry and a callback function is executed
if one was specified.
For ideal performance, a batch loading method is also provided:
* The absolute path name to the JSON file is queued
in the ExtensionRegistry instance.
* When loadFromQueue() is called, it constructs a hash
unique to the members of the current queue, and sees
if the queue has been cached in APC. If not, it processes
each file individually, and combines the result of each
Processor into one giant array, which is cached in APC.
* The giant array then sets various global settings,
defines constants, and calls callbacks.
To invalidate the cached processed info, by default the mtime
of each JSON file is checked. However that can be slow if you
have a large number of extensions, so you can set $wgExtensionInfoMTime
to the mtime of one file, and `touch` it whenever you update
your extensions.
Change-Id: I7074b65d07c5c7d4e3f1fb0755d74a0b07ed4596
2014-10-15 00:31:15 +00:00
|
|
|
|
2021-09-21 05:40:55 +00:00
|
|
|
// Set an appropriate locale (T291234)
|
|
|
|
|
// setlocale() will return the locale name actually set.
|
|
|
|
|
// The putenv() is meant to propagate the choice of locale to shell commands
|
|
|
|
|
// so that they will interpret UTF-8 correctly. If you have a problem with a
|
|
|
|
|
// shell command and need to send a special locale, you can override the locale
|
|
|
|
|
// with Command::environment().
|
|
|
|
|
putenv( "LC_ALL=" . setlocale( LC_ALL, 'C.UTF-8', 'C' ) );
|
2017-05-09 16:12:41 +00:00
|
|
|
|
2022-07-09 16:06:21 +00:00
|
|
|
// Set PHP runtime to the desired timezone
|
|
|
|
|
date_default_timezone_set( $wgLocaltimezone );
|
|
|
|
|
|
2019-08-31 22:43:23 +00:00
|
|
|
MWDebug::setup();
|
2011-12-04 18:29:57 +00:00
|
|
|
|
2020-12-22 14:51:13 +00:00
|
|
|
// Enable the global service locator.
|
2021-07-26 16:48:37 +00:00
|
|
|
// Trivial expansion of site configuration should go before this point.
|
|
|
|
|
// Any non-trivial expansion that requires calling into MediaWikiServices or other parts of MW.
|
2020-12-22 14:51:13 +00:00
|
|
|
MediaWikiServices::allowGlobalInstance();
|
2016-09-15 18:52:55 +00:00
|
|
|
|
2016-05-01 19:29:11 +00:00
|
|
|
// Define a constant that indicates that the bootstrapping of the service locator
|
|
|
|
|
// is complete.
|
|
|
|
|
define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
|
|
|
|
|
|
2022-05-19 12:57:14 +00:00
|
|
|
MWExceptionRenderer::setShowExceptionDetails( $wgShowExceptionDetails );
|
2022-01-28 19:33:21 +00:00
|
|
|
MWExceptionHandler::installHandler( $wgLogExceptionBacktrace, $wgPropagateErrors );
|
The beginnings of HipHop compiled mode support. It works now for parser cache hits.
* Work around HipHop issue 314 (volatile broken) and issue 308 (no compilation detection) by adding some large and ugly compilation detection code to WebStart.php and doMaintenance.php.
* Provide an MW_COMPILED constant which can be used to detect compiled mode throughout the codebase.
* Introduced wfIsHipHop(), which detects either compiled or interpreted mode. Used this to work around unusual eval() return value in eval.php.
* Work around lack of ini_get() in Maintenance.php, by duplicating wfIsHipHop().
* In Maintenance::shouldExecute(), accept "include" as an inclusion function name, since all kinds of inclusion give this string in HipHop.
* Introduced new class MWInit, which provides some static functions in the pre-autoloader environment.
* Introduced MWInit::compiledPath(), which provides a relative path for invoking a compiled file, and MWInit::interpretedPath(), which provides an absolute path for interpreting a PHP file. Used these new functions in the appropriate places.
* When we are running compiled code, don't include files which would generate duplicate class, function or constant definitions. Documented the new requirements on the contents of Defines.php and UtfNormalDefines.php.
* In HipHop compiled mode, it's not possible to have executable code in the same file as a class definition.
** Moved MimeMagic initialisation to the constructor.
** Moved Namespace.php global variable initialisation to Setup.php.
** Moved MemcachedSessions.php initialisation to the caller in GlobalFunctions.php.
** Moved Sanitizer.php constants and global variables to static class members. Introduced an accessor function for the attribs regex, as a new place to put code formerly at file level.
** Moved Language.php initialisation of $wgLanguageNames to Language::getLanguageNames(). Removed the global variable, marked "private" since forever.
* In two places: don't use error_log() with type=3 to append to a file, HipHop doesn't support it. Use file_put_contents() with FILE_APPEND instead.
* Work around the terrible breakage of class_exists() by using MWInit::classExists() instead in various places. In WebInstaller::getPageByName(), the class_exists() was marked with a fixme comment already, so I replaced it with an autoloader solution.
2011-04-04 12:59:55 +00:00
|
|
|
|
2021-07-31 19:05:38 +00:00
|
|
|
// Non-trivial validation of: $wgServer
|
|
|
|
|
// The FatalError page only renders cleanly after MWExceptionHandler is installed.
|
|
|
|
|
if ( $wgServer === false ) {
|
|
|
|
|
// T30798: $wgServer must be explicitly set
|
|
|
|
|
throw new FatalError(
|
|
|
|
|
'$wgServer must be set in LocalSettings.php. ' .
|
|
|
|
|
'See <a href="https://www.mediawiki.org/wiki/Manual:$wgServer">' .
|
|
|
|
|
'https://www.mediawiki.org/wiki/Manual:$wgServer</a>.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-26 16:48:37 +00:00
|
|
|
// Non-trivial expansion of: $wgCanonicalServer, $wgServerName.
|
|
|
|
|
// These require calling global functions.
|
|
|
|
|
// Also here are other settings that further depend on these two.
|
2014-05-06 09:31:24 +00:00
|
|
|
if ( $wgCanonicalServer === false ) {
|
|
|
|
|
$wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
|
|
|
|
|
}
|
2021-07-26 16:48:37 +00:00
|
|
|
$wgVirtualRestConfig['global']['domain'] = $wgCanonicalServer;
|
2014-05-06 09:31:24 +00:00
|
|
|
|
|
|
|
|
$serverParts = wfParseUrl( $wgCanonicalServer );
|
|
|
|
|
if ( $wgServerName !== false ) {
|
2014-05-11 15:33:33 +00:00
|
|
|
wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
|
|
|
|
|
. 'not customized. Overwriting $wgServerName.' );
|
2014-05-06 09:31:24 +00:00
|
|
|
}
|
|
|
|
|
$wgServerName = $serverParts['host'];
|
|
|
|
|
unset( $serverParts );
|
|
|
|
|
|
2021-07-26 16:48:37 +00:00
|
|
|
// $wgEmergencyContact and $wgPasswordSender may be false or empty string (T104142)
|
2015-08-31 15:32:56 +00:00
|
|
|
if ( !$wgEmergencyContact ) {
|
2014-05-06 09:31:24 +00:00
|
|
|
$wgEmergencyContact = 'wikiadmin@' . $wgServerName;
|
|
|
|
|
}
|
2015-08-31 15:32:56 +00:00
|
|
|
if ( !$wgPasswordSender ) {
|
2014-05-06 09:31:24 +00:00
|
|
|
$wgPasswordSender = 'apache@' . $wgServerName;
|
|
|
|
|
}
|
2015-04-30 21:38:05 +00:00
|
|
|
if ( !$wgNoReplyAddress ) {
|
2016-03-18 14:19:07 +00:00
|
|
|
$wgNoReplyAddress = $wgPasswordSender;
|
2015-04-30 21:38:05 +00:00
|
|
|
}
|
2014-05-06 09:31:24 +00:00
|
|
|
|
2021-07-26 16:48:37 +00:00
|
|
|
// Non-trivial expansion of: $wgSecureLogin
|
|
|
|
|
// (due to calling wfWarn).
|
2012-10-08 04:21:08 +00:00
|
|
|
if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
|
|
|
|
|
$wgSecureLogin = false;
|
2014-05-11 15:33:33 +00:00
|
|
|
wfWarn( 'Secure login was enabled on a server that only supports '
|
|
|
|
|
. 'HTTP or HTTPS. Disabling secure login.' );
|
2012-10-08 04:21:08 +00:00
|
|
|
}
|
|
|
|
|
|
2015-01-07 21:57:56 +00:00
|
|
|
// Now that GlobalFunctions is loaded, set defaults that depend on it.
|
2012-05-26 03:19:55 +00:00
|
|
|
if ( $wgTmpDirectory === false ) {
|
|
|
|
|
$wgTmpDirectory = wfTempDir();
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-22 16:03:50 +00:00
|
|
|
if ( $wgSharedDB && $wgSharedTables ) {
|
|
|
|
|
// Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
|
|
|
|
|
MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
|
|
|
|
|
array_fill_keys(
|
|
|
|
|
$wgSharedTables,
|
|
|
|
|
[
|
|
|
|
|
'dbname' => $wgSharedDB,
|
|
|
|
|
'schema' => $wgSharedSchema,
|
|
|
|
|
'prefix' => $wgSharedPrefix
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-13 20:07:50 +00:00
|
|
|
// Raise the memory limit if it's too low
|
2021-07-26 16:48:37 +00:00
|
|
|
// NOTE: This use wfDebug, and must remain after the MWDebug::setup() call.
|
2019-07-13 01:05:54 +00:00
|
|
|
wfMemoryLimit( $wgMemoryLimit );
|
2006-07-26 07:15:39 +00:00
|
|
|
|
2022-02-21 16:21:36 +00:00
|
|
|
// Explicit globals, so this works with bootstrap.php
|
|
|
|
|
global $wgRequest, $wgInitialSessionId;
|
|
|
|
|
|
2017-11-29 02:40:04 +00:00
|
|
|
// Initialize the request object in $wgRequest
|
2015-11-17 18:43:47 +00:00
|
|
|
$wgRequest = RequestContext::getMain()->getRequest(); // BackCompat
|
2021-04-15 22:48:58 +00:00
|
|
|
|
2018-02-01 00:47:09 +00:00
|
|
|
// 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
|
|
|
|
|
// be reflected in their subsequent web requests. Avoid the use of interim cache keys because
|
|
|
|
|
// they use a blind TTL and could be stale if an object changes twice in a short time span.
|
2017-11-29 04:39:47 +00:00
|
|
|
MediaWikiServices::getInstance()->getMainWANObjectCache()->useInterimHoldOffCaching( false );
|
|
|
|
|
}
|
2015-11-17 18:43:47 +00:00
|
|
|
|
2014-04-13 20:07:50 +00:00
|
|
|
// Useful debug output
|
2021-02-10 22:31:02 +00:00
|
|
|
( static function () {
|
2020-06-01 05:00:39 +00:00
|
|
|
global $wgCommandLineMode, $wgRequest;
|
|
|
|
|
$logger = LoggerFactory::getInstance( 'wfDebug' );
|
|
|
|
|
if ( $wgCommandLineMode ) {
|
|
|
|
|
$self = $_SERVER['PHP_SELF'] ?? '';
|
|
|
|
|
$logger->debug( "\n\nStart command line script $self" );
|
|
|
|
|
} else {
|
|
|
|
|
$debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
|
|
|
|
|
$debug .= "IP: " . $wgRequest->getIP() . "\n";
|
|
|
|
|
$debug .= "HTTP HEADERS:\n";
|
|
|
|
|
foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
|
|
|
|
|
$debug .= "$name: $value\n";
|
|
|
|
|
}
|
|
|
|
|
$debug .= "(end headers)";
|
|
|
|
|
$logger->debug( $debug );
|
2010-01-27 17:21:18 +00:00
|
|
|
}
|
2020-06-01 05:00:39 +00:00
|
|
|
} )();
|
2003-08-11 13:53:20 +00:00
|
|
|
|
2014-04-13 20:07:50 +00:00
|
|
|
// Most of the config is out, some might want to run hooks here.
|
Hooks::run() call site migration
Migrate all callers of Hooks::run() to use the new
HookContainer/HookRunner system.
General principles:
* Use DI if it is already used. We're not changing the way state is
managed in this patch.
* HookContainer is always injected, not HookRunner. HookContainer
is a service, it's a more generic interface, it is the only
thing that provides isRegistered() which is needed in some cases,
and a HookRunner can be efficiently constructed from it
(confirmed by benchmark). Because HookContainer is needed
for object construction, it is also needed by all factories.
* "Ask your friendly local base class". Big hierarchies like
SpecialPage and ApiBase have getHookContainer() and getHookRunner()
methods in the base class, and classes that extend that base class
are not expected to know or care where the base class gets its
HookContainer from.
* ProtectedHookAccessorTrait provides protected getHookContainer() and
getHookRunner() methods, getting them from the global service
container. The point of this is to ease migration to DI by ensuring
that call sites ask their local friendly base class rather than
getting a HookRunner from the service container directly.
* Private $this->hookRunner. In some smaller classes where accessor
methods did not seem warranted, there is a private HookRunner property
which is accessed directly. Very rarely (two cases), there is a
protected property, for consistency with code that conventionally
assumes protected=private, but in cases where the class might actually
be overridden, a protected accessor is preferred over a protected
property.
* The last resort: Hooks::runner(). Mostly for static, file-scope and
global code. In a few cases it was used for objects with broken
construction schemes, out of horror or laziness.
Constructors with new required arguments:
* AuthManager
* BadFileLookup
* BlockManager
* ClassicInterwikiLookup
* ContentHandlerFactory
* ContentSecurityPolicy
* DefaultOptionsManager
* DerivedPageDataUpdater
* FullSearchResultWidget
* HtmlCacheUpdater
* LanguageFactory
* LanguageNameUtils
* LinkRenderer
* LinkRendererFactory
* LocalisationCache
* MagicWordFactory
* MessageCache
* NamespaceInfo
* PageEditStash
* PageHandlerFactory
* PageUpdater
* ParserFactory
* PermissionManager
* RevisionStore
* RevisionStoreFactory
* SearchEngineConfig
* SearchEngineFactory
* SearchFormWidget
* SearchNearMatcher
* SessionBackend
* SpecialPageFactory
* UserNameUtils
* UserOptionsManager
* WatchedItemQueryService
* WatchedItemStore
Constructors with new optional arguments:
* DefaultPreferencesFactory
* Language
* LinkHolderArray
* MovePage
* Parser
* ParserCache
* PasswordReset
* Router
setHookContainer() now required after construction:
* AuthenticationProvider
* ResourceLoaderModule
* SearchEngine
Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
2020-03-19 02:42:09 +00:00
|
|
|
Hooks::runner()->onSetupAfterCache();
|
2008-12-10 23:15:50 +00:00
|
|
|
|
2021-07-26 16:59:05 +00:00
|
|
|
// Now that variant lists may be available, parse any action paths and article paths
|
|
|
|
|
// as query parameters.
|
|
|
|
|
//
|
|
|
|
|
// Skip title interpolation on API queries where it is useless and sometimes harmful (T18019).
|
|
|
|
|
//
|
|
|
|
|
// Optimization: Skip on load.php and all other entrypoints besides index.php to save time.
|
|
|
|
|
//
|
|
|
|
|
// TODO: Figure out if this can be safely done after everything else in Setup.php (e.g. any
|
|
|
|
|
// hooks or other state that would miss this?). If so, move to wfIndexMain or MediaWiki::run.
|
|
|
|
|
if ( MW_ENTRY_POINT === 'index' ) {
|
|
|
|
|
$wgRequest->interpolateTitle();
|
|
|
|
|
}
|
2014-04-01 19:03:00 +00:00
|
|
|
|
2016-02-01 20:44:03 +00:00
|
|
|
/**
|
2020-04-07 21:38:17 +00:00
|
|
|
* @var MediaWiki\Session\SessionId|null The persistent session ID (if any) loaded at startup
|
2016-02-01 20:44:03 +00:00
|
|
|
*/
|
|
|
|
|
$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' ) ) {
|
2021-01-06 05:23:15 +00:00
|
|
|
HeaderCallback::warnIfHeadersSent();
|
2018-06-11 09:16:48 +00:00
|
|
|
session_name( $wgSessionName ?: $wgCookiePrefix . '_session' );
|
2016-02-01 20:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-18 20:56:40 +00:00
|
|
|
// Create the SessionManager singleton and set up our session handler,
|
|
|
|
|
// unless we're specifically asked not to.
|
|
|
|
|
if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
|
|
|
|
|
MediaWiki\Session\PHPSessionHandler::install(
|
|
|
|
|
MediaWiki\Session\SessionManager::singleton()
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-02-01 20:44:03 +00:00
|
|
|
|
2020-05-08 18:11:23 +00:00
|
|
|
$contLang = MediaWikiServices::getInstance()->getContentLanguage();
|
|
|
|
|
|
2016-02-01 20:44:03 +00:00
|
|
|
// Initialize the session
|
|
|
|
|
try {
|
|
|
|
|
$session = MediaWiki\Session\SessionManager::getGlobalSession();
|
2019-09-07 14:21:09 +00:00
|
|
|
} catch ( MediaWiki\Session\SessionOverflowException $ex ) {
|
|
|
|
|
// The exception is because the request had multiple possible
|
|
|
|
|
// sessions tied for top priority. Report this to the user.
|
|
|
|
|
$list = [];
|
|
|
|
|
foreach ( $ex->getSessionInfos() as $info ) {
|
2020-05-08 18:11:23 +00:00
|
|
|
$list[] = $info->getProvider()->describe( $contLang );
|
2016-02-01 20:44:03 +00:00
|
|
|
}
|
2020-05-08 18:11:23 +00:00
|
|
|
$list = $contLang->listToText( $list );
|
2019-09-07 14:21:09 +00:00
|
|
|
throw new HttpError( 400,
|
2020-05-08 18:11:23 +00:00
|
|
|
Message::newFromKey( 'sessionmanager-tie', $list )->inLanguage( $contLang )
|
2019-09-07 14:21:09 +00:00
|
|
|
);
|
2016-02-01 20:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-08 18:11:23 +00:00
|
|
|
unset( $contLang );
|
|
|
|
|
|
2016-02-01 20:44:03 +00:00
|
|
|
if ( $session->isPersistent() ) {
|
|
|
|
|
$wgInitialSessionId = $session->getSessionId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$session->renew();
|
|
|
|
|
if ( MediaWiki\Session\PHPSessionHandler::isEnabled() &&
|
2019-01-12 19:16:52 +00:00
|
|
|
( $session->isPersistent() || $session->shouldRememberUser() ) &&
|
|
|
|
|
session_id() !== $session->getId()
|
2016-02-01 20:44:03 +00:00
|
|
|
) {
|
|
|
|
|
// Start the PHP-session for backwards compatibility
|
2019-01-12 19:16:52 +00:00
|
|
|
if ( session_id() !== '' ) {
|
|
|
|
|
wfDebugLog( 'session', 'PHP session {old_id} was already started, changing to {new_id}', 'all', [
|
|
|
|
|
'old_id' => session_id(),
|
|
|
|
|
'new_id' => $session->getId(),
|
|
|
|
|
] );
|
|
|
|
|
session_write_close();
|
|
|
|
|
}
|
2016-02-01 20:44:03 +00:00
|
|
|
session_id( $session->getId() );
|
2019-01-12 19:16:52 +00:00
|
|
|
session_start();
|
2016-02-01 20:44:03 +00:00
|
|
|
}
|
2016-02-18 20:56:40 +00:00
|
|
|
|
|
|
|
|
unset( $session );
|
|
|
|
|
} else {
|
|
|
|
|
// Even if we didn't set up a global Session, still install our session
|
|
|
|
|
// handler unless specifically requested not to.
|
|
|
|
|
if ( !defined( 'MW_NO_SESSION_HANDLER' ) ) {
|
|
|
|
|
MediaWiki\Session\PHPSessionHandler::install(
|
|
|
|
|
MediaWiki\Session\SessionManager::singleton()
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-02-01 20:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
2022-02-21 16:21:36 +00:00
|
|
|
// Explicit globals, so this works with bootstrap.php
|
2019-12-30 06:58:16 +00:00
|
|
|
global $wgUser, $wgLang, $wgOut, $wgTitle;
|
2022-02-21 16:21:36 +00:00
|
|
|
|
2014-04-01 19:03:00 +00:00
|
|
|
/**
|
|
|
|
|
* @var User $wgUser
|
2020-03-21 01:43:22 +00:00
|
|
|
* @deprecated since 1.35, use an available context source when possible, or, as a backup,
|
|
|
|
|
* RequestContext::getMain()
|
2014-04-01 19:03:00 +00:00
|
|
|
*/
|
2021-09-04 19:19:47 +00:00
|
|
|
$wgUser = new StubGlobalUser( RequestContext::getMain()->getUser() ); // BackCompat
|
|
|
|
|
register_shutdown_function( static function () {
|
|
|
|
|
StubGlobalUser::$destructorDeprecationDisarmed = true;
|
|
|
|
|
} );
|
2011-03-24 00:48:22 +00:00
|
|
|
|
2014-02-06 09:04:46 +00:00
|
|
|
/**
|
2020-11-14 07:29:49 +00:00
|
|
|
* @var Language|StubUserLang $wgLang
|
2014-02-06 09:04:46 +00:00
|
|
|
*/
|
|
|
|
|
$wgLang = new StubUserLang;
|
2011-03-24 00:48:22 +00:00
|
|
|
|
2014-02-06 09:04:46 +00:00
|
|
|
/**
|
2014-04-01 19:03:00 +00:00
|
|
|
* @var OutputPage $wgOut
|
2014-02-06 09:04:46 +00:00
|
|
|
*/
|
2014-04-13 20:07:50 +00:00
|
|
|
$wgOut = RequestContext::getMain()->getOutput(); // BackCompat
|
2007-11-20 10:55:08 +00:00
|
|
|
|
2014-04-01 19:03:00 +00:00
|
|
|
/**
|
2020-11-14 07:29:49 +00:00
|
|
|
* @var Title|null $wgTitle
|
2014-04-01 19:03:00 +00:00
|
|
|
*/
|
2014-02-06 09:04:46 +00:00
|
|
|
$wgTitle = null;
|
2004-05-31 08:43:36 +00:00
|
|
|
|
2022-02-21 16:21:36 +00:00
|
|
|
// Explicit globals, so this works with bootstrap.php
|
|
|
|
|
global $wgFullyInitialised, $wgExtensionFunctions;
|
|
|
|
|
|
2015-10-23 18:50:11 +00:00
|
|
|
// Extension setup functions
|
2014-04-13 20:07:50 +00:00
|
|
|
// Entries should be added to this variable during the inclusion
|
|
|
|
|
// of the extension file. This allows the extension to perform
|
|
|
|
|
// any necessary initialisation in the fully initialised environment
|
2008-12-23 23:34:35 +00:00
|
|
|
foreach ( $wgExtensionFunctions as $func ) {
|
2005-12-14 16:46:27 +00:00
|
|
|
call_user_func( $func );
|
2004-05-15 03:36:39 +00:00
|
|
|
}
|
2020-10-27 00:21:47 +00:00
|
|
|
unset( $func ); // no global pollution; destroy reference
|
2004-05-15 03:36:39 +00:00
|
|
|
|
2016-02-01 20:44:03 +00:00
|
|
|
// If the session user has a 0 id but a valid name, that means we need to
|
|
|
|
|
// autocreate it.
|
2016-02-07 22:46:34 +00:00
|
|
|
if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
|
|
|
|
|
$sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
|
2020-08-05 20:20:00 +00:00
|
|
|
if ( $sessionUser->getId() === 0 &&
|
|
|
|
|
MediaWikiServices::getInstance()->getUserNameUtils()->isValid( $sessionUser->getName() )
|
|
|
|
|
) {
|
2020-03-31 18:51:49 +00:00
|
|
|
$res = MediaWikiServices::getInstance()->getAuthManager()->autoCreateUser(
|
2016-04-01 16:49:26 +00:00
|
|
|
$sessionUser,
|
|
|
|
|
MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
|
|
|
|
|
true
|
|
|
|
|
);
|
2016-08-10 01:32:28 +00:00
|
|
|
\MediaWiki\Logger\LoggerFactory::getInstance( 'authevents' )->info( 'Autocreation attempt', [
|
2016-02-11 08:12:45 +00:00
|
|
|
'event' => 'autocreate',
|
2021-03-19 17:01:43 +00:00
|
|
|
'status' => strval( $res ),
|
2016-02-11 08:12:45 +00:00
|
|
|
] );
|
|
|
|
|
unset( $res );
|
2016-02-07 22:46:34 +00:00
|
|
|
}
|
|
|
|
|
unset( $sessionUser );
|
2016-02-01 20:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-30 09:29:10 +00:00
|
|
|
if ( !$wgCommandLineMode ) {
|
|
|
|
|
Pingback::schedulePingback();
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-11 16:02:43 +00:00
|
|
|
$settingsWarnings = $wgSettings->getWarnings();
|
|
|
|
|
if ( $settingsWarnings ) {
|
|
|
|
|
$logger = LoggerFactory::getInstance( 'Settings' );
|
|
|
|
|
foreach ( $settingsWarnings as $msg ) {
|
|
|
|
|
$logger->warning( $msg );
|
|
|
|
|
}
|
|
|
|
|
unset( $logger );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset( $settingsWarnings );
|
|
|
|
|
|
2022-02-21 16:28:35 +00:00
|
|
|
// Explicit globals, so this works with bootstrap.php
|
|
|
|
|
global $wgFullyInitialised;
|
2004-07-18 08:48:43 +00:00
|
|
|
$wgFullyInitialised = true;
|
2016-02-07 19:24:05 +00:00
|
|
|
|
|
|
|
|
// T264370
|
|
|
|
|
if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
|
|
|
|
|
MediaWiki\Session\SessionManager::singleton()->logPotentialSessionLeakage();
|
|
|
|
|
}
|