MediaWiki  1.32.5
doMaintenance.php
Go to the documentation of this file.
1 <?php
28 
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
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 // Define how settings are loaded (e.g. LocalSettings.php)
58 if ( !defined( 'MW_CONFIG_CALLBACK' ) && !defined( 'MW_CONFIG_FILE' ) ) {
59  define( 'MW_CONFIG_FILE', $maintenance->loadSettings() );
60 }
61 
62 // Custom setup for Maintenance entry point
63 if ( !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  ) {
73  }
74  }
75 
76  $maintenance->finalSetup();
77  }
78  define( 'MW_SETUP_CALLBACK', 'wfMaintenanceSetup' );
79 }
80 
81 require_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 // Do the work
94 $success = $maintenance->execute();
95 
96 // Potentially debug globals
97 $maintenance->globals();
98 
99 if ( $maintenance->getDbType() !== Maintenance::DB_NONE ) {
100  // Perform deferred updates.
101  $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
102  $lbFactory->commitMasterChanges( $maintClass );
104 }
105 
106 // log profiling info
108 
109 if ( isset( $lbFactory ) ) {
110  // Commit and close up!
111  $lbFactory->commitMasterChanges( 'doMaintenance' );
112  $lbFactory->shutdown( $lbFactory::SHUTDOWN_NO_CHRONPROT );
113 }
114 
115 // Exit with an error status if execute() returned false
116 if ( $success === false ) {
117  exit( 1 );
118 }
$maintClass
$maintClass
Definition: CountFancyCaptchas.php:54
$wgCacheDirectory
$wgCacheDirectory
Directory for caching data in the local filesystem.
Definition: DefaultSettings.php:2317
$success
$success
Definition: doMaintenance.php:94
php
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
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$wgLocalisationCacheConf
$wgLocalisationCacheConf
Localisation cache configuration.
Definition: DefaultSettings.php:2600
Maintenance\shouldExecute
static shouldExecute()
Should we execute the maintenance script, or just allow it to be included as a standalone class?...
Definition: Maintenance.php:179
Maintenance\DB_NONE
const DB_NONE
Constants for DB access type.
Definition: Maintenance.php:65
DeferredUpdates\doUpdates
static doUpdates( $mode='run', $stage=self::ALL)
Do any deferred updates and clear the list.
Definition: DeferredUpdates.php:130
$self
$self
Definition: doMaintenance.php:55
$maintenance
$maintenance
Definition: doMaintenance.php:48
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
MediaWikiServices
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
wfLogProfilingData
wfLogProfilingData()
Definition: GlobalFunctions.php:1153