MediaWiki REL1_33
doMaintenance.php
Go to the documentation of this file.
1<?php
28
29if ( !defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
30 echo "This file must be included after Maintenance.php\n";
31 exit( 1 );
32}
33
34// Wasn't included from the file scope, halt execution (probably wanted the class)
35// If a class is using commandLine.inc (old school maintenance), they definitely
36// cannot be included and will proceed with execution
37if ( !Maintenance::shouldExecute() && $maintClass != CommandLineInc::class ) {
38 return;
39}
40
42 echo "\$maintClass is not set or is set to a non-existent class.\n";
43 exit( 1 );
44}
45
46// Get an object to start us off
49
50// Basic sanity checks and such
51$maintenance->setup();
52
53// We used to call this variable $self, but it was moved
54// to $maintenance->mSelf. Keep that here for b/c
55$self = $maintenance->getName();
56
57// Define how settings are loaded (e.g. LocalSettings.php)
58if ( !defined( 'MW_CONFIG_CALLBACK' ) && !defined( 'MW_CONFIG_FILE' ) ) {
59 define( 'MW_CONFIG_FILE', $maintenance->loadSettings() );
60}
61
62// Custom setup for Maintenance entry point
63if ( !defined( 'MW_SETUP_CALLBACK' ) ) {
64 function wfMaintenanceSetup() {
65 // phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.wgPrefix
67 if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
68 if ( $wgLocalisationCacheConf['storeClass'] === false
69 && ( $wgLocalisationCacheConf['store'] == 'db'
70 || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) )
71 ) {
72 $wgLocalisationCacheConf['storeClass'] = LCStoreNull::class;
73 }
74 }
75
76 $maintenance->finalSetup();
77 }
78 define( 'MW_SETUP_CALLBACK', 'wfMaintenanceSetup' );
79}
80
81require_once "$IP/includes/Setup.php";
82
83// Initialize main config instance
84$maintenance->setConfig( MediaWikiServices::getInstance()->getMainConfig() );
85
86// Sanity-check required extensions are installed
87$maintenance->checkRequiredExtensions();
88
89// A good time when no DBs have writes pending is around lag checks.
90// This avoids having long running scripts just OOM and lose all the updates.
91$maintenance->setAgentAndTriggers();
92
93$maintenance->validateParamsAndArgs();
94
95// Do the work
97
98// Potentially debug globals
99$maintenance->globals();
100
101if ( $maintenance->getDbType() !== Maintenance::DB_NONE ) {
102 // Perform deferred updates.
103 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
104 $lbFactory->commitMasterChanges( $maintClass );
105 DeferredUpdates::doUpdates();
106}
107
108// log profiling info
110
111if ( isset( $lbFactory ) ) {
112 // Commit and close up!
113 $lbFactory->commitMasterChanges( 'doMaintenance' );
114 $lbFactory->shutdown( $lbFactory::SHUTDOWN_NO_CHRONPROT );
115}
116
117// Exit with an error status if execute() returned false
118if ( $success === false ) {
119 exit( 1 );
120}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgCacheDirectory
Directory for caching data in the local filesystem.
$wgLocalisationCacheConf
Localisation cache configuration.
wfLogProfilingData()
const DB_NONE
Constants for DB access type.
static shouldExecute()
Should we execute the maintenance script, or just allow it to be included as a standalone class?...
MediaWikiServices is the service locator for the application scope of MediaWiki.
$maintenance
$success
class DemoMaint extends Maintenance $maintClass