MediaWiki  REL1_19
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, CleanupRemovedModules, CleanupSpam, clear_stats, ClearInterwikiCache, CLIParser, CommandLineInc, CommandLineInstaller, CompressOld, ConvertLinks, ConvertUserOptions, 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, Lang2Po, LangMemUsage, LoggedUpdateMaintenance, 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, RefreshImageCount, RefreshImageMetadata, RefreshLinks, RemoveUnusedAccounts, RenameDbPrefix, ResetUserTokens, RollbackEdits, RunJobs, SeleniumTester, ShowJobs, ShowStats, SqliteMaintenance, StorageTypeStats, TableCleanup, Undelete, UpdateArticleCount, UpdateDoubleWidthSearch, UpdateMediaWiki, UpdateRestrictions, UpdateSearchIndex, UpdateSpecialPages, UploadDumper, UploadStashCleanup, and WaitForSlave.

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()
 $mBatchSize = null
 $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
 $mDb = null
 $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 50 of file Maintenance.php.


Constructor & Destructor Documentation

Default constructor.

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

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

Definition at line 118 of file Maintenance.php.

References $IP, and addDefaultParams().

Here is the call graph for this function:


Member Function Documentation

Add the default parameters to the scripts.

Definition at line 425 of file Maintenance.php.

References addOption(), and getDbType().

Referenced by __construct().

Here is the call graph for this function:

Here is the caller graph for this function:

Maintenance::addDescription ( text) [protected]

Set the description text.

Parameters:
$textString: the text of the description

Definition at line 227 of file Maintenance.php.

Referenced by PurgeParserCache\__construct().

Here is the caller graph for this function:

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 169 of file Maintenance.php.

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

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

Definition at line 557 of file Maintenance.php.

References $limit, and memoryLimit().

Referenced by finalSetup(), and setup().

Here is the call graph for this function:

Here is the caller graph for this function:

Execute a callback function at the end of initialisation.

Reimplemented in UpdateMediaWiki.

Definition at line 898 of file Maintenance.php.

Referenced by finalSetup().

Here is the caller graph for this function:

Clean up channeled output.

Output a newline if necessary.

Definition at line 353 of file Maintenance.php.

References print.

Referenced by output(), and outputChanneled().

Here is the caller graph for this function:

Clear all params and arguments.

Definition at line 570 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 219 of file Maintenance.php.

Referenced by SeleniumTester\__construct().

Here is the caller graph for this function:

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 334 of file Maintenance.php.

References outputChanneled(), and print.

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

Here is the call graph for this function:

Maintenance::execute ( ) [abstract]

Do the actual work.

All child classes will need to implement this

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

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

Return all of the core maintenance scripts.

Returns:
array

Definition at line 1025 of file Maintenance.php.

References $file, and $mCoreScripts.

Referenced by getMaintenanceScripts().

Here is the caller graph for this function:

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

Returns a database to be used by current maintenance script.

It can be set by setDB(). If not set, wfGetDB() will be used. This function has the same parameters as wfGetDB()

Returns:
DatabaseBase

Definition at line 1064 of file Maintenance.php.

References wfGetDB().

Referenced by PopulateRevisionSha1\doDBUpdates(), PopulateRevisionLength\doDBUpdates(), PopulateLogSearch\doDBUpdates(), PopulateLogUsertext\doDBUpdates(), PopulateRevisionSha1\doSha1LegacyUpdates(), PopulateRevisionSha1\doSha1Updates(), LoggedUpdateMaintenance\execute(), purgeRedundantText(), PopulateRevisionSha1\upgradeLegacyArchiveRow(), and PopulateRevisionSha1\upgradeRow().

Here is the call graph for this function:

Here is the caller graph for this function:

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, UpdateSearchIndex, CheckSyntax, ConvertLinks, RebuildTextIndex, SqliteMaintenance, AlterSharedConstraints, UpdateDoubleWidthSearch, PatchSql, RenameDbPrefix, CacheStats, and FixSlaveDesync.

Definition at line 418 of file Maintenance.php.

References DB_STD.

Referenced by addDefaultParams(), DumpIterator\finalSetup(), and finalSetup().

Here is the caller graph for this function:

Maintenance::getDir ( ) [protected]

Get the maintenance directory.

Returns:
string

Definition at line 1006 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 1016 of file Maintenance.php.

References $wgMaintenanceScripts, and getCoreScripts().

Here is the call graph for this function:

Get the script's name.

Returns:
String

Definition at line 276 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 191 of file Maintenance.php.

References hasOption().

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

Here is the call graph for this function:

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

Definition at line 287 of file Maintenance.php.

References $f, $input, and STDIN_ALL.

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

Here is the caller graph for this function:

Potentially debug globals.

Originally a feature only for refreshLinks

Definition at line 908 of file Maintenance.php.

References hasOption().

Here is the call graph for this function:

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 236 of file Maintenance.php.

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

Here is the caller graph for this function:

Maintenance::hasOption ( name) [protected]

Checks to see if a particular param exists.

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

Definition at line 181 of file Maintenance.php.

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

Definition at line 300 of file Maintenance.php.

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 585 of file Maintenance.php.

References $options, $self, error(), loadSpecialVars(), and maybeHelp().

Referenced by setup(), and TemplateCategoriesTest\testTemplateCategories().

Here is the call graph for this function:

Here is the caller graph for this function:

Generic setup for most installs.

Returns the location of LocalSettings

Returns:
String

Definition at line 918 of file Maintenance.php.

References $IP, $wgCommandLineMode, and error().

Here is the call graph for this function:

Handle the special variables that are global to all scripts.

Definition at line 709 of file Maintenance.php.

References getOption(), and hasOption().

Referenced by loadParamsAndArgs().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Lock the search index.

Parameters:
&$dbDatabase object

Definition at line 1085 of file Maintenance.php.

Referenced by relockSearchindex(), and updateSearchIndex().

Here is the caller graph for this function:

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 728 of file Maintenance.php.

References $output, hasOption(), and output().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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 548 of file Maintenance.php.

References $limit, and getOption().

Referenced by adjustMemoryLimit().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Definition at line 311 of file Maintenance.php.

References $out, cleanupChanneled(), outputChanneled(), and print.

Referenced by ImageBuilder\addMissingImage(), SqliteMaintenance\backup(), CheckSyntax\buildFileList(), ImageBuilder\buildTable(), CheckSyntax\checkEvilToken(), CheckSyntax\checkFileWithCli(), CheckSyntax\checkFileWithParsekit(), Orphans\checkOrphans(), NamespaceConflictChecker\checkPrefix(), CheckSyntax\checkRegex(), Orphans\checkSeparation(), SqliteMaintenance\checkSyntax(), Orphans\checkWidows(), CleanupSpam\cleanupArticle(), RebuildTextIndex\clearSearchIndex(), CompressOld\compressOldPages(), CompressOld\compressWithConcat(), CompareParsers\conclusions(), RebuildTextIndex\createMysqlTextIndex(), ConvertLinks\createTempTable(), RefreshLinks\deleteLinksFromNonexistent(), FixSlaveDesync\desyncFixPage(), PopulateRevisionSha1\doDBUpdates(), PopulateRevisionLength\doDBUpdates(), PopulateParentId\doDBUpdates(), FixExtLinksProtocolRelative\doDBUpdates(), PopulateLogUsertext\doDBUpdates(), PopulateLogSearch\doDBUpdates(), PopulateImageSha1\doDBUpdates(), DeleteOldRevisions\doDelete(), PopulateCategory\doPopulateCategory(), ReassignEdits\doReassignEdits(), RebuildLocalisationCache\doRebuild(), RefreshLinks\doRefreshLinks(), PopulateRevisionSha1\doSha1LegacyUpdates(), PopulateRevisionSha1\doSha1Updates(), UpdateSearchIndex\doUpdateSearchIndex(), RebuildTextIndex\dropMysqlTextIndex(), ImportSiteScripts\execute(), GetLagTimes\execute(), DumpRev\execute(), GetSlaveServer\execute(), RebuildMessages\execute(), CheckAutoLoader\execute(), AllTrans\execute(), CountMessages\execute(), BenchmarkHooks\execute(), RebuildAll\execute(), FixUserRegistration\execute(), RefreshImageCount\execute(), DeleteRevision\execute(), RebuildRecentchanges\execute(), DatabaseLag\execute(), DumpMessages\execute(), DeleteDefaultMessages\execute(), CheckBadRedirects\execute(), nextJobDB\execute(), BenchmarkPurge\execute(), PurgeDeletedFiles\execute(), CheckImages\execute(), GetTextMaint\execute(), JSParseHelper\execute(), CleanupSpam\execute(), BatchedQueryRunner\execute(), DateFormats\execute(), MigrateUserGroup\execute(), ClearInterwikiCache\execute(), PurgeList\execute(), ConvertUserOptions\execute(), RemoveUnusedAccounts\execute(), ResetUserTokens\execute(), Undelete\execute(), mcTest\execute(), UpdateSpecialPages\execute(), DeleteOldRevisions\execute(), NukePage\execute(), DumpSisterSites\execute(), ShowJobs\execute(), LangMemUsage\execute(), CacheStats\execute(), OrphanStats\execute(), UpdateArticleCount\execute(), DeleteImageCache\execute(), UpdateRestrictions\execute(), DeleteOrphanedRevisions\execute(), RollbackEdits\execute(), PruneFileCache\execute(), RenameDbPrefix\execute(), DeleteSelfExternals\execute(), CleanupRemovedModules\execute(), PatchSql\execute(), UploadStashCleanup\execute(), Protect\execute(), FixTimestamps\execute(), ChangePassword\execute(), InitStats\execute(), CreateAndPromote\execute(), AttachLatest\execute(), ShowStats\execute(), EditCLI\execute(), ReassignEdits\execute(), Digit2Html\execute(), FixDoubleRedirects\execute(), DumpLinks\execute(), DeleteArchivedRevisions\execute(), InitEditCount\execute(), UpdateDoubleWidthSearch\execute(), AlterSharedConstraints\execute(), DeleteArchivedFiles\execute(), FetchText\execute(), RebuildFileCache\execute(), DeleteBatch\execute(), TableCleanup\execute(), RebuildLocalisationCache\execute(), NamespaceConflictChecker\execute(), ConvertLinks\execute(), RebuildTextIndex\execute(), CheckSyntax\execute(), NukeNS\execute(), Lang2Po\execute(), MoveBatch\execute(), WatchlistCleanup\execute(), PHPUnitMaintClass\execute(), FindHooks\execute(), RefreshImageMetadata\execute(), CompressOld\execute(), BackupReader\execute(), UpdateMediaWiki\execute(), SeleniumTester\execute(), LoggedUpdateMaintenance\execute(), ImportSiteScripts\fetchScriptList(), FixSlaveDesync\findPageLatestCorruption(), DeleteArchivedRevisions\handleOutput(), DeleteArchivedFiles\handleOutput(), DumpRenderer\handleRevision(), DumpIterator\handleRevision(), SqliteMaintenance\integrityCheck(), ImageCleanup\killRow(), GenerateSitemap\main(), maybeHelp(), MinifyScript\minify(), TitleCleanup\moveIllegalPage(), TitleCleanup\moveInconsistentPage(), ImageBuilder\oldimageCallback(), UploadDumper\outputItem(), ImageCleanup\pokeFile(), RebuildTextIndex\populateSearchIndex(), 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(), purgeRedundantText(), FixDoubleRedirects\queueJobs(), RebuildRecentchanges\rebuildRecentChangesTablePass1(), RebuildRecentchanges\rebuildRecentChangesTablePass2(), RebuildRecentchanges\rebuildRecentChangesTablePass3(), RebuildRecentchanges\rebuildRecentChangesTablePass4(), WatchlistCleanup\removeWatch(), NamespaceConflictChecker\reportConflict(), NamespaceConflictChecker\resolveConflict(), NamespaceConflictChecker\resolveConflictOn(), RunJobs\runJobsLog(), TableCleanup\runTable(), UpdateSearchIndex\searchIndexUpdateCallback(), PurgeList\sendPurgeRequest(), MwSql\sqlPrintResult(), updateSearchIndex(), updateSearchIndexForPage(), PopulateRevisionSha1\upgradeLegacyArchiveRow(), PopulateRevisionSha1\upgradeRow(), and SqliteMaintenance\vacuum().

Here is the call graph for this function:

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
$channelChannel identifier or null for no channel. Channel comparison uses ===.

Definition at line 372 of file Maintenance.php.

References $cli, cleanupChanneled(), and print.

Referenced by error(), and output().

Here is the call graph for this function:

Here is the caller graph for this function:

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 1178 of file Maintenance.php.

References MWInit\functionExists().

Referenced by ParserTest\__construct(), MwSql\execute(), and readconsole().

Here is the call graph for this function:

Here is the caller graph for this function:

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 951 of file Maintenance.php.

References $count, $res, getDB(), and output().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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 1191 of file Maintenance.php.

References posix_isatty(), and readlineEmulation().

Referenced by MwSql\execute().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Emulate readline()

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

Definition at line 1220 of file Maintenance.php.

References $command, Installer\locateExecutableInDefaultPaths(), print, wfEscapeShellArg(), wfIsWindows(), and wfShellExec().

Referenced by readconsole().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Parameters:
&$dbDatabase object

Definition at line 1104 of file Maintenance.php.

References lockSearchindex(), and unlockSearchindex().

Referenced by updateSearchIndex().

Here is the call graph for this function:

Here is the caller graph for this function:

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 462 of file Maintenance.php.

References $maintClass, MWInit\classExists(), and error().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Maintenance::setDB ( &$  db)

Sets database object to be returned by getDB().

Parameters:
$dbDatabaseBase: Database object to be used

Definition at line 1077 of file Maintenance.php.

Referenced by DatabaseUpdater\__construct().

Here is the caller graph for this function:

Do some sanity checking and basic setup.

Definition at line 487 of file Maintenance.php.

References $wgCommandLineMode, $wgRequestTime, adjustMemoryLimit(), error(), loadParamsAndArgs(), maybeHelp(), and validateParamsAndArgs().

Here is the call graph for this function:

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 136 of file Maintenance.php.

References $count.

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

Unlock the tables.

Parameters:
&$dbDatabase object

Definition at line 1095 of file Maintenance.php.

Referenced by relockSearchindex(), and updateSearchIndex().

Here is the caller graph for this function:

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 1116 of file Maintenance.php.

References lockSearchindex(), output(), relockSearchindex(), and unlockSearchindex().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Maintenance::updateSearchIndexForPage ( dbw,
pageId 
)

Update the searchindex table for a given pageid.

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

Definition at line 1154 of file Maintenance.php.

References $title, SearchUpdate\doUpdate(), Revision\loadFromPageId(), and output().

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

Here is the call graph for this function:

Here is the caller graph for this function:

Run some validation checks on the params, etc.

Reimplemented in CommandLineInstaller.

Definition at line 684 of file Maintenance.php.

References error(), hasArg(), hasOption(), and maybeHelp().

Referenced by setup().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Maintenance::$atLineStart = true [private]

Definition at line 347 of file Maintenance.php.

Maintenance::$lastChannel = null [private]

Definition at line 348 of file Maintenance.php.

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

Definition at line 70 of file Maintenance.php.

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

Definition at line 76 of file Maintenance.php.

Maintenance::$mBatchSize = null [protected]

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 112 of file Maintenance.php.

Referenced by getCoreScripts().

Maintenance::$mDb = null [private]

Definition at line 105 of file Maintenance.php.

Maintenance::$mDbPass

Definition at line 83 of file Maintenance.php.

Maintenance::$mDbUser [protected]

Definition at line 83 of file Maintenance.php.

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

Definition at line 102 of file Maintenance.php.

Maintenance::$mDescription = '' [protected]

Definition at line 86 of file Maintenance.php.

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

Definition at line 100 of file Maintenance.php.

Maintenance::$mInputLoaded = false [protected]

Definition at line 89 of file Maintenance.php.

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

Definition at line 73 of file Maintenance.php.

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

Definition at line 64 of file Maintenance.php.

Maintenance::$mQuiet = false [protected]

Definition at line 82 of file Maintenance.php.

Maintenance::$mSelf [protected]

Reimplemented in FakeMaintenance.

Definition at line 79 of file Maintenance.php.

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

Definition at line 67 of file Maintenance.php.

Definition at line 57 of file Maintenance.php.

Referenced by getDbType().

const Maintenance::STDIN_ALL = 'all'

Definition at line 61 of file Maintenance.php.

Referenced by EditCLI\execute(), and getStdin().


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