MediaWiki master
doMaintenance.php
Go to the documentation of this file.
1<?php
16
17// No AutoLoader yet
18require_once __DIR__ . '/includes/MaintenanceRunner.php';
19require_once __DIR__ . '/includes/MaintenanceParameters.php';
20
21if ( !defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
22 echo "This file must be included after Maintenance.php\n";
23 exit( 1 );
24}
25
26// Wasn't included from the file scope, halt execution (probably wanted the class).
27// This typically happens when a maintenance script is executed using run.php.
28// @phan-suppress-next-line PhanRedundantValueComparisonInGlobalScope
29if ( !MaintenanceRunner::shouldExecute() && $maintClass != CommandLineInc::class ) {
30 return;
31}
32
33// @phan-suppress-next-line PhanImpossibleConditionInGlobalScope
34if ( !$maintClass || !class_exists( $maintClass ) ) {
35 echo "\$maintClass is not set or is set to a non-existent class.\n";
36 exit( 1 );
37}
38
39// Define the MediaWiki entrypoint
40define( 'MEDIAWIKI', true );
41
43require_once "$IP/includes/AutoLoader.php";
44
46$runner->initForClass( $maintClass, $GLOBALS['argv'] );
47
48// We used to call this variable $self, but it was moved
49// to $maintenance->mSelf. Keep that here for b/c
50$self = $runner->getName();
51
52$runner->defineSettings();
53
54// Custom setup for Maintenance entry point
55if ( !defined( 'MW_FINAL_SETUP_CALLBACK' ) ) {
56
61 function wfMaintenanceSetup( SettingsBuilder $settingsBuilder ) {
62 global $runner;
63 $runner->setup( $settingsBuilder );
64 }
65
66 define( 'MW_FINAL_SETUP_CALLBACK', 'wfMaintenanceSetup' );
67}
68
69// Initialize MediaWiki (load settings, initialized session,
70// enable MediaWikiServices)
71require_once "$IP/includes/Setup.php";
72
73// We only get here if the script was invoked directly.
74// If it was loaded by MaintenanceRunner, MaintenanceRunner::shouldExecute() would have returned false,
75// and we would have returned from this file early.
76
77if ( stream_isatty( STDOUT ) ) {
78 echo "\n";
79 echo "*******************************************************************************\n";
80 echo "NOTE: Do not run maintenance scripts directly, use maintenance/run.php instead!\n";
81 echo " Running scripts directly has been deprecated in MediaWiki 1.40.\n";
82 echo " It may not work for some (or any) scripts in the future.\n";
83 echo "*******************************************************************************\n";
84 echo "\n";
85}
86
87// Do it!
89
90// Exit with an error status if execute() returned false
91if ( !$success ) {
92 exit( 1 );
93}
wfDetectInstallPath()
Decide and remember where mediawiki is installed.
$maintClass
A runner for maintenance scripts.
Builder class for constructing a Config object from a set of sources during bootstrap.
$runner
if(stream_isatty(STDOUT)) $success