Merge ".mailmap: Correct two contributor names"
[mediawiki.git] / mw-config / index.php
blob563cc64ca90b5bf7ce7a7c8de24d55337f200340
1 <?php
2 // phpcs:disable Generic.Arrays.DisallowLongArraySyntax
3 /**
4 * New version of MediaWiki web-based config/installation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
21 * @file
24 use MediaWiki\Context\RequestContext;
25 use MediaWiki\Installer\Installer;
26 use MediaWiki\Installer\InstallerOverrides;
27 use MediaWiki\MediaWikiServices;
29 // Bail on old versions of PHP, or if composer has not been run yet to install
30 // dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+.
31 // phpcs:ignore MediaWiki.Usage.DirUsage.FunctionFound
32 require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php';
33 wfEntryPointCheck( 'html', dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
35 define( 'MW_CONFIG_CALLBACK', [ Installer::class, 'overrideConfig' ] );
36 define( 'MEDIAWIKI_INSTALL', true );
38 // Resolve relative to regular MediaWiki root
39 // instead of mw-config subdirectory.
40 chdir( dirname( __DIR__ ) );
41 require dirname( __DIR__ ) . '/includes/WebStart.php';
43 wfInstallerMain();
45 function wfInstallerMain() {
46 global $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
47 $request = RequestContext::getMain()->getRequest();
49 $installer = InstallerOverrides::getWebInstaller( $request );
51 if ( !$installer->startSession() ) {
52 if ( $installer->request->getCheck( 'css' ) ) {
53 // Do not display errors on css pages
54 $installer->outputCss();
55 exit;
58 $errors = $installer->getPhpErrors();
59 $installer->showError( 'config-session-error', $errors[0] );
60 $installer->finish();
61 exit;
64 $fingerprint = $installer->getFingerprint();
65 if ( isset( $_SESSION['installData'][$fingerprint] ) ) {
66 $session = $_SESSION['installData'][$fingerprint];
67 } else {
68 $session = array();
71 $services = MediaWikiServices::getInstance();
72 $languageFactory = $services->getLanguageFactory();
73 $languageNameUtils = $services->getLanguageNameUtils();
75 $langCode = 'en';
76 if ( isset( $session['settings']['_UserLang'] ) &&
77 $languageNameUtils->isKnownLanguageTag( $session['settings']['_UserLang'] )
78 ) {
79 $langCode = $session['settings']['_UserLang'];
81 $uselang = $request->getRawVal( 'uselang' );
82 if ( $uselang !== null && $languageNameUtils->isKnownLanguageTag( $uselang ) ) {
83 $langCode = $uselang;
85 $wgLang = $languageFactory->getRawLanguage( $langCode );
87 RequestContext::getMain()->setLanguage( $wgLang );
89 $installer->setParserLanguage( $wgLang );
91 $wgMetaNamespace = $wgCanonicalNamespaceNames[NS_PROJECT];
93 $session = $installer->execute( $session );
95 $_SESSION['installData'][$fingerprint] = $session;