MediaWiki  1.27.1
doMaintenance.php
Go to the documentation of this file.
1 <?php
29 if ( !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
37 if ( !Maintenance::shouldExecute() && $maintClass != 'CommandLineInc' ) {
38  return;
39 }
40 
41 if ( !$maintClass || !class_exists( $maintClass ) ) {
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 # Start the autoloader, so that extensions can derive classes from core files
58 require_once "$IP/includes/AutoLoader.php";
59 # Grab profiling functions
60 require_once "$IP/includes/profiler/ProfilerFunctions.php";
61 
62 # Start the profiler
64 if ( file_exists( "$IP/StartProfiler.php" ) ) {
65  require "$IP/StartProfiler.php";
66 }
67 
68 // Some other requires
69 require_once "$IP/includes/Defines.php";
70 require_once "$IP/includes/DefaultSettings.php";
71 require_once "$IP/includes/GlobalFunctions.php";
72 
73 # Load composer's autoloader if present
74 if ( is_readable( "$IP/vendor/autoload.php" ) ) {
75  require_once "$IP/vendor/autoload.php";
76 }
77 
78 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
79  # Use a callback function to configure MediaWiki
80  call_user_func( MW_CONFIG_CALLBACK );
81 } else {
82  // Require the configuration (probably LocalSettings.php)
83  require $maintenance->loadSettings();
84 }
85 
86 if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
87  if ( $wgLocalisationCacheConf['storeClass'] === false
88  && ( $wgLocalisationCacheConf['store'] == 'db'
89  || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) )
90  ) {
91  $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
92  }
93 }
94 
95 $maintenance->finalSetup();
96 // Some last includes
97 require_once "$IP/includes/Setup.php";
98 
99 // Initialize main config instance
100 $maintenance->setConfig( ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) );
101 
102 // Do the work
103 $maintenance->execute();
104 
105 // Potentially debug globals
106 $maintenance->globals();
107 
108 // Perform deferred updates.
110 
111 // log profiling info
113 
114 // Commit and close up!
116 $factory->commitMasterChanges( 'doMaintenance' );
117 $factory->shutdown();
$maintClass
static doUpdates($mode= 'run', $type=self::ALL)
Do any deferred updates and clear the list.
const DB_NONE
Constants for DB access type.
Definition: Maintenance.php:58
wfLogProfilingData()
$wgCacheDirectory
Directory for caching data in the local filesystem.
$factory
$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:30
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
wfGetLBFactory()
Get the load balancer factory object.