MediaWiki
master
doMaintenance.php
Go to the documentation of this file.
1
<?php
14
use
MediaWiki\Maintenance\MaintenanceRunner
;
15
use
MediaWiki\Settings\SettingsBuilder
;
16
17
// No AutoLoader yet
18
require_once __DIR__ .
'/includes/MaintenanceRunner.php'
;
19
require_once __DIR__ .
'/includes/MaintenanceParameters.php'
;
20
21
if
( !defined(
'RUN_MAINTENANCE_IF_MAIN'
) ) {
22
echo
"This file must be included after Maintenance.php\n"
;
23
exit( 1 );
24
}
25
26
// Wasn't included from the file scope, halt execution (probably wanted the class).
27
// This typically happens when a maintenance script is executed using run.php.
28
// @phan-suppress-next-line PhanRedundantValueComparisonInGlobalScope
29
if
( !MaintenanceRunner::shouldExecute() &&
$maintClass
!= CommandLineInc::class ) {
30
return
;
31
}
32
33
// @phan-suppress-next-line PhanImpossibleConditionInGlobalScope
34
if
( !
$maintClass
|| !class_exists(
$maintClass
) ) {
35
echo
"\$maintClass is not set or is set to a non-existent class.\n"
;
36
exit( 1 );
37
}
38
39
// Define the MediaWiki entrypoint
40
define(
'MEDIAWIKI'
,
true
);
41
42
$IP
=
wfDetectInstallPath
();
43
require_once
"$IP/includes/AutoLoader.php"
;
44
45
$runner
=
new
MaintenanceRunner
();
46
$runner
->initForClass(
$maintClass
, $GLOBALS[
'argv'
] );
47
48
// We used to call this variable $self, but it was moved
49
// to $maintenance->mSelf. Keep that here for b/c
50
$self
=
$runner
->getName();
51
52
$runner
->defineSettings();
53
54
// Custom setup for Maintenance entry point
55
if
( !defined(
'MW_FINAL_SETUP_CALLBACK'
) ) {
56
61
function
wfMaintenanceSetup(
SettingsBuilder
$settingsBuilder ) {
62
global
$runner
;
63
$runner
->setup( $settingsBuilder );
64
}
65
66
define(
'MW_FINAL_SETUP_CALLBACK'
,
'wfMaintenanceSetup'
);
67
}
68
69
// Initialize MediaWiki (load settings, initialized session,
70
// enable MediaWikiServices)
71
require_once
"$IP/includes/Setup.php"
;
72
73
// We only get here if the script was invoked directly.
74
// If it was loaded by MaintenanceRunner, MaintenanceRunner::shouldExecute() would have returned false,
75
// and we would have returned from this file early.
76
77
if
( stream_isatty( STDOUT ) ) {
78
echo
"\n"
;
79
echo
"*******************************************************************************\n"
;
80
echo
"NOTE: Do not run maintenance scripts directly, use maintenance/run.php instead!\n"
;
81
echo
" Running scripts directly has been deprecated in MediaWiki 1.40.\n"
;
82
echo
" It may not work for some (or any) scripts in the future.\n"
;
83
echo
"*******************************************************************************\n"
;
84
echo
"\n"
;
85
}
86
87
// Do it!
88
$success
=
$runner
->run();
89
90
// Exit with an error status if execute() returned false
91
if
( !
$success
) {
92
exit( 1 );
93
}
wfDetectInstallPath
wfDetectInstallPath()
Decide and remember where mediawiki is installed.
Definition
BootstrapHelperFunctions.php:66
$maintClass
$maintClass
Definition
addChangeTag.php:56
MediaWiki\Maintenance\MaintenanceRunner
A runner for maintenance scripts.
Definition
MaintenanceRunner.php:25
MediaWiki\Settings\SettingsBuilder
Builder class for constructing a Config object from a set of sources during bootstrap.
Definition
SettingsBuilder.php:55
$IP
$IP
Definition
doMaintenance.php:42
$self
$self
Definition
doMaintenance.php:50
$runner
$runner
Definition
doMaintenance.php:45
$success
if(stream_isatty(STDOUT)) $success
Definition
doMaintenance.php:88
maintenance
doMaintenance.php
Generated on Fri Feb 13 2026 12:28:57 for MediaWiki by
1.10.0