MediaWiki master
BootstrapHelperFunctions.php
Go to the documentation of this file.
1<?php
30function wfDetectLocalSettingsFile( ?string $installationPath = null ): string {
31 if ( defined( 'MW_CONFIG_FILE' ) ) {
32 return MW_CONFIG_FILE;
33 }
34
35 $installationPath ??= wfDetectInstallPath();
36
37 // We could look for LocalSettings.yaml and LocalSettings.json,
38 // and use them if they exist. But having them in a web accessible
39 // place is dangerous, so better not to encourage that.
40 // In order to use LocalSettings.yaml and LocalSettings.json, they
41 // will have to be referenced explicitly by MW_CONFIG_FILE.
42 $configFile = getenv( 'MW_CONFIG_FILE' ) ?: "LocalSettings.php";
43 // Can't use str_contains because for maintenance scripts (update.php, install.php),
44 // this is called *before* Setup.php and vendor (polyfill-php80) are included.
45 if ( strpos( $configFile, '/' ) === false ) {
46 $configFile = "$installationPath/$configFile";
47 }
48
49 define( 'MW_CONFIG_FILE', $configFile );
50 return $configFile;
51}
52
66function wfDetectInstallPath(): string {
67 if ( !defined( 'MW_INSTALL_PATH' ) ) {
68 $IP = getenv( 'MW_INSTALL_PATH' );
69 if ( $IP === false ) {
70 $IP = dirname( __DIR__ );
71 }
72 define( 'MW_INSTALL_PATH', $IP );
73 }
74
75 return MW_INSTALL_PATH;
76}
77
83function wfIsWindows() {
84 return PHP_OS_FAMILY === 'Windows';
85}
86
93function wfIsCLI() {
94 return PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg';
95}
wfDetectLocalSettingsFile(?string $installationPath=null)
Decide and remember where to load LocalSettings from.
wfIsWindows()
Check if the operating system is Windows.
wfDetectInstallPath()
Decide and remember where mediawiki is installed.
wfIsCLI()
Check if we are running from the commandline.
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Definition Setup.php:104
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81