25require_once __DIR__ .
'/../includes/PHPVersionCheck.php';
36define(
'RUN_MAINTENANCE_IF_MAIN', __DIR__ .
'/doMaintenance.php' );
158 $IP = strval( getenv(
'MW_INSTALL_PATH' ) ) !==
''
159 ? getenv(
'MW_INSTALL_PATH' )
160 : realpath( __DIR__ .
'/..' );
163 register_shutdown_function( [ $this,
'outputChanneled' ],
false );
176 if ( !function_exists(
'debug_backtrace' ) ) {
181 $bt = debug_backtrace();
182 $count = count( $bt );
186 if ( $bt[0][
'class'] !==
'Maintenance' || $bt[0][
'function'] !==
'shouldExecute' ) {
189 $includeFuncs = [
'require_once',
'require',
'include',
'include_once' ];
190 for ( $i = 1; $i < $count; $i++ ) {
191 if ( !in_array( $bt[$i][
'function'], $includeFuncs ) ) {
215 protected function addOption( $name, $description, $required =
false,
216 $withArg =
false, $shortName =
false, $multiOccurrence =
false
218 $this->mParams[
$name] = [
219 'desc' => $description,
220 'require' => $required,
221 'withArg' => $withArg,
222 'shortName' => $shortName,
223 'multiOccurrence' => $multiOccurrence
226 if ( $shortName !==
false ) {
227 $this->mShortParamsMap[$shortName] =
$name;
237 return isset( $this->mOptions[$name] );
250 protected function getOption( $name, $default =
null ) {
252 return $this->mOptions[
$name];
255 $this->mOptions[
$name] = $default;
257 return $this->mOptions[
$name];
267 protected function addArg( $arg, $description, $required =
true ) {
268 $this->mArgList[] = [
270 'desc' => $description,
271 'require' => $required
280 unset( $this->mParams[$name] );
288 $this->mDescription = $text;
296 protected function hasArg( $argId = 0 ) {
297 return isset( $this->mArgs[$argId] );
306 protected function getArg( $argId = 0, $default =
null ) {
307 return $this->
hasArg( $argId ) ? $this->mArgs[$argId] : $default;
315 $this->mBatchSize =
$s;
322 if ( $this->mBatchSize ) {
323 $this->
addOption(
'batch-size',
'Run this many operations ' .
324 'per batch, default: ' . $this->mBatchSize,
false,
true );
325 if ( isset( $this->mParams[
'batch-size'] ) ) {
327 $this->mDependantParameters[
'batch-size'] = $this->mParams[
'batch-size'];
347 if ( $len == self::STDIN_ALL ) {
348 return file_get_contents(
'php://stdin' );
350 $f = fopen(
'php://stdin',
'rt' );
354 $input = fgets( $f, $len );
374 if ( $this->mQuiet ) {
377 if ( $channel ===
null ) {
381 $out = preg_replace(
'/\n\z/',
'',
$out );
392 protected function error( $err, $die = 0 ) {
394 if ( PHP_SAPI ==
'cli' ) {
395 fwrite( STDERR, $err .
"\n" );
399 $die = intval( $die );
412 if ( !$this->atLineStart ) {
414 $this->atLineStart =
true;
427 if ( $msg ===
false ) {
434 if ( !$this->atLineStart && $channel !== $this->lastChannel ) {
440 $this->atLineStart =
false;
441 if ( $channel ===
null ) {
444 $this->atLineStart =
true;
446 $this->lastChannel = $channel;
467 # Generic (non script dependant) options:
469 $this->
addOption(
'help',
'Display this help message',
false,
false,
'h' );
470 $this->
addOption(
'quiet',
'Whether to supress non-error output',
false,
false,
'q' );
471 $this->
addOption(
'conf',
'Location of LocalSettings.php, if not default',
false,
true );
472 $this->
addOption(
'wiki',
'For specifying the wiki ID',
false,
true );
473 $this->
addOption(
'globals',
'Output globals at the end of processing for debugging' );
476 'Set a specific memory limit for the script, '
477 .
'"max" for no limit or "default" to avoid changing it'
479 $this->
addOption(
'server',
"The protocol and server name to use in URLs, e.g. " .
480 "http://en.wikipedia.org. This is sometimes necessary because " .
481 "server name detection may fail in command line scripts.",
false,
true );
482 $this->
addOption(
'profiler',
'Profiler output format (usually "text")',
false,
true );
484 # Save generic options to display them separately in help
487 # Script dependant options:
491 $this->
addOption(
'dbuser',
'The DB user to use for this script',
false,
true );
492 $this->
addOption(
'dbpass',
'The password to use for this script',
false,
true );
495 # Save additional script dependant options to display
496 # them separately in help
497 $this->mDependantParameters = array_diff_key( $this->mParams, $this->mGenericParameters );
505 if ( $this->config ===
null ) {
506 $this->config = MediaWikiServices::getInstance()->getMainConfig();
530 $this->requiredExtensions[] =
$name;
541 foreach ( $this->requiredExtensions as $name ) {
542 if ( !$registry->isLoaded( $name ) ) {
548 $joined = implode(
', ', $missing );
549 $msg =
"The following extensions are required to be installed "
550 .
"for this script to run: $joined. Please enable them and then try again.";
551 $this->
error( $msg, 1 );
560 if ( function_exists(
'posix_getpwuid' ) ) {
561 $agent = posix_getpwuid( posix_geteuid() )[
'name'];
567 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
569 $lbFactory->setAgentName(
570 mb_strlen( $agent ) > 15 ? mb_substr( $agent, 0, 15 ) .
'...' : $agent
581 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
582 $lbFactory->setWaitForReplicationListener(
588 DeferredUpdates::tryOpportunisticExecute(
'run' );
594 $lbFactory->getMainLB()->setTransactionListener(
596 function ( $trigger ) {
600 DeferredUpdates::tryOpportunisticExecute(
'run' );
617 require_once $classFile;
620 $this->
error(
"Cannot spawn child: $maintClass" );
628 $child->loadParamsAndArgs( $this->mSelf, $this->mOptions, $this->mArgs );
629 if ( !is_null( $this->mDb ) ) {
630 $child->setDB( $this->mDb );
642 # Abort if called from a web server
643 if ( isset( $_SERVER ) && isset( $_SERVER[
'REQUEST_METHOD'] ) ) {
644 $this->
error(
'This script must be run from the command line',
true );
647 if ( $IP ===
null ) {
648 $this->
error(
"\$IP not set, aborting!\n" .
649 '(Did you forget to call parent::__construct() in your maintenance script?)', 1 );
652 # Make sure we can handle script parameters
653 if ( !defined(
'HPHP_VERSION' ) && !ini_get(
'register_argc_argv' ) ) {
654 $this->
error(
'Cannot get command line arguments, register_argc_argv is set to false',
true );
660 if ( ini_get(
'display_errors' ) ) {
661 ini_set(
'display_errors',
'stderr' );
667 # Set the memory limit
668 # Note we need to set it again later in cache LocalSettings changed it
671 # Set max execution time to 0 (no limit). PHP.net says that
672 # "When running PHP from the command line the default setting is 0."
673 # But sometimes this doesn't seem to be the case.
674 ini_set(
'max_execution_time', 0 );
678 # Define us as being in MediaWiki
679 define(
'MEDIAWIKI',
true );
683 # Turn off output buffering if it's on
684 while ( ob_get_level() > 0 ) {
701 $limit = $this->
getOption(
'memory-limit',
'max' );
702 $limit = trim( $limit,
"\" '" );
711 if ( $limit ==
'max' ) {
714 if ( $limit !=
'default' ) {
715 ini_set(
'memory_limit', $limit );
733 $profiler =
new $class(
734 [
'sampling' => 1,
'output' => [
$output ] ]
738 $profiler->setTemplated(
true );
739 Profiler::replaceStubInstance( $profiler );
742 $trxProfiler = Profiler::instance()->getTransactionProfiler();
743 $trxProfiler->setLogger( LoggerFactory::getInstance(
'DBPerformance' ) );
751 $this->mOptions = [];
753 $this->mInputLoaded =
false;
766 $this->orderedOptions = [];
769 for ( $arg = reset(
$argv ); $arg !==
false; $arg = next(
$argv ) ) {
770 if ( $arg ==
'--' ) {
771 # End of options, remainder should be considered arguments
772 $arg = next(
$argv );
773 while ( $arg !==
false ) {
775 $arg = next(
$argv );
778 } elseif ( substr( $arg, 0, 2 ) ==
'--' ) {
780 $option = substr( $arg, 2 );
781 if ( isset( $this->mParams[$option] ) && $this->mParams[$option][
'withArg'] ) {
782 $param = next(
$argv );
783 if ( $param ===
false ) {
784 $this->
error(
"\nERROR: $option parameter needs a value after it\n" );
790 $bits = explode(
'=', $option, 2 );
791 if ( count( $bits ) > 1 ) {
800 } elseif ( $arg ==
'-' ) {
801 # Lonely "-", often used to indicate stdin or stdout.
803 } elseif ( substr( $arg, 0, 1 ) ==
'-' ) {
805 $argLength = strlen( $arg );
806 for ( $p = 1; $p < $argLength; $p++ ) {
808 if ( !isset( $this->mParams[$option] ) && isset( $this->mShortParamsMap[$option] ) ) {
809 $option = $this->mShortParamsMap[$option];
812 if ( isset( $this->mParams[$option][
'withArg'] ) && $this->mParams[$option][
'withArg'] ) {
813 $param = next(
$argv );
814 if ( $param ===
false ) {
815 $this->
error(
"\nERROR: $option parameter needs a value after it\n" );
829 $this->mArgs =
$args;
831 $this->mInputLoaded =
true;
847 $this->orderedOptions[] = [ $option,
$value ];
849 if ( isset( $this->mParams[$option] ) ) {
850 $multi = $this->mParams[$option][
'multiOccurrence'];
854 $exists = array_key_exists( $option,
$options );
855 if ( $multi && $exists ) {
857 } elseif ( $multi ) {
859 } elseif ( !$exists ) {
862 $this->
error(
"\nERROR: $option parameter given twice\n" );
877 # If we were given opts or args, set those and return early
879 $this->mSelf =
$self;
880 $this->mInputLoaded =
true;
883 $this->mOptions = $opts;
884 $this->mInputLoaded =
true;
887 $this->mArgs =
$args;
888 $this->mInputLoaded =
true;
891 # If we've already loaded input (either by user values or from $argv)
892 # skip on loading it again. The array_shift() will corrupt values if
893 # it's run again and again
894 if ( $this->mInputLoaded ) {
901 $this->mSelf =
$argv[0];
910 # Check to make sure we've got all the required options
911 foreach ( $this->mParams as
$opt => $info ) {
913 $this->
error(
"Param $opt required!" );
918 foreach ( $this->mArgList as $k => $info ) {
919 if ( $info[
'require'] && !$this->
hasArg( $k ) ) {
920 $this->
error(
'Argument <' . $info[
'name'] .
'> required!' );
935 $this->mDbUser = $this->
getOption(
'dbuser' );
938 $this->mDbPass = $this->
getOption(
'dbpass' );
941 $this->mQuiet =
true;
943 if ( $this->
hasOption(
'batch-size' ) ) {
944 $this->mBatchSize = intval( $this->
getOption(
'batch-size' ) );
953 if ( !$force && !$this->
hasOption(
'help' ) ) {
959 $descWidth = $screenWidth - ( 2 * strlen( $tab ) );
961 ksort( $this->mParams );
962 $this->mQuiet =
false;
965 if ( $this->mDescription ) {
966 $this->
output(
"\n" . wordwrap( $this->mDescription, $screenWidth ) .
"\n" );
968 $output =
"\nUsage: php " . basename( $this->mSelf );
971 if ( $this->mParams ) {
972 $output .=
" [--" . implode( array_keys( $this->mParams ),
"|--" ) .
"]";
976 if ( $this->mArgList ) {
978 foreach ( $this->mArgList as $k => $arg ) {
979 if ( $arg[
'require'] ) {
980 $output .=
'<' . $arg[
'name'] .
'>';
982 $output .=
'[' . $arg[
'name'] .
']';
984 if ( $k < count( $this->mArgList ) - 1 ) {
989 $this->
output(
"$output\n\n" );
991 # TODO abstract some repetitive code below
994 $this->
output(
"Generic maintenance parameters:\n" );
995 foreach ( $this->mGenericParameters as $par => $info ) {
996 if ( $info[
'shortName'] !==
false ) {
997 $par .=
" (-{$info['shortName']})";
1000 wordwrap(
"$tab--$par: " . $info[
'desc'], $descWidth,
1001 "\n$tab$tab" ) .
"\n"
1007 if ( count( $scriptDependantParams ) > 0 ) {
1008 $this->
output(
"Script dependant parameters:\n" );
1010 foreach ( $scriptDependantParams as $par => $info ) {
1011 if ( $info[
'shortName'] !==
false ) {
1012 $par .=
" (-{$info['shortName']})";
1015 wordwrap(
"$tab--$par: " . $info[
'desc'], $descWidth,
1016 "\n$tab$tab" ) .
"\n"
1024 $scriptSpecificParams = array_diff_key(
1025 # all script parameters:
1027 # remove the Maintenance default parameters:
1031 if ( count( $scriptSpecificParams ) > 0 ) {
1032 $this->
output(
"Script specific parameters:\n" );
1034 foreach ( $scriptSpecificParams as $par => $info ) {
1035 if ( $info[
'shortName'] !==
false ) {
1036 $par .=
" (-{$info['shortName']})";
1039 wordwrap(
"$tab--$par: " . $info[
'desc'], $descWidth,
1040 "\n$tab$tab" ) .
"\n"
1047 if ( count( $this->mArgList ) > 0 ) {
1048 $this->
output(
"Arguments:\n" );
1050 foreach ( $this->mArgList as $info ) {
1051 $openChar = $info[
'require'] ?
'<' :
'[';
1052 $closeChar = $info[
'require'] ?
'>' :
']';
1054 wordwrap(
"$tab$openChar" . $info[
'name'] .
"$closeChar: " .
1055 $info[
'desc'], $descWidth,
"\n$tab$tab" ) .
"\n"
1072 # Turn off output buffering again, it might have been turned on in the settings files
1073 if ( ob_get_level() ) {
1079 # Override $wgServer
1081 $wgServer = $this->
getOption(
'server', $wgServer );
1084 # If these were passed, use them
1085 if ( $this->mDbUser ) {
1088 if ( $this->mDbPass ) {
1109 MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->destroy();
1117 $wgShowSQLErrors =
true;
1119 MediaWiki\suppressWarnings();
1120 set_time_limit( 0 );
1121 MediaWiki\restoreWarnings();
1130 if ( defined(
'MW_CMDLINE_CALLBACK' ) ) {
1131 call_user_func( MW_CMDLINE_CALLBACK );
1152 if ( isset( $this->mOptions[
'conf'] ) ) {
1153 $settingsFile = $this->mOptions[
'conf'];
1154 } elseif ( defined(
"MW_CONFIG_FILE" ) ) {
1155 $settingsFile = MW_CONFIG_FILE;
1157 $settingsFile =
"$IP/LocalSettings.php";
1159 if ( isset( $this->mOptions[
'wiki'] ) ) {
1160 $bits = explode(
'-', $this->mOptions[
'wiki'] );
1161 if ( count( $bits ) == 1 ) {
1164 define(
'MW_DB', $bits[0] );
1165 define(
'MW_PREFIX', $bits[1] );
1168 if ( !is_readable( $settingsFile ) ) {
1169 $this->
error(
"A copy of your installation's LocalSettings.php\n" .
1170 "must exist and be readable in the source directory.\n" .
1171 "Use --conf to specify it.",
true );
1173 $wgCommandLineMode =
true;
1175 return $settingsFile;
1184 # Data should come off the master, wrapped in a transaction
1188 # Get "active" text records from the revisions table
1190 $this->
output(
'Searching for active text records in revisions table...' );
1191 $res = $dbw->select(
'revision',
'rev_text_id', [], __METHOD__, [
'DISTINCT' ] );
1192 foreach (
$res as $row ) {
1193 $cur[] = $row->rev_text_id;
1195 $this->
output(
"done.\n" );
1197 # Get "active" text records from the archive table
1198 $this->
output(
'Searching for active text records in archive table...' );
1199 $res = $dbw->select(
'archive',
'ar_text_id', [], __METHOD__, [
'DISTINCT' ] );
1200 foreach (
$res as $row ) {
1201 # old pre-MW 1.5 records can have null ar_text_id's.
1202 if ( $row->ar_text_id !==
null ) {
1203 $cur[] = $row->ar_text_id;
1206 $this->
output(
"done.\n" );
1208 # Get the IDs of all text records not in these sets
1209 $this->
output(
'Searching for inactive text records...' );
1210 $cond =
'old_id NOT IN ( ' . $dbw->makeList( $cur ) .
' )';
1211 $res = $dbw->select(
'text',
'old_id', [ $cond ], __METHOD__, [
'DISTINCT' ] );
1213 foreach (
$res as $row ) {
1214 $old[] = $row->old_id;
1216 $this->
output(
"done.\n" );
1218 # Inform the user of what we're going to do
1219 $count = count( $old );
1220 $this->
output(
"$count inactive items found.\n" );
1222 # Delete as appropriate
1223 if ( $delete && $count ) {
1224 $this->
output(
'Deleting...' );
1225 $dbw->delete(
'text', [
'old_id' => $old ], __METHOD__ );
1226 $this->
output(
"done.\n" );
1251 protected function getDB( $db, $groups = [], $wiki =
false ) {
1252 if ( is_null( $this->mDb ) ) {
1253 return wfGetDB( $db, $groups, $wiki );
1296 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
1297 $lbFactory->waitForReplication(
1298 [
'timeout' => 30,
'ifWritesSince' => $this->lastReplicationWait ]
1300 $this->lastReplicationWait = microtime(
true );
1327 $write = [
'searchindex' ];
1337 $db->lockTables( $read, $write, __CLASS__ .
'::' . __METHOD__ );
1345 $db->unlockTables( __CLASS__ .
'::' . __METHOD__ );
1369 if ( $maxLockTime ) {
1370 $this->
output(
" --- Waiting for lock ---" );
1376 # Loop through the results and do a search update
1377 foreach ( $results as $row ) {
1378 # Allow reads to be processed
1379 if ( $maxLockTime && time() > $lockTime + $maxLockTime ) {
1380 $this->
output(
" --- Relocking ---" );
1385 call_user_func( $callback, $dbw, $row );
1388 # Unlock searchindex
1389 if ( $maxLockTime ) {
1390 $this->
output(
" --- Unlocking --" );
1407 $titleObj =
$rev->getTitle();
1408 $title = $titleObj->getPrefixedDBkey();
1409 $this->
output(
"$title..." );
1410 # Update searchindex
1411 $u =
new SearchUpdate( $pageId, $titleObj->getText(),
$rev->getContent() );
1428 if ( !function_exists(
'posix_isatty' ) ) {
1441 static $isatty =
null;
1442 if ( is_null( $isatty ) ) {
1446 if ( $isatty && function_exists(
'readline' ) ) {
1447 $resp = readline( $prompt );
1448 if ( $resp ===
null ) {
1458 if ( feof( STDIN ) ) {
1461 $st = fgets( STDIN, 1024 );
1464 if ( $st ===
false ) {
1467 $resp = trim( $st );
1483 $command =
"read -er -p $encPrompt && echo \"\$REPLY\"";
1500 if ( feof( STDIN ) ) {
1505 return fgets( STDIN, 1024 );
1516 $default = [ 80, 50 ];
1532 if ( !preg_match(
'/^(\d+) (\d+)$/', $size, $m ) ) {
1535 return [ intval( $m[2] ), intval( $m[1] ) ];
1543 require_once __DIR__ .
'/../tests/common/TestsAutoLoader.php';
1564 parent::__construct();
1565 $this->
addOption(
'force',
'Run the update even if it was completed already' );
1574 && $db->selectRow(
'updatelog',
'1', [
'ul_key' => $key ], __METHOD__ )
1585 if ( $db->insert(
'updatelog', [
'ul_key' => $key ], __METHOD__,
'IGNORE' ) ) {
1601 return "Update '{$key}' already logged as completed.";
1611 return "Unable to log update '{$key}' as completed.";
$GLOBALS['wgAutoloadClasses']['LocalisationUpdate']
$wgDBuser
Database username.
$wgDBadminuser
Separate username for maintenance tasks.
$wgTrxProfilerLimits
Performance expectations for DB usage.
$wgDBservers
Database load balancer This is a two-dimensional array, an array of server info structures Fields are...
$wgProfileLimit
Only record profiling info for pages that took longer than this.
$wgDBadminpassword
Separate password for maintenance tasks.
$wgServer
URL of the server.
$wgLBFactoryConf
Load balancer factory configuration To set up a multi-master wiki farm, set the class here to somethi...
$wgDBpassword
Database user's password.
$wgShowSQLErrors
Whether to show "we're sorry, but there has been a database error" pages.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfShellExec( $cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
wfHostname()
Fetch server name for use in error reporting etc.
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
wfIsWindows()
Check if the operating system is Windows.
const RUN_MAINTENANCE_IF_MAIN
wfEntryPointCheck( $entryPoint)
Check php version and that external dependencies are installed, and display an informative error if e...
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
global $wgCommandLineMode
float $wgRequestTime
Request start time as fractional seconds since epoch.
Fake maintenance wrapper, mostly used for the web installer/updater.
execute()
Do the actual work.
static locateExecutableInDefaultPaths( $names, $versionInfo=false)
Same as locateExecutable(), but checks in getPossibleBinPaths() by default.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
__construct()
Default constructor.
doDBUpdates()
Do the actual work.
updatelogFailedMessage()
Message to show that the update log was unable to log the completion of this update.
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
getUpdateKey()
Get the update key name to go in the update log table.
execute()
Do the actual work.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
setup()
Do some sanity checking and basic setup.
__construct()
Default constructor.
error( $err, $die=0)
Throw an error to the user.
getName()
Get the script's name.
addArg( $arg, $description, $required=true)
Add some args that are needed.
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
relockSearchindex( $db)
Unlock and lock again Since the lock is low-priority, queued reads will be able to complete.
int $mBatchSize
Batch size.
setAgentAndTriggers()
Set triggers like when to try to run deferred updates.
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
static getTermSize()
Get the terminal size as a two-element array where the first element is the width (number of columns)...
clearParamsAndArgs()
Clear all params and arguments.
array $requiredExtensions
setParam(&$options, $option, $value)
Helper function used solely by loadParamsAndArgs to prevent code duplication.
const DB_NONE
Constants for DB access type.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
output( $out, $channel=null)
Throw some output to the user.
getStdin( $len=null)
Return input from stdin.
cleanupChanneled()
Clean up channeled output.
memoryLimit()
Normally we disable the memory_limit when running admin scripts.
afterFinalSetup()
Execute a callback function at the end of initialisation.
hasArg( $argId=0)
Does a given argument exist?
getDir()
Get the maintenance directory.
addDefaultParams()
Add the default parameters to the scripts.
deleteOption( $name)
Remove an option.
static readlineEmulation( $prompt)
Emulate readline()
static requireTestsAutoloader()
Call this to set up the autoloader to allow classes to be used from the tests directory.
loadParamsAndArgs( $self=null, $opts=null, $args=null)
Process command line arguments $mOptions becomes an array with keys set to the option names $mArgs be...
outputChanneled( $msg, $channel=null)
Message outputter with channeled message support.
finalSetup()
Handle some last-minute setup here.
loadSpecialVars()
Handle the special variables that are global to all scripts.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
float $lastReplicationWait
UNIX timestamp.
array $orderedOptions
Used to read the options in the order they were passed.
loadSettings()
Generic setup for most installs.
setDB(IDatabase $db)
Sets database object to be returned by getDB().
hasOption( $name)
Checks to see if a particular param exists.
purgeRedundantText( $delete=true)
Support function for cleaning up redundant text records.
runChild( $maintClass, $classFile=null)
Run a child maintenance script.
IMaintainableDatabase $mDb
Used by getDB() / setDB()
execute()
Do the actual work.
static readconsole( $prompt='> ')
Prompt the console for input.
static posix_isatty( $fd)
Wrapper for posix_isatty() We default as considering stdin a tty (for nice readline methods) but trea...
adjustMemoryLimit()
Adjusts PHP's memory limit to better suit our needs, if needed.
validateParamsAndArgs()
Run some validation checks on the params, etc.
getDbType()
Does the script need different DB access? By default, we give Maintenance scripts normal rights to th...
unlockSearchindex( $db)
Unlock the tables.
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
activateProfiler()
Activate the profiler (assuming $wgProfiler is set)
maybeHelp( $force=false)
Maybe show the help.
updateSearchIndexForPage( $dbw, $pageId)
Update the searchindex table for a given pageid.
resource $fileHandle
Used when creating separate schema files.
loadWithArgv( $argv)
Load params and arguments from a given array of command-line arguments.
static setLBFactoryTriggers(LBFactory $LBFactory)
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
static shouldExecute()
Should we execute the maintenance script, or just allow it to be included as a standalone class?...
getOption( $name, $default=null)
Get an option, or return the default.
Config $config
Accessible via getConfig()
lockSearchindex( $db)
Lock the search index.
checkRequiredExtensions()
Verify that the required extensions are installed.
rollbackTransaction(IDatabase $dbw, $fname)
Rollback the transcation on a DB handle.
updateSearchIndex( $maxLockTime, $callback, $dbw, $results)
Perform a search index update with locking.
globals()
Potentially debug globals.
setConfig(Config $config)
setBatchSize( $s=0)
Set the batch size.
static loadFromPageId( $db, $pageid, $id=0)
Load either the current, or a specified, revision that's attached to a given page.
Database independant search index updater.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account incomplete not yet checked for validity & $retval
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Allows to change the fields on the form that will be generated $name
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
returning false will NOT prevent logging $e
Advanced database interface for IDatabase handles that include maintenance methods.
if(is_array($mode)) switch( $mode) $input