|
MediaWiki 1.43.1
|
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effort. More...
Inherited by AddChangeTag, AddSite, AttachLatest, BenchmarkParse, BlockUsers, ChangePassword, CheckBadRedirects, CheckComposerLockUpToDate, CheckImages, GeneratePhpCharToUpperMappings, ImportImages, MediaWiki\Maintenance\BackupDumper, MediaWiki\Maintenance\Benchmarker, MediaWiki\Maintenance\DeleteLocalPasswords, MediaWiki\Maintenance\FakeMaintenance, MediaWiki\Maintenance\LoggedUpdateMaintenance, MediaWiki\Maintenance\SchemaMaintenance, MediaWiki\Maintenance\Version, RefreshLinks, UppercaseTitlesForUnicodeTransition, ViewCLI, WikiBirthday, and WrapOldPasswords.

Public Member Functions | |
| __construct () | |
| Default constructor. | |
| canExecuteWithoutLocalSettings () | |
| Whether this script can run without LocalSettings.php. | |
| checkRequiredExtensions () | |
| Verify that the required extensions are installed. | |
| cleanupChanneled () | |
| Clean up channeled output. | |
| clearParamsAndArgs () | |
| Clear all params and arguments. | |
| createChild (string $maintClass, ?string $classFile=null) | |
| Returns an instance of the given maintenance script, with all of the current arguments passed to it. | |
| execute () | |
| Do the actual work. | |
| finalSetup (SettingsBuilder $settingsBuilder) | |
| Handle some last-minute setup here. | |
| getConfig () | |
| getDbType () | |
| Does the script need different DB access? By default, we give Maintenance scripts normal rights to the DB. | |
| getName () | |
| Get the script's name. | |
| getParameters () | |
| isQuiet () | |
| loadParamsAndArgs ( $self=null, $opts=null, $args=null) | |
| Process command line arguments when running as a child script. | |
| loadWithArgv ( $argv) | |
| Load params and arguments from a given array of command-line arguments. | |
| memoryLimit () | |
| Normally we disable the memory_limit when running admin scripts. | |
| outputChanneled ( $msg, $channel=null) | |
| Message outputter with channeled message support. | |
| purgeRedundantText ( $delete=true) | |
| Support function for cleaning up redundant text records. | |
| runChild ( $maintClass, $classFile=null) | |
| Returns an instance of the given maintenance script, with all of the current arguments passed to it. | |
| setArg ( $argId, $value) | |
| Programmatically set the value of the given argument. | |
| setConfig (Config $config) | |
| setDB (IMaintainableDatabase $db) | |
| Sets database object to be returned by getDB(). | |
| setDBProvider (IConnectionProvider $dbProvider) | |
| setName (string $name) | |
| setOption (string $name, $value) | |
| Programmatically set the value of the given option. | |
| setup () | |
| Provides subclasses with an opportunity to perform initial checks. | |
| validateParamsAndArgs () | |
| Run some validation checks on the params, etc. | |
Static Public Member Functions | |
| static | getTermSize () |
| Get the terminal size as a two-element array where the first element is the width (number of columns) and the second element is the height (number of rows). | |
| static | posix_isatty ( $fd) |
| Wrapper for posix_isatty() We default as considering stdin a tty (for nice readline methods) but treating stout as not a tty to avoid color codes. | |
| static | readconsole ( $prompt='> ') |
| Prompt the console for input. | |
| static | requireTestsAutoloader () |
| Call this to set up the autoloader to allow classes to be used from the tests directory. | |
Public Attributes | |
| resource null | $fileHandle |
| Used when creating separate schema files. | |
| array | $orderedOptions = [] |
| Used to read the options in the order they were passed. | |
| const | DB_ADMIN = 2 |
| const | DB_NONE = 0 |
| Constants for DB access type. | |
| const | DB_STD = 1 |
| const | GENERIC_MAINTENANCE_PARAMETERS = 'Script runner options' |
| const | SCRIPT_DEPENDENT_PARAMETERS = 'Common options' |
| const | STDIN_ALL = -1 |
Protected Member Functions | |
| addArg ( $arg, $description, $required=true, $multi=false) | |
| Add some args that are needed. | |
| addDefaultParams () | |
| Add the default parameters to the scripts. | |
| addDescription ( $text) | |
| Set the description text. | |
| addOption ( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false) | |
| Add a parameter to the script. | |
| afterFinalSetup () | |
| Override to perform any required operation at the end of initialisation. | |
| beginTransaction (IDatabase $dbw, $fname) | |
| Begin a transaction on a DB. | |
| commitTransaction (IDatabase $dbw, $fname) | |
| Commit the transaction on a DB handle and wait for replica DBs to catch up. | |
| countDown ( $seconds) | |
| Count down from $seconds to zero on the terminal, with a one-second pause between showing each number. | |
| deleteOption ( $name) | |
| Remove an option. | |
| error ( $err, $die=0) | |
| Throw an error to the user. | |
| fatalError ( $msg, $exitCode=1) | |
| Output a message and terminate the current script. | |
| getArg ( $argId=0, $default=null) | |
| Get an argument. | |
| getArgName (int $argId) | |
| Get the name of an argument. | |
| getArgs ( $offset=0) | |
| Get arguments. | |
| getBatchSize () | |
| Returns batch size. | |
| getDB ( $db, $groups=[], $dbDomain=false) | |
| Returns a database to be used by current maintenance script. | |
| getDir () | |
| Get the maintenance directory. | |
| getHookContainer () | |
| Get a HookContainer, for running extension hooks or for hook metadata. | |
| getHookRunner () | |
| Get a HookRunner for running core hooks. | |
| getOption ( $name, $default=null) | |
| Get an option, or return the default. | |
| getPrimaryDB () | |
| getReplicaDB () | |
| getServiceContainer () | |
| Returns the main service container. | |
| getStdin ( $len=null) | |
| Return input from stdin. | |
| hasArg ( $argId=0) | |
| Does a given argument exist? | |
| hasOption ( $name) | |
| Checks to see if a particular option was set. | |
| loadSpecialVars () | |
| Handle the special variables that are global to all scripts. | |
| maybeHelp ( $force=false) | |
| Maybe show the help. | |
| output ( $out, $channel=null) | |
| Throw some output to the user. | |
| parseIntList ( $text) | |
| Utility function to parse a string (perhaps from a command line option) into a list of integers (perhaps some kind of numeric IDs). | |
| prompt (string $prompt, ?string $default=null) | |
| requireExtension ( $name) | |
| Indicate that the specified extension must be loaded before the script can run. | |
| rollbackTransaction (IDatabase $dbw, $fname) | |
| Rollback the transaction on a DB handle. | |
| setAllowUnregisteredOptions ( $allow) | |
| Sets whether to allow unregistered options, which are options passed to a script that do not match an expected parameter. | |
| setBatchSize ( $s=0) | |
| showHelp () | |
| Definitely show the help. | |
| supportsOption ( $name) | |
| Checks to see if a particular option in supported. | |
| validateUserOption ( $errorMsg) | |
| waitForReplication () | |
| Wait for replica DBs to catch up. | |
Protected Attributes | |
| array | $mArgs = [] |
| This is the list of arguments that were actually passed. | |
| int null | $mBatchSize = null |
| Batch size. | |
| string | $mDbPass = null |
| string | $mDbUser = null |
| string | $mDescription = '' |
| A description of the script, children should change this via addDescription() | |
| bool | $mInputLoaded = false |
| Have we already loaded our user input? | |
| array | $mOptions = [] |
| This is the list of options that were actually passed. | |
| array[] | $mParams = [] |
| Empty. | |
| bool | $mQuiet = false |
| Special vars for params that are always used. | |
| string null | $mSelf |
| Name of the script currently running. | |
| MaintenanceParameters | $parameters |
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effort.
All that must be defined is the execute() method. See docs/maintenance.txt for more info and a quick demo of how to use it.
Terminology: params: registry of named values that may be passed to the script arg list: registry of positional values that may be passed to the script options: passed param values args: passed positional values
In the command: mwscript somescript.php –foo=bar baz foo is a param bar is the option value of the option for param foo baz is the arg value at index 0 in the arg list
WARNING: the constructor, MaintenanceRunner::shouldExecute(), setup(), finalSetup(), and getName() are called before Setup.php is complete, which means most of the common infrastructure, like logging or autoloading, is not available. Be careful when changing these methods or the ones called from them. Likewise, be careful with the constructor when subclassing. MediaWikiServices instance is not yet available at this point.
Definition at line 74 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::__construct | ( | ) |
Default constructor.
Children should call this first if implementing their own constructors
Reimplemented in AddChangeTag, AddSite, AttachLatest, BenchmarkParse, BlockUsers, ChangePassword, CheckBadRedirects, CheckComposerLockUpToDate, CheckImages, MediaWiki\Maintenance\FixAutoblockLogTitles, ImportImages, MediaWiki\Maintenance\Benchmarker, MediaWiki\Maintenance\DeleteLocalPasswords, MediaWiki\Maintenance\LoggedUpdateMaintenance, MediaWiki\Maintenance\SchemaMaintenance, GeneratePhpCharToUpperMappings, RefreshLinks, UppercaseTitlesForUnicodeTransition, MediaWiki\Maintenance\Version, ViewCLI, WikiBirthday, and WrapOldPasswords.
Definition at line 198 of file Maintenance.php.
References MediaWiki\Maintenance\Maintenance\addDefaultParams().
|
protected |
Add some args that are needed.
| string | $arg | Name of the arg, like 'start' |
| string | $description | Short description of the arg |
| bool | $required | Is this required? |
| bool | $multi | Does it allow multiple values? (Last arg only) |
Definition at line 310 of file Maintenance.php.
Referenced by AddSite\__construct(), BenchmarkParse\__construct(), BlockUsers\__construct(), ImportImages\__construct(), RefreshLinks\__construct(), and ViewCLI\__construct().
|
protected |
Add the default parameters to the scripts.
Definition at line 634 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\Maintenance\__construct().
|
protected |
Set the description text.
| string | $text | The text of the description |
Definition at line 335 of file Maintenance.php.
Referenced by DumpBackup\__construct(), MediaWiki\Maintenance\TextPassDumper\__construct(), AddChangeTag\__construct(), AddSite\__construct(), AttachLatest\__construct(), BenchmarkParse\__construct(), BlockUsers\__construct(), ChangePassword\__construct(), CheckBadRedirects\__construct(), CheckComposerLockUpToDate\__construct(), CheckImages\__construct(), MediaWiki\Maintenance\FixAutoblockLogTitles\__construct(), ImportImages\__construct(), MediaWiki\Maintenance\DeleteLocalPasswords\__construct(), GeneratePhpCharToUpperMappings\__construct(), RefreshLinks\__construct(), UppercaseTitlesForUnicodeTransition\__construct(), MediaWiki\Maintenance\Version\__construct(), ViewCLI\__construct(), WikiBirthday\__construct(), and WrapOldPasswords\__construct().
|
protected |
Add a parameter to the script.
Will be displayed on –help with the associated description
| string | $name | The name of the param (help, version, etc) |
| string | $description | The description of the param to show on –help |
| bool | $required | Is the param required? |
| bool | $withArg | Is an argument required with this option? |
| string | bool | $shortName | Character to use as short name |
| bool | $multiOccurrence | Can this option be passed multiple times? |
Definition at line 265 of file Maintenance.php.
Referenced by DumpBackup\__construct(), MediaWiki\Maintenance\BackupDumper\__construct(), MediaWiki\Maintenance\TextPassDumper\__construct(), AddChangeTag\__construct(), AddSite\__construct(), AttachLatest\__construct(), BenchmarkParse\__construct(), BlockUsers\__construct(), ChangePassword\__construct(), ImportImages\__construct(), MediaWiki\Maintenance\Benchmarker\__construct(), MediaWiki\Maintenance\DeleteLocalPasswords\__construct(), MediaWiki\Maintenance\LoggedUpdateMaintenance\__construct(), MediaWiki\Maintenance\SchemaMaintenance\__construct(), RefreshLinks\__construct(), UppercaseTitlesForUnicodeTransition\__construct(), WrapOldPasswords\__construct(), and MediaWiki\Maintenance\BackupDumper\finalSetup().
|
protected |
Override to perform any required operation at the end of initialisation.
Definition at line 1031 of file Maintenance.php.
|
protected |
Begin a transaction on a DB.
This method makes it clear that begin() is called from a maintenance script, which has outermost scope. This is safe, unlike $dbw->begin() called in other places.
| IDatabase | $dbw | |
| string | $fname | Caller name |
Definition at line 1184 of file Maintenance.php.
References Wikimedia\Rdbms\IDatabase\begin().
Referenced by WrapOldPasswords\execute().
| MediaWiki\Maintenance\Maintenance::canExecuteWithoutLocalSettings | ( | ) |
Whether this script can run without LocalSettings.php.
Scripts that need to be able to run when MediaWiki has not been installed should override this to return true. Scripts that return true from this method must be able to function without a storage backend. When no LocalSettings.php file is present, any attempt to access the database will fail with a fatal error.
Reimplemented in CheckComposerLockUpToDate, MediaWiki\Maintenance\SchemaMaintenance, and MediaWiki\Maintenance\Version.
Definition at line 240 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::checkRequiredExtensions | ( | ) |
Verify that the required extensions are installed.
Definition at line 711 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::cleanupChanneled | ( | ) |
Clean up channeled output.
Output a newline if necessary.
Definition at line 572 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::clearParamsAndArgs | ( | ) |
Clear all params and arguments.
Definition at line 813 of file Maintenance.php.
|
protected |
Commit the transaction on a DB handle and wait for replica DBs to catch up.
This method makes it clear that commit() is called from a maintenance script, which has outermost scope. This is safe, unlike $dbw->commit() called in other places.
| IDatabase | $dbw | |
| string | $fname | Caller name |
Definition at line 1199 of file Maintenance.php.
References Wikimedia\Rdbms\IDatabase\commit().
Referenced by WrapOldPasswords\execute().
|
protected |
Count down from $seconds to zero on the terminal, with a one-second pause between showing each number.
If the maintenance script is in quiet mode, this function does nothing.
| int | $seconds |
Definition at line 1253 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::createChild | ( | string | $maintClass, |
| ?string | $classFile = null ) |
Returns an instance of the given maintenance script, with all of the current arguments passed to it.
Callers are expected to run the returned maintenance script instance by calling Maintenance::execute
| string | $maintClass | A name of a child maintenance class |
| string | null | $classFile | Full path of where the child is |
Maintenance::execute on the returned object. Definition at line 761 of file Maintenance.php.
References $maintClass.
|
protected |
Remove an option.
Useful for removing options that won't be used in your script.
| string | $name | The option to remove. |
Definition at line 318 of file Maintenance.php.
|
protected |
Throw an error to the user.
Doesn't respect –quiet, so don't use this for non-error output
| string | StatusValue | $err | The error to display |
| int | $die | Deprecated since 1.31, use Maintenance::fatalError() instead |
Definition at line 514 of file Maintenance.php.
References wfDeprecated(), and wfMessage().
Referenced by AddSite\execute(), and UppercaseTitlesForUnicodeTransition\execute().
|
abstract |
Do the actual work.
All child classes will need to implement this
Reimplemented in AddChangeTag, AddSite, AttachLatest, BenchmarkParse, BlockUsers, ChangePassword, CheckBadRedirects, CheckComposerLockUpToDate, CheckImages, DumpBackup, ImportImages, MediaWiki\Maintenance\DeleteLocalPasswords, MediaWiki\Maintenance\FakeMaintenance, MediaWiki\Maintenance\LoggedUpdateMaintenance, MediaWiki\Maintenance\SchemaMaintenance, MediaWiki\Maintenance\TextPassDumper, GeneratePhpCharToUpperMappings, RefreshLinks, UppercaseTitlesForUnicodeTransition, MediaWiki\Maintenance\Version, ViewCLI, WikiBirthday, and WrapOldPasswords.
|
protected |
Output a message and terminate the current script.
| string | StatusValue | $msg | Error message |
| int | $exitCode | PHP exit status. Should be in range 1-254. |
Definition at line 552 of file Maintenance.php.
Referenced by AddChangeTag\execute(), BenchmarkParse\execute(), BlockUsers\execute(), ChangePassword\execute(), DumpBackup\execute(), ImportImages\execute(), GeneratePhpCharToUpperMappings\execute(), RefreshLinks\execute(), UppercaseTitlesForUnicodeTransition\execute(), ViewCLI\execute(), WrapOldPasswords\execute(), MediaWiki\Maintenance\DeleteLocalPasswords\initialize(), DumpBackup\processOptions(), and MediaWiki\Maintenance\BackupDumper\processOptions().
| MediaWiki\Maintenance\Maintenance::finalSetup | ( | SettingsBuilder | $settingsBuilder | ) |
Handle some last-minute setup here.
| SettingsBuilder | $settingsBuilder |
Reimplemented in MediaWiki\Maintenance\BackupDumper, and MediaWiki\Maintenance\TextPassDumper.
Definition at line 948 of file Maintenance.php.
References MediaWiki\Settings\SettingsBuilder\getConfig(), and MediaWiki\Settings\SettingsBuilder\putConfigValues().
|
protected |
Get an argument.
| int | string | $argId | The index (from zero) of the argument, or the name declared for the argument by addArg(). |
| mixed | null | $default | The default if it doesn't exist |
Definition at line 357 of file Maintenance.php.
Referenced by AddSite\execute(), BenchmarkParse\execute(), BlockUsers\execute(), ImportImages\execute(), RefreshLinks\execute(), and ViewCLI\execute().
|
protected |
Get the name of an argument.
| int | $argId | The index (from zero) of the argument. |
Definition at line 381 of file Maintenance.php.
|
protected |
Get arguments.
| int | string | $offset | The index (from zero) of the first argument, or the name declared for the argument by addArg(). |
Definition at line 369 of file Maintenance.php.
|
protected |
Returns batch size.
Definition at line 418 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\FixAutoblockLogTitles\doDBUpdates(), CheckImages\execute(), RefreshLinks\execute(), WrapOldPasswords\execute(), and MediaWiki\Maintenance\DeleteLocalPasswords\getUserBatches().
| MediaWiki\Maintenance\Maintenance::getConfig | ( | ) |
Definition at line 667 of file Maintenance.php.
Referenced by ImportImages\execute().
|
protected |
Returns a database to be used by current maintenance script.
This uses the main LBFactory instance by default unless overriden via setDB().
This function has the same parameters as LoadBalancer::getConnection().
For simple cases, use ::getReplicaDB() or ::getPrimaryDB() instead.
| int | $db | DB index (DB_REPLICA/DB_PRIMARY) |
| string | string[] | $groups | default: empty array |
| string | bool | $dbDomain | default: current wiki |
Definition at line 1122 of file Maintenance.php.
Referenced by RefreshLinks\execute(), RefreshLinks\fixRedirect(), and MediaWiki\Maintenance\BackupDumper\initProgress().
| MediaWiki\Maintenance\Maintenance::getDbType | ( | ) |
Does the script need different DB access? By default, we give Maintenance scripts normal rights to the DB.
Sometimes, a script needs admin rights access for a reason and sometimes they want no access. Subclasses should override and return one of the following values, as needed: Maintenance::DB_NONE - For no DB access at all Maintenance::DB_STD - For normal DB access, default Maintenance::DB_ADMIN - For admin DB access
Definition at line 627 of file Maintenance.php.
|
protected |
|
protected |
Get a HookContainer, for running extension hooks or for hook metadata.
Definition at line 1409 of file Maintenance.php.
Referenced by BenchmarkParse\execute().
|
protected |
Get a HookRunner for running core hooks.
Definition at line 1424 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::getName | ( | ) |
|
protected |
Get an option, or return the default.
If the option was added to support multiple occurrences, this will return an array.
| string | $name | The name of the param |
| mixed | null | $default | Anything you want, default null |
Definition at line 299 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\Benchmarker\bench(), AddChangeTag\execute(), AddSite\execute(), BenchmarkParse\execute(), BlockUsers\execute(), ChangePassword\execute(), ImportImages\execute(), RefreshLinks\execute(), UppercaseTitlesForUnicodeTransition\execute(), WrapOldPasswords\execute(), MediaWiki\Maintenance\DeleteLocalPasswords\initialize(), DumpBackup\processOptions(), MediaWiki\Maintenance\BackupDumper\processOptions(), MediaWiki\Maintenance\TextPassDumper\processOptions(), and MediaWiki\Maintenance\DeleteLocalPasswords\processUsers().
| MediaWiki\Maintenance\Maintenance::getParameters | ( | ) |
|
protected |
Definition at line 1158 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\FixAutoblockLogTitles\doDBUpdates(), AttachLatest\execute(), MediaWiki\Maintenance\LoggedUpdateMaintenance\execute(), UppercaseTitlesForUnicodeTransition\execute(), WrapOldPasswords\execute(), MediaWiki\Maintenance\DeleteLocalPasswords\getUserBatches(), and MediaWiki\Maintenance\DeleteLocalPasswords\getUserDB().
|
protected |
Definition at line 1147 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\FixAutoblockLogTitles\doDBUpdates(), CheckBadRedirects\execute(), CheckImages\execute(), UppercaseTitlesForUnicodeTransition\execute(), and WikiBirthday\execute().
|
protected |
Returns the main service container.
Definition at line 681 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\BackupDumper\backupDb(), MediaWiki\Maintenance\BackupDumper\dump(), AddSite\execute(), AttachLatest\execute(), BenchmarkParse\execute(), BlockUsers\execute(), CheckBadRedirects\execute(), CheckImages\execute(), ImportImages\execute(), GeneratePhpCharToUpperMappings\execute(), ViewCLI\execute(), WikiBirthday\execute(), WrapOldPasswords\execute(), RefreshLinks\fixRedirect(), MediaWiki\Maintenance\DeleteLocalPasswords\initialize(), and MediaWiki\Maintenance\TextPassDumper\rotateDb().
|
protected |
Return input from stdin.
| int | null | $len | The number of bytes to read. If null, just return the handle. Maintenance::STDIN_ALL returns the full content |
Definition at line 457 of file Maintenance.php.
Referenced by BlockUsers\execute().
|
static |
Get the terminal size as a two-element array where the first element is the width (number of columns) and the second element is the height (number of rows).
Definition at line 1357 of file Maintenance.php.
References wfIsWindows().
|
protected |
Does a given argument exist?
| int | string | $argId | The index (from zero) of the argument, or the name declared for the argument by addArg(). |
Definition at line 345 of file Maintenance.php.
Referenced by BlockUsers\execute().
|
protected |
Checks to see if a particular option was set.
| string | $name | The name of the option |
Definition at line 284 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\Benchmarker\bench(), AttachLatest\execute(), BenchmarkParse\execute(), BlockUsers\execute(), DumpBackup\execute(), ImportImages\execute(), MediaWiki\Maintenance\LoggedUpdateMaintenance\execute(), RefreshLinks\execute(), WrapOldPasswords\execute(), MediaWiki\Maintenance\DeleteLocalPasswords\initialize(), DumpBackup\processOptions(), MediaWiki\Maintenance\BackupDumper\processOptions(), and MediaWiki\Maintenance\TextPassDumper\processOptions().
| MediaWiki\Maintenance\Maintenance::isQuiet | ( | ) |
Definition at line 474 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::loadParamsAndArgs | ( | $self = null, | |
| $opts = null, | |||
| $args = null ) |
Process command line arguments when running as a child script.
| string | null | $self | The name of the script, if any |
| array | null | $opts | An array of options, in form of key=>value |
| array | null | $args | An array of command line arguments |
Definition at line 859 of file Maintenance.php.
References $self.
|
protected |
Handle the special variables that are global to all scripts.
Definition at line 898 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::loadWithArgv | ( | $argv | ) |
Load params and arguments from a given array of command-line arguments.
| array | $argv | The argument array, not including the script itself. |
Definition at line 835 of file Maintenance.php.
Referenced by DumpBackup\__construct(), MediaWiki\Maintenance\BackupDumper\__construct(), and MediaWiki\Maintenance\TextPassDumper\__construct().
|
protected |
Maybe show the help.
If the help is shown, exit.
| bool | $force | Whether to force the help to show, default false |
Definition at line 918 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::memoryLimit | ( | ) |
Normally we disable the memory_limit when running admin scripts.
Some scripts may wish to actually set a limit, however, to avoid blowing up unexpectedly.
Definition at line 806 of file Maintenance.php.
|
protected |
Throw some output to the user.
Scripts can call this with no fears, as we handle all –quiet stuff here
| string | $out | The text to show to the user |
| mixed | null | $channel | Unique identifier for the channel. See function outputChanneled. |
Definition at line 485 of file Maintenance.php.
Referenced by DumpBackup\__construct(), MediaWiki\Maintenance\TextPassDumper\__construct(), MediaWiki\Maintenance\Benchmarker\addResult(), MediaWiki\Maintenance\FixAutoblockLogTitles\doDBUpdates(), AddChangeTag\execute(), AddSite\execute(), AttachLatest\execute(), BlockUsers\execute(), ChangePassword\execute(), CheckBadRedirects\execute(), CheckImages\execute(), ImportImages\execute(), MediaWiki\Maintenance\DeleteLocalPasswords\execute(), MediaWiki\Maintenance\LoggedUpdateMaintenance\execute(), GeneratePhpCharToUpperMappings\execute(), RefreshLinks\execute(), ViewCLI\execute(), WikiBirthday\execute(), WrapOldPasswords\execute(), MediaWiki\Maintenance\DeleteLocalPasswords\getUserBatches(), MediaWiki\Maintenance\Benchmarker\startBench(), and MediaWiki\Maintenance\Benchmarker\verboseRun().
| MediaWiki\Maintenance\Maintenance::outputChanneled | ( | $msg, | |
| $channel = null ) |
Message outputter with channeled message support.
Messages on the same channel are concatenated, but any intervening messages in another channel start a new line.
| string | false | $msg | The message without trailing newline |
| string | null | $channel | Channel identifier or null for no channel. Channel comparison uses ===. |
Definition at line 587 of file Maintenance.php.
|
protected |
Utility function to parse a string (perhaps from a command line option) into a list of integers (perhaps some kind of numeric IDs).
| string | $text |
Definition at line 1441 of file Maintenance.php.
|
static |
Wrapper for posix_isatty() We default as considering stdin a tty (for nice readline methods) but treating stout as not a tty to avoid color codes.
| mixed | $fd | File descriptor |
Definition at line 1277 of file Maintenance.php.
|
protected |
| string | $prompt | The prompt to display to the user |
| string | null | $default | The default value to return if the user just presses enter |
Definition at line 1486 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::purgeRedundantText | ( | $delete = true | ) |
Support function for cleaning up redundant text records.
| bool | $delete | Whether or not to actually delete the records |
Definition at line 1039 of file Maintenance.php.
|
static |
Prompt the console for input.
| string | $prompt | What to begin the line with, like '> ' |
Definition at line 1290 of file Maintenance.php.
|
protected |
Indicate that the specified extension must be loaded before the script can run.
This must be called in the constructor.
| string | $name |
Definition at line 702 of file Maintenance.php.
|
static |
Call this to set up the autoloader to allow classes to be used from the tests directory.
Definition at line 1399 of file Maintenance.php.
|
protected |
Rollback the transaction on a DB handle.
This method makes it clear that rollback() is called from a maintenance script, which has outermost scope. This is safe, unlike $dbw->rollback() called in other places.
| IDatabase | $dbw | |
| string | $fname | Caller name |
Definition at line 1239 of file Maintenance.php.
References Wikimedia\Rdbms\IDatabase\rollback().
| MediaWiki\Maintenance\Maintenance::runChild | ( | $maintClass, | |
| $classFile = null ) |
Returns an instance of the given maintenance script, with all of the current arguments passed to it.
Callers are expected to run the returned maintenance script instance by calling Maintenance::execute
Maintenance::createChild instead. This method is an alias to that method. | string | $maintClass | A name of a child maintenance class |
| string | null | $classFile | Full path of where the child is |
Maintenance::execute on the returned object. Definition at line 744 of file Maintenance.php.
References $maintClass.
|
protected |
Sets whether to allow unregistered options, which are options passed to a script that do not match an expected parameter.
| bool | $allow | Should we allow? |
Definition at line 327 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::setArg | ( | $argId, | |
| $value ) |
Programmatically set the value of the given argument.
Useful for setting up child scripts, see runChild().
| string | int | $argId | Arg index or name |
| mixed | null | $value |
Definition at line 407 of file Maintenance.php.
|
protected |
| int | $s | The number of operations to do in a batch |
Definition at line 425 of file Maintenance.php.
Referenced by CheckImages\__construct(), MediaWiki\Maintenance\FixAutoblockLogTitles\__construct(), MediaWiki\Maintenance\DeleteLocalPasswords\__construct(), MediaWiki\Maintenance\LoggedUpdateMaintenance\__construct(), RefreshLinks\__construct(), UppercaseTitlesForUnicodeTransition\__construct(), and WrapOldPasswords\__construct().
| MediaWiki\Maintenance\Maintenance::setConfig | ( | Config | $config | ) |
| MediaWiki\Maintenance\Maintenance::setDB | ( | IMaintainableDatabase | $db | ) |
Sets database object to be returned by getDB().
| IMaintainableDatabase | $db |
Reimplemented in MediaWiki\Maintenance\BackupDumper.
Definition at line 1139 of file Maintenance.php.
Referenced by MediaWiki\Installer\DatabaseUpdater\__construct().
| MediaWiki\Maintenance\Maintenance::setDBProvider | ( | IConnectionProvider | $dbProvider | ) |
| IConnectionProvider | $dbProvider |
Definition at line 1170 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::setName | ( | string | $name | ) |
| MediaWiki\Maintenance\Maintenance::setOption | ( | string | $name, |
| $value ) |
Programmatically set the value of the given option.
Useful for setting up child scripts, see runChild().
| string | $name | |
| mixed | null | $value |
Definition at line 394 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\LoggedUpdateMaintenance\setForce().
| MediaWiki\Maintenance\Maintenance::setup | ( | ) |
Provides subclasses with an opportunity to perform initial checks.
Definition at line 795 of file Maintenance.php.
|
protected |
|
protected |
Checks to see if a particular option in supported.
Normally this means it has been registered by the script via addOption.
| string | $name | The name of the option |
Definition at line 250 of file Maintenance.php.
| MediaWiki\Maintenance\Maintenance::validateParamsAndArgs | ( | ) |
Run some validation checks on the params, etc.
Definition at line 888 of file Maintenance.php.
|
protected |
| string | $errorMsg | Error message to be displayed if neither –user or –userid are passed. |
Definition at line 1459 of file Maintenance.php.
Referenced by ChangePassword\execute().
|
protected |
Wait for replica DBs to catch up.
Definition at line 1212 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\FixAutoblockLogTitles\doDBUpdates(), AttachLatest\execute(), ImportImages\execute(), and MediaWiki\Maintenance\DeleteLocalPasswords\processUsers().
| resource null MediaWiki\Maintenance\Maintenance::$fileHandle |
Used when creating separate schema files.
Definition at line 156 of file Maintenance.php.
|
protected |
This is the list of arguments that were actually passed.
Definition at line 113 of file Maintenance.php.
|
protected |
Batch size.
If a script supports this, they should set a default with setBatchSize()
Definition at line 141 of file Maintenance.php.
|
protected |
Definition at line 121 of file Maintenance.php.
|
protected |
Definition at line 120 of file Maintenance.php.
|
protected |
A description of the script, children should change this via addDescription()
Definition at line 127 of file Maintenance.php.
|
protected |
Have we already loaded our user input?
Definition at line 133 of file Maintenance.php.
|
protected |
This is the list of options that were actually passed.
Definition at line 107 of file Maintenance.php.
|
protected |
Empty.
Definition at line 101 of file Maintenance.php.
|
protected |
Special vars for params that are always used.
Definition at line 119 of file Maintenance.php.
|
protected |
Name of the script currently running.
Definition at line 116 of file Maintenance.php.
| array MediaWiki\Maintenance\Maintenance::$orderedOptions = [] |
Used to read the options in the order they were passed.
Useful for option chaining (Ex. dumpBackup.php). It will be an empty array if the options are passed in through loadParamsAndArgs( $self, $opts, $args ).
This is an array of arrays where 0 => the option and 1 => parameter value.
Definition at line 189 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\BackupDumper\processOptions().
|
protected |
Definition at line 93 of file Maintenance.php.
| const MediaWiki\Maintenance\Maintenance::DB_ADMIN = 2 |
Definition at line 81 of file Maintenance.php.
| const MediaWiki\Maintenance\Maintenance::DB_NONE = 0 |
Constants for DB access type.
Definition at line 79 of file Maintenance.php.
| const MediaWiki\Maintenance\Maintenance::DB_STD = 1 |
Definition at line 80 of file Maintenance.php.
| const MediaWiki\Maintenance\Maintenance::GENERIC_MAINTENANCE_PARAMETERS = 'Script runner options' |
Definition at line 88 of file Maintenance.php.
Referenced by MediaWiki\Maintenance\MaintenanceRunner\addDefaultParams().
| const MediaWiki\Maintenance\Maintenance::SCRIPT_DEPENDENT_PARAMETERS = 'Common options' |
Definition at line 87 of file Maintenance.php.
| const MediaWiki\Maintenance\Maintenance::STDIN_ALL = -1 |
Definition at line 84 of file Maintenance.php.