MediaWiki  1.28.0
doMaintenance.php
Go to the documentation of this file.
1 <?php
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
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 # Start the autoloader, so that extensions can derive classes from core files
59 require_once "$IP/includes/AutoLoader.php";
60 # Grab profiling functions
61 require_once "$IP/includes/profiler/ProfilerFunctions.php";
62 
63 # Start the profiler
65 if ( file_exists( "$IP/StartProfiler.php" ) ) {
66  require "$IP/StartProfiler.php";
67 }
68 
69 // Some other requires
70 require_once "$IP/includes/Defines.php";
71 require_once "$IP/includes/DefaultSettings.php";
72 require_once "$IP/includes/GlobalFunctions.php";
73 
74 # Load composer's autoloader if present
75 if ( is_readable( "$IP/vendor/autoload.php" ) ) {
76  require_once "$IP/vendor/autoload.php";
77 }
78 
79 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
80  # Use a callback function to configure MediaWiki
81  call_user_func( MW_CONFIG_CALLBACK );
82 } else {
83  // Require the configuration (probably LocalSettings.php)
84  require $maintenance->loadSettings();
85 }
86 
87 if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
88  if ( $wgLocalisationCacheConf['storeClass'] === false
89  && ( $wgLocalisationCacheConf['store'] == 'db'
90  || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) )
91  ) {
92  $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
93  }
94 }
95 
96 $maintenance->finalSetup();
97 // Some last includes
98 require_once "$IP/includes/Setup.php";
99 
100 // Initialize main config instance
101 $maintenance->setConfig( ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) );
102 
103 // Sanity-check required extensions are installed
104 $maintenance->checkRequiredExtensions();
105 
106 // A good time when no DBs have writes pending is around lag checks.
107 // This avoids having long running scripts just OOM and lose all the updates.
108 $maintenance->setAgentAndTriggers();
109 
110 // Do the work
111 $maintenance->execute();
112 
113 // Potentially debug globals
114 $maintenance->globals();
115 
116 // Perform deferred updates.
117 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
118 $lbFactory->commitMasterChanges( $maintClass );
120 
121 // log profiling info
123 
124 // Commit and close up!
125 $lbFactory->commitMasterChanges( 'doMaintenance' );
126 $lbFactory->shutdown( $lbFactory::SHUTDOWN_NO_CHRONPROT );
const DB_NONE
Constants for DB access type.
Definition: Maintenance.php:57
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static doUpdates($mode= 'run', $stage=self::ALL)
Do any deferred updates and clear the list.
wfLogProfilingData()
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
$wgCacheDirectory
Directory for caching data in the local filesystem.
$wgLocalisationCacheConf
Localisation cache configuration.
$self
$wgProfiler
static shouldExecute()
Should we execute the maintenance script, or just allow it to be included as a standalone class...
const MW_CONFIG_CALLBACK
Definition: install.php:26
static getDefaultInstance()
$maintenance
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$lbFactory