MediaWiki  REL1_20
Maintenance Class Reference

Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effort. More...

Inherited by AllTrans, AlterSharedConstraints, AttachLatest, BackupReader, BatchedQueryRunner, Benchmarker, CacheStats, ChangePassword, CheckAutoLoader, CheckBadRedirects, CheckImages, CheckSyntax, CheckUsernames, CleanupAncientTables, CleanupPreferences, CleanupRemovedModules, CleanupSpam, clear_stats, ClearInterwikiCache, CLIParser, CommandLineInc, CommandLineInstaller, CompressOld, ConvertLinks, ConvertUserOptions, CopyFileBackend, CountMessages, CreateAndPromote, DatabaseLag, DateFormats, DeleteArchivedFiles, DeleteArchivedRevisions, DeleteBatch, DeleteDefaultMessages, DeleteImageCache, DeleteOldRevisions, DeleteOrphanedRevisions, DeleteRevision, DeleteSelfExternals, Digit2Html, DumpIterator, DumpLinks, DumpMessages, DumpRenderer, DumpRev, DumpSisterSites, EditCLI, FakeMaintenance, FetchText, FindHooks, FixBug20757, FixDoubleRedirects, FixSlaveDesync, FixTimestamps, FixUserRegistration, GenerateCollationData, GenerateNormalizerData, GenerateRandomImages, GenerateSitemap, GetLagTimes, GetSlaveServer, GetTextMaint, ImageBuilder, ImportSiteScripts, InitEditCount, InitStats, JSParseHelper, LangMemUsage, LoggedUpdateMaintenance, MaintenanceFixup, MaintenanceFormatInstallDoc, MakeLanguageSpec, mcTest, MergeMessageFileList, MigrateUserGroup, MinifyScript, MoveBatch, MwSql, NamespaceConflictChecker, nextJobDB, NukeNS, NukePage, Orphans, OrphanStats, PatchSql, PHPUnitMaintClass, PopulateCategory, Protect, PruneFileCache, PurgeDeletedFiles, PurgeList, PurgeOldText, PurgeParserCache, ReassignEdits, RebuildAll, RebuildFileCache, RebuildLocalisationCache, RebuildMessages, RebuildRecentchanges, RebuildTextIndex, RefreshImageMetadata, RefreshLinks, RemoveUnusedAccounts, RenameDbPrefix, ResetUserTokens, RollbackEdits, RunJobs, SeleniumTester, ShowJobs, ShowStats, SqliteMaintenance, StorageTypeStats, SyncFileBackend, TableCleanup, TestFileOpPerformance, Undelete, UpdateArticleCount, UpdateCollation, UpdateDoubleWidthSearch, UpdateMediaWiki, UpdateRestrictions, UpdateSearchIndex, UpdateSpecialPages, UploadDumper, UploadStashCleanup, and WaitForSlave.

Collaboration diagram for Maintenance:

List of all members.

Public Member Functions

 __construct ()
 Default constructor.
 cleanupChanneled ()
 Clean up channeled output.
 clearParamsAndArgs ()
 Clear all params and arguments.
 execute ()
 Do the actual work.
 finalSetup ()
 Handle some last-minute setup here.
 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.
 globals ()
 Potentially debug globals.
 isQuiet ()
 loadParamsAndArgs ($self=null, $opts=null, $args=null)
 Process command line arguments $mOptions becomes an array with keys set to the option names $mArgs becomes a zero-based array containing the non-option arguments.
 loadSettings ()
 Generic setup for most installs.
 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)
 Run a child maintenance script.
 setDB (&$db)
 Sets database object to be returned by getDB().
 setup ()
 Do some sanity checking and basic setup.
 updateSearchIndex ($maxLockTime, $callback, $dbw, $results)
 Perform a search index update with locking.
 updateSearchIndexForPage ($dbw, $pageId)
 Update the searchindex table for a given pageid.

Static Public Member Functions

static getMaintenanceScripts ()
 Get the list of available maintenance scripts.
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 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)

Public Attributes

 $mDbPass
const DB_ADMIN = 2
const DB_NONE = 0
 Constants for DB access type.
const DB_STD = 1
const STDIN_ALL = 'all'

Protected Member Functions

 addArg ($arg, $description, $required=true)
 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)
 Add a parameter to the script.
 adjustMemoryLimit ()
 Adjusts PHP's memory limit to better suit our needs, if needed.
 afterFinalSetup ()
 Execute a callback function at the end of initialisation.
 deleteOption ($name)
 Remove an option.
 error ($err, $die=0)
 Throw an error to the user.
 getArg ($argId=0, $default=null)
 Get an argument.
getDB ($db, $groups=array(), $wiki=false)
 Returns a database to be used by current maintenance script.
 getDir ()
 Get the maintenance directory.
 getOption ($name, $default=null)
 Get an option, or return the default.
 getStdin ($len=null)
 Return input from stdin.
 hasArg ($argId=0)
 Does a given argument exist?
 hasOption ($name)
 Checks to see if a particular param exists.
 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.
 setBatchSize ($s=0)
 Set the batch size.
 validateParamsAndArgs ()
 Run some validation checks on the params, etc.

Static Protected Member Functions

static getCoreScripts ()
 Return all of the core maintenance scripts.

Protected Attributes

 $mArgList = array()
 $mArgs = array()
int $mBatchSize = null
 Batch size.
 $mDbUser
 $mDescription = ''
 $mInputLoaded = false
 $mOptions = array()
 $mParams = array()
 $mQuiet = false
 $mSelf
 $mShortParamsMap = array()

Static Protected Attributes

static $mCoreScripts = null
 List of all the core maintenance scripts.

Private Member Functions

 lockSearchindex (&$db)
 Lock the search index.
 relockSearchindex (&$db)
 Unlock and lock again Since the lock is low-priority, queued reads will be able to complete.
 unlockSearchindex (&$db)
 Unlock the tables.

Static Private Member Functions

static readlineEmulation ($prompt)
 Emulate readline()

Private Attributes

 $atLineStart = true
 $lastChannel = null
DatabaseBase $mDb = null
 Used by getDD() / setDB()
 $mDependantParameters = array()
 $mGenericParameters = array()

Detailed Description

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.

Author:
Chad Horohoe <[email protected]>
Since:
1.16

Definition at line 51 of file Maintenance.php.


Constructor & Destructor Documentation

Default constructor.

Children should call this *first* if implementing their own constructors

Reimplemented in LoggedUpdateMaintenance, SearchDump, GenerateSitemap, CLIParser, GenerateCollationData, CompressOld, SeleniumTester, ImageCleanup, WatchlistCleanup, PreprocessDump, ImageBuilder, FindHooks, MoveBatch, NukeNS, TableCleanup, DumpRenderer, UpdateMediaWiki, bench_strtr_str_replace, CompareParsers, BackupReader, RefreshImageMetadata, UpdateCollation, Digit2Html, RebuildTextIndex, DumpIterator, DumpLinks, CommandLineInstaller, NamespaceConflictChecker, Benchmarker, CapsCleanup, TitleCleanup, DeleteBatch, MergeMessageFileList, Orphans, RebuildLocalisationCache, ShowStats, UpdateSearchIndex, MakeLanguageSpec, bench_utf8_title_check, UploadStashCleanup, CopyFileBackend, AttachLatest, CheckSyntax, CheckUsernames, ConvertLinks, ConvertUserOptions, DeleteArchivedRevisions, FixTimestamps, GenerateNormalizerData, ShowJobs, bench_HTTP_HTTPS, bench_if_switch, bench_wfIsWindows, DeleteArchivedFiles, DumpSisterSites, TestFileOpPerformance, FixDoubleRedirects, PopulateCategory, PopulateLogSearch, PopulateLogUsertext, RunJobs, UpdateArticleCount, UpdateRestrictions, ChangePassword, CleanupRemovedModules, DeleteImageCache, DeleteOrphanedRevisions, FixExtLinksProtocolRelative, DateFormats, PopulateParentId, PruneFileCache, PurgeParserCache, ReassignEdits, UpdateDoubleWidthSearch, CleanupAncientTables, CreateAndPromote, DeleteDefaultMessages, DeleteRevision, GetTextMaint, InitStats, JSParseHelper, DumpMessages, mcTest, MinifyScript, NukePage, PopulateRevisionSha1, RebuildRecentchanges, RemoveUnusedAccounts, RenameDbPrefix, ResetUserTokens, RollbackEdits, BatchedQueryRunner, BenchmarkDeleteTruncate, BenchmarkHooks, BenchmarkPurge, CleanupSpam, ClearInterwikiCache, clear_stats, DeleteOldRevisions, DeleteSelfExternals, UploadDumper, FetchText, FixSlaveDesync, FixUserRegistration, ImportSiteScripts, AllTrans, CountMessages, nextJobDB, PatchSql, PopulateRevisionLength, PurgeDeletedFiles, PurgeOldText, RebuildAll, MwSql, CacheStats, SyncFileBackend, UpdateSpecialPages, WaitForSlave, CheckAutoLoader, CheckBadRedirects, CheckImages, CommandLineInc, EditCLI, MaintenanceFormatInstallDoc, GetLagTimes, GetSlaveServer, DatabaseLag, MigrateUserGroup, AlterSharedConstraints, PopulateImageSha1, Protect, PurgeList, RebuildFileCache, RebuildMessages, RefreshLinks, SqliteMaintenance, FixBug20757, LangMemUsage, InitEditCount, Undelete, OrphanStats, DumpRev, and PHPUnitMaintClass.

Definition at line 120 of file Maintenance.php.


Member Function Documentation

Add the default parameters to the scripts.

Definition at line 408 of file Maintenance.php.

Maintenance::addDescription ( text) [protected]

Set the description text.

Parameters:
$textString: the text of the description

Definition at line 229 of file Maintenance.php.

Referenced by PurgeParserCache\__construct().

Maintenance::addOption ( name,
description,
required = false,
withArg = false,
shortName = false 
) [protected]

Add a parameter to the script.

Will be displayed on --help with the associated description

Parameters:
$nameString: the name of the param (help, version, etc)
$descriptionString: the description of the param to show on --help
$requiredBoolean: is the param required?
$withArgBoolean: is an argument required with this option?
$shortNameString: character to use as short name

Definition at line 171 of file Maintenance.php.

Referenced by PHPUnitMaintClass\__construct(), Undelete\__construct(), InitEditCount\__construct(), CommandLineInc\__construct(), SqliteMaintenance\__construct(), DatabaseLag\__construct(), FixBug20757\__construct(), EditCLI\__construct(), PopulateImageSha1\__construct(), Protect\__construct(), PurgeList\__construct(), MaintenanceFormatInstallDoc\__construct(), GetSlaveServer\__construct(), RebuildFileCache\__construct(), RefreshLinks\__construct(), ImportSiteScripts\__construct(), DeleteOldRevisions\__construct(), CleanupSpam\__construct(), SyncFileBackend\__construct(), UploadDumper\__construct(), UpdateSpecialPages\__construct(), nextJobDB\__construct(), PurgeDeletedFiles\__construct(), PurgeOldText\__construct(), RemoveUnusedAccounts\__construct(), RenameDbPrefix\__construct(), ResetUserTokens\__construct(), RollbackEdits\__construct(), InitStats\__construct(), mcTest\__construct(), MinifyScript\__construct(), CleanupAncientTables\__construct(), NukePage\__construct(), CreateAndPromote\__construct(), GetTextMaint\__construct(), CleanupRemovedModules\__construct(), UpdateDoubleWidthSearch\__construct(), ChangePassword\__construct(), DeleteImageCache\__construct(), DeleteOrphanedRevisions\__construct(), PruneFileCache\__construct(), PurgeParserCache\__construct(), ReassignEdits\__construct(), RunJobs\__construct(), UpdateArticleCount\__construct(), PopulateCategory\__construct(), TestFileOpPerformance\__construct(), FixDoubleRedirects\__construct(), DeleteArchivedFiles\__construct(), DeleteArchivedRevisions\__construct(), AttachLatest\__construct(), CheckSyntax\__construct(), GenerateNormalizerData\__construct(), ShowJobs\__construct(), CopyFileBackend\__construct(), Benchmarker\__construct(), UpdateSearchIndex\__construct(), Orphans\__construct(), MergeMessageFileList\__construct(), CapsCleanup\__construct(), DeleteBatch\__construct(), RebuildLocalisationCache\__construct(), DumpIterator\__construct(), CommandLineInstaller\__construct(), NamespaceConflictChecker\__construct(), BackupReader\__construct(), UpdateCollation\__construct(), CompareParsers\__construct(), RefreshImageMetadata\__construct(), DumpRenderer\__construct(), TableCleanup\__construct(), UpdateMediaWiki\__construct(), NukeNS\__construct(), FindHooks\__construct(), MoveBatch\__construct(), ImageBuilder\__construct(), WatchlistCleanup\__construct(), PreprocessDump\__construct(), SeleniumTester\__construct(), GenerateCollationData\__construct(), CompressOld\__construct(), CLIParser\__construct(), and SearchDump\__construct().

Adjusts PHP's memory limit to better suit our needs, if needed.

Definition at line 540 of file Maintenance.php.

Execute a callback function at the end of initialisation.

Reimplemented in UpdateMediaWiki.

Definition at line 881 of file Maintenance.php.

Clean up channeled output.

Output a newline if necessary.

Definition at line 354 of file Maintenance.php.

Clear all params and arguments.

Definition at line 553 of file Maintenance.php.

Maintenance::deleteOption ( name) [protected]

Remove an option.

Useful for removing options that won't be used in your script.

Parameters:
$nameString: the option to remove.

Definition at line 221 of file Maintenance.php.

Referenced by SeleniumTester\__construct().

Maintenance::error ( err,
die = 0 
) [protected]

Throw an error to the user.

Doesn't respect --quiet, so don't use this for non-error output

Parameters:
$errString: the error to display
$dieInt: if > 0, go ahead and die out using this int as the code

Definition at line 335 of file Maintenance.php.

Referenced by SqliteMaintenance\backup(), CheckSyntax\buildFileList(), ImageCleanup\buildSafeTitle(), CompareParsers\checkOptions(), SqliteMaintenance\checkSyntax(), CleanupSpam\cleanupArticle(), UpdateMediaWiki\compatChecks(), CompressOld\compressPage(), CompressOld\compressWithConcat(), CompareParsers\conclusions(), CopyFileBackend\copyFileBatch(), PopulateRevisionSha1\doDBUpdates(), PopulateRevisionLength\doDBUpdates(), FixExtLinksProtocolRelative\doDBUpdates(), PopulateParentId\doDBUpdates(), PopulateLogSearch\doDBUpdates(), PopulateImageSha1\doDBUpdates(), DumpRev\execute(), Undelete\execute(), LangMemUsage\execute(), OrphanStats\execute(), GetLagTimes\execute(), MwSql\execute(), BenchmarkPurge\execute(), DeleteRevision\execute(), MaintenanceFormatInstallDoc\execute(), BatchedQueryRunner\execute(), DeleteDefaultMessages\execute(), MigrateUserGroup\execute(), UpdateSpecialPages\execute(), CleanupAncientTables\execute(), RemoveUnusedAccounts\execute(), ImportSiteScripts\execute(), CleanupSpam\execute(), GetTextMaint\execute(), CheckUsernames\execute(), CacheStats\execute(), UpdateRestrictions\execute(), PruneFileCache\execute(), RollbackEdits\execute(), CreateAndPromote\execute(), GenerateNormalizerData\execute(), ChangePassword\execute(), PatchSql\execute(), Protect\execute(), RenameDbPrefix\execute(), EditCLI\execute(), FixDoubleRedirects\execute(), ReassignEdits\execute(), FixTimestamps\execute(), UpdateDoubleWidthSearch\execute(), CapsCleanup\execute(), Digit2Html\execute(), MergeMessageFileList\execute(), DumpIterator\execute(), DeleteBatch\execute(), RebuildFileCache\execute(), SqliteMaintenance\execute(), RebuildTextIndex\execute(), DumpRenderer\execute(), CopyFileBackend\execute(), UpdateSearchIndex\execute(), ConvertLinks\execute(), RunJobs\execute(), MoveBatch\execute(), MinifyScript\execute(), PHPUnitMaintClass\execute(), RefreshImageMetadata\execute(), GenerateCollationData\execute(), CompressOld\execute(), CommandLineInstaller\execute(), BackupReader\execute(), UpdateMediaWiki\execute(), GenerateNormalizerData\generateArabic(), GenerateCollationData\generateFirstChars(), MinifyScript\getExtension(), CheckSyntax\getGitModifiedFiles(), BackupReader\getNsIndex(), DumpRenderer\handleRevision(), DumpIterator\handleRevision(), ReassignEdits\initialiseUser(), SqliteMaintenance\integrityCheck(), MinifyScript\minify(), TitleCleanup\moveInconsistentPage(), ImageCleanup\pokeFile(), PreprocessDump\processRevision(), CompareParsers\processRevision(), BackupReader\skippedNamespace(), SyncFileBackend\syncBackends(), SyncFileBackend\syncFileBatch(), SqliteMaintenance\vacuum(), and CLIParser\Wikitext().

Maintenance::execute ( ) [abstract]

Do the actual work.

All child classes will need to implement this

Reimplemented in LoggedUpdateMaintenance, FakeMaintenance, SeleniumTester, GenerateSitemap, MaintenanceFixup, UpdateMediaWiki, BackupReader, bench_utf8_title_check, CommandLineInstaller, UpdateCollation, CLIParser, CompressOld, GenerateCollationData, PopulateCategory, RefreshImageMetadata, ImageBuilder, RebuildLocalisationCache, FindHooks, MinifyScript, PHPUnitMaintClass, MoveBatch, WatchlistCleanup, ConvertLinks, NukeNS, RunJobs, UpdateSearchIndex, CheckSyntax, CopyFileBackend, DumpRenderer, NamespaceConflictChecker, RebuildTextIndex, SqliteMaintenance, CommandLineInc, DeleteBatch, RebuildFileCache, TableCleanup, DumpIterator, MergeMessageFileList, Orphans, PopulateImageSha1, bench_strtr_str_replace, FetchText, DeleteArchivedFiles, DeleteArchivedRevisions, Digit2Html, CapsCleanup, DumpLinks, TestFileOpPerformance, PurgeParserCache, UpdateDoubleWidthSearch, MakeLanguageSpec, FixTimestamps, ReassignEdits, RefreshLinks, SyncFileBackend, EditCLI, FixDoubleRedirects, RenameDbPrefix, ShowStats, AttachLatest, ChangePassword, UploadStashCleanup, CreateAndPromote, UploadDumper, InitStats, GenerateNormalizerData, PatchSql, Protect, RollbackEdits, CheckUsernames, CleanupRemovedModules, ConvertUserOptions, DeleteImageCache, FixSlaveDesync, mcTest, PruneFileCache, ShowJobs, CacheStats, UpdateArticleCount, UpdateRestrictions, bench_HTTP_HTTPS, bench_if_switch, bench_wfIsWindows, CleanupSpam, DeleteOrphanedRevisions, DumpSisterSites, GetTextMaint, ImportSiteScripts, InitEditCount, NukePage, AlterSharedConstraints, RemoveUnusedAccounts, CleanupAncientTables, DeleteDefaultMessages, DeleteOldRevisions, JSParseHelper, DateFormats, MigrateUserGroup, PurgeDeletedFiles, PurgeList, ResetUserTokens, BatchedQueryRunner, UpdateSpecialPages, DeleteRevision, DeleteSelfExternals, MaintenanceFormatInstallDoc, DumpMessages, nextJobDB, PurgeOldText, RebuildRecentchanges, FixBug20757, BenchmarkDeleteTruncate, BenchmarkHooks, BenchmarkPurge, CheckImages, ClearInterwikiCache, clear_stats, FixUserRegistration, DatabaseLag, AllTrans, CountMessages, RebuildAll, MwSql, CheckBadRedirects, GetLagTimes, GetSlaveServer, RebuildMessages, CheckAutoLoader, LangMemUsage, OrphanStats, WaitForSlave, Undelete, CleanupPreferences, DumpRev, StorageTypeStats, and GenerateRandomImages.

Handle some last-minute setup here.

Reimplemented in DumpIterator, RebuildFileCache, and PHPUnitMaintClass.

Definition at line 826 of file Maintenance.php.

static Maintenance::getCoreScripts ( ) [static, protected]

Return all of the core maintenance scripts.

Returns:
array

Definition at line 1008 of file Maintenance.php.

& Maintenance::getDB ( db,
groups = array(),
wiki = false 
) [protected]

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

Returns:
Integer

Reimplemented in SearchDump, MwSql, PHPUnitMaintClass, BatchedQueryRunner, UpdateMediaWiki, PreprocessDump, FindHooks, ConvertLinks, UpdateSearchIndex, CheckSyntax, RebuildTextIndex, SqliteMaintenance, UpdateDoubleWidthSearch, RenameDbPrefix, PatchSql, FixSlaveDesync, CacheStats, AlterSharedConstraints, and GenerateRandomImages.

Definition at line 401 of file Maintenance.php.

Referenced by DumpIterator\finalSetup().

Maintenance::getDir ( ) [protected]

Get the maintenance directory.

Returns:
string

Definition at line 989 of file Maintenance.php.

Get the list of available maintenance scripts.

Note that if you call this _before_ calling doMaintenance you won't have any extensions in it yet

Returns:
Array

Definition at line 999 of file Maintenance.php.

Get the script's name.

Returns:
String

Definition at line 278 of file Maintenance.php.

Maintenance::getOption ( name,
default = null 
) [protected]

Get an option, or return the default.

Parameters:
$nameString: the name of the param
$defaultMixed: anything you want, default null
Returns:
Mixed

Definition at line 193 of file Maintenance.php.

Referenced by Benchmarker\bench(), CheckSyntax\buildFileList(), PreprocessDump\checkOptions(), CompareParsers\checkOptions(), SqliteMaintenance\checkSyntax(), PopulateImageSha1\doDBUpdates(), TestFileOpPerformance\doPerfTest(), Undelete\execute(), GetSlaveServer\execute(), BenchmarkPurge\execute(), MaintenanceFormatInstallDoc\execute(), nextJobDB\execute(), FixBug20757\execute(), UpdateSpecialPages\execute(), ResetUserTokens\execute(), NukePage\execute(), ImportSiteScripts\execute(), RemoveUnusedAccounts\execute(), CleanupRemovedModules\execute(), PruneFileCache\execute(), DeleteImageCache\execute(), mcTest\execute(), Protect\execute(), ChangePassword\execute(), GenerateNormalizerData\execute(), UploadDumper\execute(), RollbackEdits\execute(), FixDoubleRedirects\execute(), RenameDbPrefix\execute(), EditCLI\execute(), RefreshLinks\execute(), SyncFileBackend\execute(), UpdateDoubleWidthSearch\execute(), PurgeParserCache\execute(), TestFileOpPerformance\execute(), PopulateImageSha1\execute(), MergeMessageFileList\execute(), DumpIterator\execute(), DeleteBatch\execute(), RebuildFileCache\execute(), SqliteMaintenance\execute(), NamespaceConflictChecker\execute(), CopyFileBackend\execute(), DumpRenderer\execute(), UpdateSearchIndex\execute(), RunJobs\execute(), NukeNS\execute(), MoveBatch\execute(), PHPUnitMaintClass\execute(), MinifyScript\execute(), RebuildLocalisationCache\execute(), PopulateCategory\execute(), RefreshImageMetadata\execute(), GenerateCollationData\execute(), CompressOld\execute(), UpdateCollation\execute(), CommandLineInstaller\execute(), BackupReader\execute(), SeleniumTester\execute(), CLIParser\getTitle(), MinifyScript\minify(), CompareParsers\processRevision(), SearchDump\processRevision(), PurgeDeletedFiles\purgeFromLogType(), PurgeList\purgeList(), PurgeList\purgeNamespace(), and SyncFileBackend\syncFileBatch().

Maintenance::getStdin ( len = null) [protected]

Return input from stdin.

Parameters:
$lenInteger: the number of bytes to read. If null, just return the handle. Maintenance::STDIN_ALL returns the full length
Returns:
Mixed

Reimplemented in SemiMockedFetchText.

Definition at line 289 of file Maintenance.php.

Referenced by EditCLI\execute(), FetchText\execute(), DumpIterator\execute(), DeleteBatch\execute(), DumpRenderer\execute(), MoveBatch\execute(), and PurgeList\purgeList().

Potentially debug globals.

Originally a feature only for refreshLinks

Definition at line 891 of file Maintenance.php.

Maintenance::hasArg ( argId = 0) [protected]

Does a given argument exist?

Parameters:
$argIdInteger: the integer value (from zero) for the arg
Returns:
Boolean

Definition at line 238 of file Maintenance.php.

Referenced by MwSql\execute(), MaintenanceFormatInstallDoc\execute(), BatchedQueryRunner\execute(), JSParseHelper\execute(), FixSlaveDesync\execute(), mcTest\execute(), ReassignEdits\execute(), DeleteBatch\execute(), MoveBatch\execute(), and BackupReader\execute().

Maintenance::hasOption ( name) [protected]

Checks to see if a particular param exists.

Parameters:
$nameString: the name of the param
Returns:
Boolean

Definition at line 183 of file Maintenance.php.

Referenced by CheckSyntax\buildFileList(), PreprocessDump\checkOptions(), CompareParsers\checkOptions(), CleanupSpam\cleanupArticle(), CopyFileBackend\copyFileBatch(), ConvertLinks\createTempTable(), TestFileOpPerformance\doPerfTest(), GetSlaveServer\execute(), BenchmarkPurge\execute(), DatabaseLag\execute(), PurgeOldText\execute(), MaintenanceFormatInstallDoc\execute(), UpdateSpecialPages\execute(), DeleteOldRevisions\execute(), PurgeList\execute(), CleanupAncientTables\execute(), InitEditCount\execute(), CleanupSpam\execute(), DeleteOrphanedRevisions\execute(), RemoveUnusedAccounts\execute(), GetTextMaint\execute(), ShowJobs\execute(), UpdateArticleCount\execute(), InitStats\execute(), CreateAndPromote\execute(), GenerateNormalizerData\execute(), Protect\execute(), AttachLatest\execute(), UploadDumper\execute(), ChangePassword\execute(), RollbackEdits\execute(), EditCLI\execute(), RefreshLinks\execute(), ReassignEdits\execute(), CapsCleanup\execute(), DeleteArchivedFiles\execute(), DeleteArchivedRevisions\execute(), MergeMessageFileList\execute(), Orphans\execute(), TableCleanup\execute(), DumpIterator\execute(), NamespaceConflictChecker\execute(), SqliteMaintenance\execute(), CopyFileBackend\execute(), CheckSyntax\execute(), DumpRenderer\execute(), WatchlistCleanup\execute(), ConvertLinks\execute(), UpdateSearchIndex\execute(), RunJobs\execute(), MinifyScript\execute(), RebuildLocalisationCache\execute(), ImageBuilder\execute(), RefreshImageMetadata\execute(), UpdateCollation\execute(), CommandLineInstaller\execute(), BackupReader\execute(), UpdateMediaWiki\execute(), SeleniumTester\execute(), CopyFileBackend\filesAreSame(), FindHooks\getHooksFromDoc(), BackupReader\importFromHandle(), RunJobs\memoryLimit(), RebuildLocalisationCache\memoryLimit(), WatchlistCleanup\removeWatch(), and CommandLineInstaller\validateParamsAndArgs().

Returns:
bool

Definition at line 305 of file Maintenance.php.

Referenced by SyncFileBackend\execute().

Maintenance::loadParamsAndArgs ( self = null,
opts = null,
args = null 
)

Process command line arguments $mOptions becomes an array with keys set to the option names $mArgs becomes a zero-based array containing the non-option arguments.

Parameters:
$selfString The name of the script, if any
$optsArray An array of options, in form of key=>value
$argsArray An array of command line arguments

Definition at line 568 of file Maintenance.php.

Referenced by TemplateCategoriesTest\testTemplateCategories().

Generic setup for most installs.

Returns the location of LocalSettings

Returns:
String

Definition at line 901 of file Maintenance.php.

Handle the special variables that are global to all scripts.

Definition at line 692 of file Maintenance.php.

Maintenance::lockSearchindex ( &$  db) [private]

Lock the search index.

Parameters:
&$dbDatabaseBase object

Definition at line 1067 of file Maintenance.php.

Maintenance::maybeHelp ( force = false) [protected]

Maybe show the help.

Parameters:
$forceboolean Whether to force the help to show, default false

Reimplemented in CommandLineInc.

Definition at line 711 of file Maintenance.php.

Referenced by JSParseHelper\execute(), and BackupReader\importFromStdin().

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. We also support a --memory-limit option, to allow sysadmins to explicitly set one if they'd prefer to override defaults (or for people using Suhosin which yells at you for trying to disable the limits)

Returns:
string

Reimplemented in RebuildLocalisationCache, and RunJobs.

Definition at line 531 of file Maintenance.php.

Maintenance::output ( out,
channel = null 
) [protected]

Throw some output to the user.

Scripts can call this with no fears, as we handle all --quiet stuff here

Parameters:
$outString: the text to show to the user
$channelMixed: unique identifier for the channel. See function outputChanneled.

Reimplemented in MaintenanceFixup.

Definition at line 316 of file Maintenance.php.

Referenced by ImageBuilder\addMissingImage(), SqliteMaintenance\backup(), CheckSyntax\buildFileList(), ImageBuilder\buildTable(), CheckSyntax\checkEvilToken(), CheckSyntax\checkFileWithCli(), CheckSyntax\checkFileWithParsekit(), Orphans\checkOrphans(), CheckSyntax\checkRegex(), Orphans\checkSeparation(), SqliteMaintenance\checkSyntax(), Orphans\checkWidows(), CleanupSpam\cleanupArticle(), CompressOld\compressOldPages(), CompressOld\compressWithConcat(), CompareParsers\conclusions(), CopyFileBackend\copyFileBatch(), ConvertLinks\createTempTable(), RefreshLinks\deleteLinksFromNonexistent(), FixSlaveDesync\desyncFixPage(), PopulateRevisionSha1\doDBUpdates(), PopulateRevisionLength\doDBUpdates(), FixExtLinksProtocolRelative\doDBUpdates(), PopulateParentId\doDBUpdates(), PopulateLogSearch\doDBUpdates(), PopulateLogUsertext\doDBUpdates(), PopulateImageSha1\doDBUpdates(), DeleteOldRevisions\doDelete(), TestFileOpPerformance\doPerfTest(), PopulateCategory\doPopulateCategory(), ReassignEdits\doReassignEdits(), RebuildLocalisationCache\doRebuild(), RefreshLinks\doRefreshLinks(), PopulateRevisionSha1\doSha1LegacyUpdates(), PopulateRevisionSha1\doSha1Updates(), UpdateSearchIndex\doUpdateSearchIndex(), DumpRev\execute(), CleanupPreferences\execute(), Undelete\execute(), OrphanStats\execute(), LangMemUsage\execute(), CheckAutoLoader\execute(), RebuildMessages\execute(), GetLagTimes\execute(), GetSlaveServer\execute(), CheckBadRedirects\execute(), ClearInterwikiCache\execute(), FixUserRegistration\execute(), BenchmarkHooks\execute(), DatabaseLag\execute(), AllTrans\execute(), CountMessages\execute(), BenchmarkPurge\execute(), CheckImages\execute(), RebuildAll\execute(), RebuildRecentchanges\execute(), DumpMessages\execute(), nextJobDB\execute(), DeleteRevision\execute(), DeleteSelfExternals\execute(), ResetUserTokens\execute(), BatchedQueryRunner\execute(), JSParseHelper\execute(), DateFormats\execute(), UpdateSpecialPages\execute(), MigrateUserGroup\execute(), DeleteDefaultMessages\execute(), DeleteOldRevisions\execute(), CleanupAncientTables\execute(), PurgeDeletedFiles\execute(), PurgeList\execute(), RemoveUnusedAccounts\execute(), ImportSiteScripts\execute(), InitEditCount\execute(), CleanupSpam\execute(), NukePage\execute(), AlterSharedConstraints\execute(), DeleteOrphanedRevisions\execute(), GetTextMaint\execute(), DumpSisterSites\execute(), ShowJobs\execute(), ConvertUserOptions\execute(), CacheStats\execute(), UpdateArticleCount\execute(), CleanupRemovedModules\execute(), mcTest\execute(), UpdateRestrictions\execute(), DeleteImageCache\execute(), PruneFileCache\execute(), AttachLatest\execute(), ChangePassword\execute(), RollbackEdits\execute(), InitStats\execute(), PatchSql\execute(), CreateAndPromote\execute(), Protect\execute(), UploadStashCleanup\execute(), FixDoubleRedirects\execute(), RenameDbPrefix\execute(), EditCLI\execute(), ShowStats\execute(), FixTimestamps\execute(), SyncFileBackend\execute(), ReassignEdits\execute(), UpdateDoubleWidthSearch\execute(), DumpLinks\execute(), Digit2Html\execute(), DeleteArchivedRevisions\execute(), DeleteArchivedFiles\execute(), FetchText\execute(), TableCleanup\execute(), DeleteBatch\execute(), RebuildFileCache\execute(), RebuildTextIndex\execute(), NamespaceConflictChecker\execute(), CheckSyntax\execute(), CopyFileBackend\execute(), ConvertLinks\execute(), NukeNS\execute(), WatchlistCleanup\execute(), MoveBatch\execute(), FindHooks\execute(), PHPUnitMaintClass\execute(), RebuildLocalisationCache\execute(), RefreshImageMetadata\execute(), CompressOld\execute(), UpdateCollation\execute(), BackupReader\execute(), UpdateMediaWiki\execute(), SeleniumTester\execute(), ImportSiteScripts\fetchScriptList(), FixSlaveDesync\findPageLatestCorruption(), DeleteArchivedRevisions\handleOutput(), DeleteArchivedFiles\handleOutput(), DumpRenderer\handleRevision(), DumpIterator\handleRevision(), SqliteMaintenance\integrityCheck(), ImageCleanup\killRow(), MinifyScript\minify(), TitleCleanup\moveIllegalPage(), TitleCleanup\moveInconsistentPage(), ImageBuilder\oldimageCallback(), UploadDumper\outputItem(), ImageCleanup\pokeFile(), FindHooks\printArray(), CompareParsers\processRevision(), SearchDump\processRevision(), TitleCleanup\processRow(), ImageCleanup\processRow(), WatchlistCleanup\processRow(), CapsCleanup\processRow(), TableCleanup\progress(), ImageBuilder\progress(), PruneFileCache\prune_directory(), RebuildRecentchanges\purgeFeeds(), PurgeDeletedFiles\purgeFromLogType(), PurgeList\purgeList(), PurgeList\purgeNamespace(), FixDoubleRedirects\queueJobs(), RebuildRecentchanges\rebuildRecentChangesTablePass1(), RebuildRecentchanges\rebuildRecentChangesTablePass2(), RebuildRecentchanges\rebuildRecentChangesTablePass3(), RebuildRecentchanges\rebuildRecentChangesTablePass4(), WatchlistCleanup\removeWatch(), RunJobs\runJobsLog(), TableCleanup\runTable(), UpdateSearchIndex\searchIndexUpdateCallback(), PurgeList\sendPurgeRequest(), UpdateCollation\showSortKeySizeHistogram(), MwSql\sqlPrintResult(), SyncFileBackend\syncBackends(), SyncFileBackend\syncFileBatch(), PopulateRevisionSha1\upgradeLegacyArchiveRow(), PopulateRevisionSha1\upgradeRow(), and SqliteMaintenance\vacuum().

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.

Parameters:
$msgString: the message without trailing newline
$channelstring Channel identifier or null for no channel. Channel comparison uses ===.

Reimplemented in MaintenanceFixup.

Definition at line 369 of file Maintenance.php.

static Maintenance::posix_isatty ( fd) [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.

Parameters:
$fdint File descriptor
Returns:
bool

Definition at line 1160 of file Maintenance.php.

Referenced by MwSql\execute().

Maintenance::purgeRedundantText ( delete = true)

Support function for cleaning up redundant text records.

Parameters:
$deleteBoolean: whether or not to actually delete the records
Author:
Rob Church <[email protected]>

Definition at line 934 of file Maintenance.php.

Referenced by DeleteOldRevisions\doDelete(), PurgeOldText\execute(), NukePage\execute(), DeleteOrphanedRevisions\execute(), and NukeNS\execute().

static Maintenance::readconsole ( prompt = ',
 
) [static]

Prompt the console for input.

Parameters:
$promptString what to begin the line with, like '> '
Returns:
String response

Definition at line 1173 of file Maintenance.php.

Referenced by MwSql\execute().

static Maintenance::readlineEmulation ( prompt) [static, private]

Emulate readline()

Parameters:
$promptString what to begin the line with, like '> '
Returns:
String

Definition at line 1202 of file Maintenance.php.

Maintenance::relockSearchindex ( &$  db) [private]

Unlock and lock again Since the lock is low-priority, queued reads will be able to complete.

Parameters:
&$dbDatabaseBase object

Definition at line 1086 of file Maintenance.php.

Maintenance::runChild ( maintClass,
classFile = null 
)

Run a child maintenance script.

Pass all of the current arguments to it.

Parameters:
$maintClassString: a name of a child maintenance class
$classFileString: full path of where the child is
Returns:
Maintenance child

Definition at line 445 of file Maintenance.php.

Referenced by RebuildAll\execute(), NukeNS\execute(), and UpdateMediaWiki\execute().

Maintenance::setDB ( &$  db)

Sets database object to be returned by getDB().

Parameters:
$dbDatabaseBase: Database object to be used

Definition at line 1059 of file Maintenance.php.

Do some sanity checking and basic setup.

Definition at line 470 of file Maintenance.php.

static Maintenance::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:
Boolean

Definition at line 138 of file Maintenance.php.

Maintenance::unlockSearchindex ( &$  db) [private]

Unlock the tables.

Parameters:
&$dbDatabaseBase object

Definition at line 1077 of file Maintenance.php.

Maintenance::updateSearchIndex ( maxLockTime,
callback,
dbw,
results 
)

Perform a search index update with locking.

Parameters:
$maxLockTimeInteger: the maximum time to keep the search index locked.
$callbackcallback String: the function that will update the function.
$dbwDatabaseBase object
$results

Definition at line 1098 of file Maintenance.php.

Referenced by UpdateSearchIndex\doUpdateSearchIndex(), and UpdateDoubleWidthSearch\execute().

Maintenance::updateSearchIndexForPage ( dbw,
pageId 
)

Update the searchindex table for a given pageid.

Parameters:
$dbwDatabaseBase a database write handle
$pageIdInteger: the page ID to update.
Returns:
null|string

Definition at line 1136 of file Maintenance.php.

Referenced by UpdateDoubleWidthSearch\searchIndexUpdateCallback(), and UpdateSearchIndex\searchIndexUpdateCallback().

Run some validation checks on the params, etc.

Reimplemented in CommandLineInstaller.

Definition at line 667 of file Maintenance.php.


Member Data Documentation

Maintenance::$atLineStart = true [private]

Definition at line 348 of file Maintenance.php.

Maintenance::$lastChannel = null [private]

Definition at line 349 of file Maintenance.php.

Maintenance::$mArgList = array() [protected]

Definition at line 71 of file Maintenance.php.

Maintenance::$mArgs = array() [protected]

Definition at line 77 of file Maintenance.php.

int Maintenance::$mBatchSize = null [protected]

Batch size.

If a script supports this, they should set a default with setBatchSize()

Definition at line 97 of file Maintenance.php.

Maintenance::$mCoreScripts = null [static, protected]

List of all the core maintenance scripts.

This is added to scripts added by extensions in $wgMaintenanceScripts and returned by getMaintenanceScripts()

Definition at line 114 of file Maintenance.php.

DatabaseBase Maintenance::$mDb = null [private]

Used by getDD() / setDB()

Definition at line 107 of file Maintenance.php.

Maintenance::$mDbPass

Definition at line 84 of file Maintenance.php.

Maintenance::$mDbUser [protected]

Definition at line 84 of file Maintenance.php.

Maintenance::$mDependantParameters = array() [private]

Definition at line 102 of file Maintenance.php.

Maintenance::$mDescription = '' [protected]

Definition at line 87 of file Maintenance.php.

Maintenance::$mGenericParameters = array() [private]

Definition at line 100 of file Maintenance.php.

Maintenance::$mInputLoaded = false [protected]

Definition at line 90 of file Maintenance.php.

Maintenance::$mOptions = array() [protected]

Definition at line 74 of file Maintenance.php.

Maintenance::$mParams = array() [protected]

Definition at line 65 of file Maintenance.php.

Maintenance::$mQuiet = false [protected]

Definition at line 83 of file Maintenance.php.

Maintenance::$mSelf [protected]

Reimplemented in FakeMaintenance.

Definition at line 80 of file Maintenance.php.

Maintenance::$mShortParamsMap = array() [protected]

Definition at line 68 of file Maintenance.php.

Definition at line 58 of file Maintenance.php.

const Maintenance::STDIN_ALL = 'all'

Definition at line 62 of file Maintenance.php.

Referenced by EditCLI\execute().


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