MediaWiki
REL1_30
doMaintenance.php
Go to the documentation of this file.
1
<?php
28
use
MediaWiki\MediaWikiServices
;
29
30
if
( !defined(
'RUN_MAINTENANCE_IF_MAIN'
) ) {
31
echo
"This file must be included after Maintenance.php\n"
;
32
exit( 1 );
33
}
34
35
// Wasn't included from the file scope, halt execution (probably wanted the class)
36
// If a class is using commandLine.inc (old school maintenance), they definitely
37
// cannot be included and will proceed with execution
38
if
( !
Maintenance::shouldExecute
() &&
$maintClass
!=
'CommandLineInc'
) {
39
return
;
40
}
41
42
if
( !
$maintClass
|| !class_exists(
$maintClass
) ) {
43
echo
"\$maintClass is not set or is set to a non-existent class.\n"
;
44
exit( 1 );
45
}
46
47
// Get an object to start us off
49
$maintenance
=
new
$maintClass
();
50
51
// Basic sanity checks and such
52
$maintenance
->setup();
53
54
// We used to call this variable $self, but it was moved
55
// to $maintenance->mSelf. Keep that here for b/c
56
$self
=
$maintenance
->getName();
57
58
require_once
"$IP/includes/PreConfigSetup.php"
;
59
60
if
( defined(
'MW_CONFIG_CALLBACK'
) ) {
61
# Use a callback function to configure MediaWiki
62
call_user_func(
MW_CONFIG_CALLBACK
);
63
}
else
{
64
// Require the configuration (probably LocalSettings.php)
65
require
$maintenance
->loadSettings();
66
}
67
68
if
(
$maintenance
->getDbType() ===
Maintenance::DB_NONE
) {
69
if
(
$wgLocalisationCacheConf
[
'storeClass'
] ===
false
70
&& (
$wgLocalisationCacheConf
[
'store'
] ==
'db'
71
|| (
$wgLocalisationCacheConf
[
'store'
] ==
'detect'
&& !
$wgCacheDirectory
) )
72
) {
73
$wgLocalisationCacheConf
[
'storeClass'
] =
'LCStoreNull'
;
74
}
75
}
76
77
$maintenance
->finalSetup();
78
// Some last includes
79
require_once
"$IP/includes/Setup.php"
;
80
81
// Initialize main config instance
82
$maintenance
->setConfig( MediaWikiServices::getInstance()->getMainConfig() );
83
84
// Sanity-check required extensions are installed
85
$maintenance
->checkRequiredExtensions();
86
87
// A good time when no DBs have writes pending is around lag checks.
88
// This avoids having long running scripts just OOM and lose all the updates.
89
$maintenance
->setAgentAndTriggers();
90
91
// Do the work
92
$maintenance
->execute();
93
94
// Potentially debug globals
95
$maintenance
->globals();
96
97
if
(
$maintenance
->getDbType() !==
Maintenance::DB_NONE
) {
98
// Perform deferred updates.
99
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
100
$lbFactory->commitMasterChanges(
$maintClass
);
101
DeferredUpdates::doUpdates
();
102
}
103
104
// log profiling info
105
wfLogProfilingData
();
106
107
if
( isset( $lbFactory ) ) {
108
// Commit and close up!
109
$lbFactory->commitMasterChanges(
'doMaintenance'
);
110
$lbFactory->shutdown( $lbFactory::SHUTDOWN_NO_CHRONPROT );
111
}
$wgCacheDirectory
$wgCacheDirectory
Directory for caching data in the local filesystem.
Definition
DefaultSettings.php:2227
$wgLocalisationCacheConf
$wgLocalisationCacheConf
Localisation cache configuration.
Definition
DefaultSettings.php:2511
wfLogProfilingData
wfLogProfilingData()
Definition
GlobalFunctions.php:1231
DeferredUpdates\doUpdates
static doUpdates( $mode='run', $stage=self::ALL)
Do any deferred updates and clear the list.
Definition
DeferredUpdates.php:123
Maintenance\DB_NONE
const DB_NONE
Constants for DB access type.
Definition
Maintenance.php:62
Maintenance\shouldExecute
static shouldExecute()
Should we execute the maintenance script, or just allow it to be included as a standalone class?...
Definition
Maintenance.php:173
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:78
$maintenance
$maintenance
Definition
doMaintenance.php:49
$self
$self
Definition
doMaintenance.php:56
MW_CONFIG_CALLBACK
const MW_CONFIG_CALLBACK
Definition
install.php:26
$maintClass
class DemoMaint extends Maintenance $maintClass
maintenance
doMaintenance.php
Generated on Mon Nov 25 2024 15:43:24 for MediaWiki by
1.10.0