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