*/
public $fileHandle;
- /**
- * List of all the core maintenance scripts. This is added
- * to scripts added by extensions in $wgMaintenanceScripts
- * and returned by getMaintenanceScripts()
- */
- protected static $mCoreScripts = null;
-
/**
* Default constructor. Children should call this *first* if implementing
* their own constructors
* as a standalone class? It checks that the call stack only includes this
* function and "requires" (meaning was called from the file scope)
*
- * @return Boolean
+ * @return bool
*/
public static function shouldExecute() {
$bt = debug_backtrace();
* Add a parameter to the script. Will be displayed on --help
* with the associated description
*
- * @param $name String: the name of the param (help, version, etc)
- * @param $description String: the description of the param to show on --help
- * @param $required Boolean: is the param required?
- * @param $withArg Boolean: is an argument required with this option?
- * @param $shortName String: character to use as short name
+ * @param string $name The name of the param (help, version, etc)
+ * @param string $description The description of the param to show on --help
+ * @param bool $required Is the param required?
+ * @param bool $withArg Is an argument required with this option?
+ * @param string $shortName Character to use as short name
*/
protected function addOption( $name, $description, $required = false, $withArg = false, $shortName = false ) {
$this->mParams[$name] = array( 'desc' => $description, 'require' => $required, 'withArg' => $withArg, 'shortName' => $shortName );
/**
* Checks to see if a particular param exists.
- * @param $name String: the name of the param
- * @return Boolean
+ * @param string $name The name of the param
+ * @return bool
*/
protected function hasOption( $name ) {
return isset( $this->mOptions[$name] );
/**
* Get an option, or return the default
- * @param $name String: the name of the param
- * @param $default Mixed: anything you want, default null
- * @return Mixed
+ * @param string $name The name of the param
+ * @param mixed $default Anything you want, default null
+ * @return mixed
*/
protected function getOption( $name, $default = null ) {
if ( $this->hasOption( $name ) ) {
/**
* Add some args that are needed
- * @param $arg String: name of the arg, like 'start'
- * @param $description String: short description of the arg
- * @param $required Boolean: is this required?
+ * @param string $arg Name of the arg, like 'start'
+ * @param string $description Short description of the arg
+ * @param bool $required Is this required?
*/
protected function addArg( $arg, $description, $required = true ) {
$this->mArgList[] = array(
/**
* Remove an option. Useful for removing options that won't be used in your script.
- * @param $name String: the option to remove.
+ * @param string $name The option to remove.
*/
protected function deleteOption( $name ) {
unset( $this->mParams[$name] );
/**
* Set the description text.
- * @param $text String: the text of the description
+ * @param string $text The text of the description
*/
protected function addDescription( $text ) {
$this->mDescription = $text;
/**
* Does a given argument exist?
- * @param $argId Integer: the integer value (from zero) for the arg
- * @return Boolean
+ * @param int $argId The integer value (from zero) for the arg
+ * @return bool
*/
protected function hasArg( $argId = 0 ) {
return isset( $this->mArgs[$argId] );
/**
* Get an argument.
- * @param $argId Integer: the integer value (from zero) for the arg
- * @param $default Mixed: the default if it doesn't exist
+ * @param int $argId The integer value (from zero) for the arg
+ * @param mixed $default The default if it doesn't exist
* @return mixed
*/
protected function getArg( $argId = 0, $default = null ) {
/**
* Set the batch size.
- * @param $s Integer: the number of operations to do in a batch
+ * @param int $s The number of operations to do in a batch
*/
protected function setBatchSize( $s = 0 ) {
$this->mBatchSize = $s;
/**
* Get the script's name
- * @return String
+ * @return string
*/
public function getName() {
return $this->mSelf;
/**
* Return input from stdin.
- * @param $len Integer: the number of bytes to read. If null,
- * just return the handle. Maintenance::STDIN_ALL returns
- * the full length
- * @return Mixed
+ * @param int $len The number of bytes to read. If null, just return the handle.
+ * Maintenance::STDIN_ALL returns the full length
+ * @return mixed
*/
protected function getStdin( $len = null ) {
if ( $len == Maintenance::STDIN_ALL ) {
/**
* Throw some output to the user. Scripts can call this with no fears,
* as we handle all --quiet stuff here
- * @param $out String: the text to show to the user
- * @param $channel Mixed: unique identifier for the channel. See
- * function outputChanneled.
+ * @param string $out The text to show to the user
+ * @param mixed $channel Unique identifier for the channel. See function outputChanneled.
*/
protected function output( $out, $channel = null ) {
if ( $this->mQuiet ) {
/**
* Throw an error to the user. Doesn't respect --quiet, so don't use
* this for non-error output
- * @param $err String: the error to display
- * @param $die Int: if > 0, go ahead and die out using this int as the code
+ * @param string $err The error to display
+ * @param int $die If > 0, go ahead and die out using this int as the code
*/
protected function error( $err, $die = 0 ) {
$this->outputChanneled( false );
* Message outputter with channeled message support. Messages on the
* same channel are concatenated, but any intervening messages in another
* channel start a new line.
- * @param $msg String: the message without trailing newline
- * @param $channel string Channel identifier or null for no
+ * @param string $msg The message without trailing newline
+ * @param string $channel Channel identifier or null for no
* channel. Channel comparison uses ===.
*/
public function outputChanneled( $msg, $channel = null ) {
* Maintenance::DB_NONE - For no DB access at all
* Maintenance::DB_STD - For normal DB access, default
* Maintenance::DB_ADMIN - For admin DB access
- * @return Integer
+ * @return int
*/
public function getDbType() {
return Maintenance::DB_STD;
/**
* Run a child maintenance script. Pass all of the current arguments
* to it.
- * @param $maintClass String: a name of a child maintenance class
- * @param $classFile String: full path of where the child is
- * @return Maintenance child
+ * @param string $maintClass A name of a child maintenance class
+ * @param string $classFile Full path of where the child is
+ * @return Maintenance
*/
public function runChild( $maintClass, $classFile = null ) {
// Make sure the class is loaded first
* $mOptions becomes an array with keys set to the option names
* $mArgs becomes a zero-based array containing the non-option arguments
*
- * @param $self String The name of the script, if any
- * @param $opts Array An array of options, in form of key=>value
- * @param $args Array An array of command line arguments
+ * @param string $self The name of the script, if any
+ * @param array $opts An array of options, in form of key=>value
+ * @param array $args An array of command line arguments
*/
public function loadParamsAndArgs( $self = null, $opts = null, $args = null ) {
# If we were given opts or args, set those and return early
/**
* Maybe show the help.
- * @param $force boolean Whether to force the help to show, default false
+ * @param bool $force Whether to force the help to show, default false
*/
protected function maybeHelp( $force = false ) {
if ( !$force && !$this->hasOption( 'help' ) ) {
/**
* Generic setup for most installs. Returns the location of LocalSettings
- * @return String
+ * @return string
*/
public function loadSettings() {
global $wgCommandLineMode, $IP;
/**
* Support function for cleaning up redundant text records
- * @param $delete Boolean: whether or not to actually delete the records
+ * @param bool $delete Whether or not to actually delete the records
* @author Rob Church <robchur@gmail.com>
*/
public function purgeRedundantText( $delete = true ) {
return __DIR__;
}
- /**
- * 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
- * @return Array
- */
- public static function getMaintenanceScripts() {
- global $wgMaintenanceScripts;
- return $wgMaintenanceScripts + self::getCoreScripts();
- }
-
- /**
- * Return all of the core maintenance scripts
- * @return array
- */
- protected static function getCoreScripts() {
- if ( !self::$mCoreScripts ) {
- $paths = array(
- __DIR__,
- __DIR__ . '/language',
- __DIR__ . '/storage',
- );
- self::$mCoreScripts = array();
- foreach ( $paths as $p ) {
- $handle = opendir( $p );
- while ( ( $file = readdir( $handle ) ) !== false ) {
- if ( $file == 'Maintenance.php' ) {
- continue;
- }
- $file = $p . '/' . $file;
- if ( is_dir( $file ) || !strpos( $file, '.php' ) ||
- ( strpos( file_get_contents( $file ), '$maintClass' ) === false ) ) {
- continue;
- }
- require $file;
- $vars = get_defined_vars();
- if ( array_key_exists( 'maintClass', $vars ) ) {
- self::$mCoreScripts[$vars['maintClass']] = $file;
- }
- }
- closedir( $handle );
- }
- }
- return self::$mCoreScripts;
- }
-
/**
* Returns a database to be used by current maintenance script. It can be set by setDB().
* If not set, wfGetDB() will be used.
/**
* Sets database object to be returned by getDB().
*
- * @param $db DatabaseBase: Database object to be used
+ * @param DatabaseBase $db Database object to be used
*/
public function setDB( &$db ) {
$this->mDb = $db;
/**
* Lock the search index
- * @param &$db DatabaseBase object
+ * @param DatabaseBase &$db
*/
private function lockSearchindex( &$db ) {
$write = array( 'searchindex' );
/**
* Unlock the tables
- * @param &$db DatabaseBase object
+ * @param DatabaseBase &$db
*/
private function unlockSearchindex( &$db ) {
$db->unlockTables( __CLASS__ . '::' . __METHOD__ );
/**
* Unlock and lock again
* Since the lock is low-priority, queued reads will be able to complete
- * @param &$db DatabaseBase object
+ * @param DatabaseBase &$db
*/
private function relockSearchindex( &$db ) {
$this->unlockSearchindex( $db );
/**
* Perform a search index update with locking
- * @param $maxLockTime Integer: the maximum time to keep the search index locked.
- * @param $callback callback String: the function that will update the function.
- * @param $dbw DatabaseBase object
- * @param $results
+ * @param int $maxLockTime The maximum time to keep the search index locked.
+ * @param string $callback The function that will update the function.
+ * @param DatabaseBase $dbw
+ * @param array $results
*/
public function updateSearchIndex( $maxLockTime, $callback, $dbw, $results ) {
$lockTime = time();
/**
* Update the searchindex table for a given pageid
- * @param $dbw DatabaseBase a database write handle
- * @param $pageId Integer: the page ID to update.
+ * @param DatabaseBase $dbw A database write handle
+ * @param int $pageId The page ID to update.
* @return null|string
*/
public function updateSearchIndexForPage( $dbw, $pageId ) {
* We default as considering stdin a tty (for nice readline methods)
* but treating stout as not a tty to avoid color codes
*
- * @param $fd int File descriptor
+ * @param int $fd File descriptor
* @return bool
*/
public static function posix_isatty( $fd ) {
/**
* Prompt the console for input
- * @param $prompt String what to begin the line with, like '> '
- * @return String response
+ * @param string $prompt What to begin the line with, like '> '
+ * @return string Response
*/
public static function readconsole( $prompt = '> ' ) {
static $isatty = null;
/**
* Emulate readline()
- * @param $prompt String what to begin the line with, like '> '
- * @return String
+ * @param string $prompt What to begin the line with, like '> '
+ * @return string
*/
private static function readlineEmulation( $prompt ) {
$bash = Installer::locateExecutableInDefaultPaths( array( 'bash' ) );
/**
* Message to show that the update was done already and was just skipped
- * @return String
+ * @return string
*/
protected function updateSkippedMessage() {
$key = $this->getUpdateKey();
/**
* Message to show the the update log was unable to log the completion of this update
- * @return String
+ * @return string
*/
protected function updatelogFailedMessage() {
$key = $this->getUpdateKey();
/**
* Do the actual work. All child classes will need to implement this.
* Return true to log the update as done or false (usually on failure).
- * @return Bool
+ * @return bool
*/
abstract protected function doDBUpdates();
/**
* Get the update key name to go in the update log table
- * @return String
+ * @return string
*/
abstract protected function getUpdateKey();
}