MediaWiki master
Maintenance.php
Go to the documentation of this file.
1<?php
14if ( !defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
15 // Define this so scripts can easily find doMaintenance.php
16 define( 'RUN_MAINTENANCE_IF_MAIN', __DIR__ . '/doMaintenance.php' );
17
18 // Original name for compat, harmless
19 // Support: MediaWiki < 1.31
20 define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN );
21}
22
23if ( defined( 'MEDIAWIKI' ) ) {
24 // This file is included by many autoloaded class files, and so may
25 // potentially be invoked in the context of a web request or another CLI
26 // script. It's not appropriate to run the following file-scope code in
27 // such a case.
28 return;
29}
30
31// Abort if called from a web server
32// wfIsCLI() is not available yet
33if ( PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg' ) {
34 echo "This script must be run from the command line\n";
35 exit( 1 );
36}
37
38define( 'MW_ENTRY_POINT', 'cli' );
39
40// Bail on old versions of PHP, or if composer has not been run yet to install
41// dependencies.
42require_once __DIR__ . '/../includes/BootstrapHelperFunctions.php';
43require_once __DIR__ . '/../includes/PHPVersionCheck.php';
44wfEntryPointCheck( 'text' );
45
51
52// Some extensions rely on MW_INSTALL_PATH to find core files to include. Setting it here helps them
53// if they're included by a core script (like DatabaseUpdater) after Maintenance.php has already
54// been run.
55if ( strval( getenv( 'MW_INSTALL_PATH' ) ) === '' ) {
56 putenv( 'MW_INSTALL_PATH=' . realpath( __DIR__ . '/..' ) );
57}
58
59require_once __DIR__ . '/includes/Maintenance.php';
60require_once __DIR__ . '/includes/LoggedUpdateMaintenance.php';
61require_once __DIR__ . '/includes/FakeMaintenance.php';
wfEntryPointCheck( $format='text', $scriptPath='/')
Check PHP version and that external dependencies are installed, and display an informative error if e...
$maintClass