MediaWiki master
index.php
Go to the documentation of this file.
1<?php
2// phpcs:disable Generic.Arrays.DisallowLongArraySyntax
14
15// Bail on old versions of PHP, or if composer has not been run yet to install
16// dependencies. Using dirname( __FILE__ ) here because __DIR__ is PHP5.3+.
17// phpcs:ignore MediaWiki.Usage.DirUsage.FunctionFound
18require_once dirname( __FILE__ ) . '/../includes/PHPVersionCheck.php';
19wfEntryPointCheck( 'html', dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
20
21define( 'MW_CONFIG_CALLBACK', [ Installer::class, 'overrideConfig' ] );
22define( 'MEDIAWIKI_INSTALL', true );
23
24// Resolve relative to regular MediaWiki root
25// instead of mw-config subdirectory.
26chdir( dirname( __DIR__ ) );
27require dirname( __DIR__ ) . '/includes/WebStart.php';
28
30
31function wfInstallerMain() {
33 $request = RequestContext::getMain()->getRequest();
34
35 $installer = InstallerOverrides::getWebInstaller( $request );
36
37 if ( !$installer->startSession() ) {
38 if ( $installer->request->getCheck( 'css' ) ) {
39 // Do not display errors on css pages
40 $installer->outputCss();
41 exit;
42 }
43
44 $errors = $installer->getPhpErrors();
45 $installer->showError( 'config-session-error', $errors[0] );
46 $installer->finish();
47 exit;
48 }
49
50 $fingerprint = $installer->getFingerprint();
51 if ( isset( $_SESSION['installData'][$fingerprint] ) ) {
52 $session = $_SESSION['installData'][$fingerprint];
53 } else {
54 $session = array();
55 }
56
57 $services = MediaWikiServices::getInstance();
58 $languageFactory = $services->getLanguageFactory();
59 $languageNameUtils = $services->getLanguageNameUtils();
60
61 $langCode = 'en';
62 if ( isset( $session['settings']['_UserLang'] ) &&
63 $languageNameUtils->isKnownLanguageTag( $session['settings']['_UserLang'] )
64 ) {
65 $langCode = $session['settings']['_UserLang'];
66 }
67 $uselang = $request->getRawVal( 'uselang' );
68 if ( $uselang !== null && $languageNameUtils->isKnownLanguageTag( $uselang ) ) {
69 $langCode = $uselang;
70 }
71 $wgLang = $languageFactory->getRawLanguage( $langCode );
72
73 RequestContext::getMain()->setLanguage( $wgLang );
74
75 $installer->setParserLanguage( $wgLang );
76
78
79 $session = $installer->execute( $session );
80
81 $_SESSION['installData'][$fingerprint] = $session;
82}
const NS_PROJECT
Definition Defines.php:55
wfEntryPointCheck( $format='text', $scriptPath='/')
Check PHP version and that external dependencies are installed, and display an informative error if e...
if(MW_ENTRY_POINT==='index') if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgLang
Definition Setup.php:551
Group all the pieces relevant to the context of a request into one instance.
Base installer class.
Definition Installer.php:70
Service locator for MediaWiki core services.
$wgCanonicalNamespaceNames
Config variable stub for the CanonicalNamespaceNames setting, for use by phpdoc and IDEs.
$wgMetaNamespace
Config variable stub for the MetaNamespace setting, for use by phpdoc and IDEs.
wfInstallerMain()
Definition index.php:31