MediaWiki master
MediaWiki\Maintenance\MaintenanceRunner Class Reference

A runner for maintenance scripts. More...

Public Member Functions

 __construct ()
 Default constructor.
 
 cleanup ()
 Handler for register_shutdown_function.
 
 defineSettings ()
 Define how settings are loaded (e.g.
 
 getName ()
 Returns the maintenance script name to show in the help message.
 
 initForClass (string $scriptClass, $argv)
 Initialize the runner for the given class.
 
 initFromWrapper (array $argv)
 Initialize the runner from the given command line arguments as passed to a wrapper script.
 
 run ()
 Run the maintenance script.
 
 setup (SettingsBuilder $settings)
 MW_FINAL_SETUP_CALLBACK handler, for setting up the Maintenance object.
 

Static Public Member Functions

static emulateConfig (SettingsBuilder $settings)
 
static shouldExecute ()
 Should we execute the maintenance script, or just allow it to be included as a standalone class? It checks that the call stack only includes this function and "requires" (meaning was called from the file scope)
 

Protected Member Functions

 addDefaultParams ()
 Add the default parameters to the scripts.
 
 error (string $msg)
 
 fatalError ( $msg, $exitCode=1)
 Output a message and terminate the current script.
 
 findScriptClass (string $script)
 
 getExtensionInfo (string $extName)
 
 getScriptClass ()
 
 preloadScriptFile (string $script)
 Preload the script file, so any defines in file level code are executed.
 

Detailed Description

A runner for maintenance scripts.

Since
1.39
Stability: unstable

Definition at line 26 of file MaintenanceRunner.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Maintenance\MaintenanceRunner::__construct ( )

Default constructor.

Children should call this first if implementing their own constructors

Stability: stable
to call

Definition at line 67 of file MaintenanceRunner.php.

References MediaWiki\Maintenance\MaintenanceRunner\addDefaultParams().

Member Function Documentation

◆ addDefaultParams()

MediaWiki\Maintenance\MaintenanceRunner::addDefaultParams ( )
protected

Add the default parameters to the scripts.

Definition at line 83 of file MaintenanceRunner.php.

References Maintenance\GENERIC_MAINTENANCE_PARAMETERS.

Referenced by MediaWiki\Maintenance\MaintenanceRunner\__construct().

◆ cleanup()

MediaWiki\Maintenance\MaintenanceRunner::cleanup ( )

Handler for register_shutdown_function.

Access: internal
Returns
void

Definition at line 782 of file MaintenanceRunner.php.

◆ defineSettings()

MediaWiki\Maintenance\MaintenanceRunner::defineSettings ( )

Define how settings are loaded (e.g.

LocalSettings.php)

Note
Called before Setup.php
Access: internal
Returns
void

Definition at line 539 of file MaintenanceRunner.php.

References $IP, and wfDetectLocalSettingsFile().

◆ emulateConfig()

static MediaWiki\Maintenance\MaintenanceRunner::emulateConfig ( SettingsBuilder $settings)
static
Parameters
SettingsBuilder$settings
Access: internal
Handler for MW_CONFIG_CALLBACK, used when no LocalSettings.php was found.

Definition at line 592 of file MaintenanceRunner.php.

References MediaWiki\Settings\SettingsBuilder\overrideConfigValues().

◆ error()

MediaWiki\Maintenance\MaintenanceRunner::error ( string $msg)
protected
Parameters
string$msg

Definition at line 740 of file MaintenanceRunner.php.

◆ fatalError()

MediaWiki\Maintenance\MaintenanceRunner::fatalError ( $msg,
$exitCode = 1 )
protected

Output a message and terminate the current script.

Parameters
string$msgError message
int$exitCodePHP exit status. Should be in range 1-254.
Returns
never

Definition at line 732 of file MaintenanceRunner.php.

◆ findScriptClass()

MediaWiki\Maintenance\MaintenanceRunner::findScriptClass ( string $script)
protected
Access: internal
Parameters
string$script
Returns
class-string<Maintenance>

Definition at line 404 of file MaintenanceRunner.php.

◆ getExtensionInfo()

MediaWiki\Maintenance\MaintenanceRunner::getExtensionInfo ( string $extName)
protected

Definition at line 247 of file MaintenanceRunner.php.

◆ getName()

MediaWiki\Maintenance\MaintenanceRunner::getName ( )

Returns the maintenance script name to show in the help message.

Returns
string

Definition at line 495 of file MaintenanceRunner.php.

◆ getScriptClass()

MediaWiki\Maintenance\MaintenanceRunner::getScriptClass ( )
protected
Returns
class-string<Maintenance>

Definition at line 382 of file MaintenanceRunner.php.

◆ initForClass()

MediaWiki\Maintenance\MaintenanceRunner::initForClass ( string $scriptClass,
$argv )

Initialize the runner for the given class.

This is used when running scripts directly, without a wrapper.

Note
Called before Setup.php
Parameters
string$scriptClassThe script class to run
string[]$argvThe arguments to passed to the script, including the script itself at index 0.

Definition at line 192 of file MaintenanceRunner.php.

◆ initFromWrapper()

MediaWiki\Maintenance\MaintenanceRunner::initFromWrapper ( array $argv)

Initialize the runner from the given command line arguments as passed to a wrapper script.

Note
Called before Setup.php
Parameters
string[]$argvThe arguments passed from the command line, including the wrapper script at index 0, and usually the script to run at index 1.

Definition at line 134 of file MaintenanceRunner.php.

◆ preloadScriptFile()

MediaWiki\Maintenance\MaintenanceRunner::preloadScriptFile ( string $script)
protected

Preload the script file, so any defines in file level code are executed.

This way, scripts can control what Setup.php does.

Access: internal
Parameters
string$script

Definition at line 346 of file MaintenanceRunner.php.

◆ run()

MediaWiki\Maintenance\MaintenanceRunner::run ( )

Run the maintenance script.

Note
The process should exit immediately after this method returns. At that point, MediaWiki will already have been shut down. It is no longer safe to perform any write operations on the database.
Any exceptions thrown by the maintenance script will cause this method to terminate the process after reporting the error to the user, without shutdown and cleanup.
Returns
bool true on success, false on failure, passed through from Maintenance::execute().

Definition at line 660 of file MaintenanceRunner.php.

◆ setup()

MediaWiki\Maintenance\MaintenanceRunner::setup ( SettingsBuilder $settings)

MW_FINAL_SETUP_CALLBACK handler, for setting up the Maintenance object.

Parameters
SettingsBuilder$settings

Definition at line 440 of file MaintenanceRunner.php.

◆ shouldExecute()

static MediaWiki\Maintenance\MaintenanceRunner::shouldExecute ( )
static

Should we execute the maintenance script, or just allow it to be included as a standalone class? It checks that the call stack only includes this function and "requires" (meaning was called from the file scope)

Returns
bool

Definition at line 756 of file MaintenanceRunner.php.

References MW_ENTRY_POINT.


The documentation for this class was generated from the following file: