Go to the documentation of this file.
25 require_once __DIR__ .
'/Maintenance.php';
34 parent::__construct();
35 $this->mDescription =
"Send SQL queries to a MediaWiki database";
36 $this->
addOption(
'cluster',
'Use an external cluster by name',
false,
true );
37 $this->
addOption(
'wikidb',
'The database wiki ID to use if not the current one',
false,
true );
38 $this->
addOption(
'slave',
'Use a slave server (either "any" or by name)',
false,
true );
42 $wiki = $this->
getOption(
'wikidb' ) ?:
false;
52 if ( $server ===
'any' ) {
56 for ( $i = 0; $i <
$lb->getServerCount(); ++$i ) {
57 if (
$lb->getServerName( $i ) === $server ) {
62 if ( $index ===
null ) {
63 $this->
error(
"No slave server configured with the name '$server'.", 1 );
70 $db =
$lb->getConnection( $index,
array(), $wiki );
71 if ( $this->
hasOption(
'slave' ) && $db->getLBInfo(
'master' ) !== null ) {
72 $this->
error(
"The server selected ({$db->getServer()}) is not a slave.", 1 );
75 if ( $this->
hasArg( 0 ) ) {
78 $this->
error(
"Unable to open input file",
true );
81 $error = $db->sourceStream(
$file,
false,
array( $this,
'sqlPrintResult' ) );
94 $historyFile = isset( $_ENV[
'HOME'] ) ?
95 "{$_ENV['HOME']}/.mwsql_history" :
"$IP/maintenance/.mwsql_history";
96 readline_read_history( $historyFile );
101 $prompt = $newPrompt;
104 # User simply pressed return key
107 $done = $db->streamStatementEnd( $wholeLine,
$line );
117 # Delimiter is eated by streamStatementEnd, we add it
118 # up in the history (bug 37020)
119 readline_add_history( $wholeLine . $db->getDelimiter() );
120 readline_write_history( $historyFile );
123 $res = $db->query( $wholeLine );
125 $prompt = $newPrompt;
129 $this->
error( $e, $doDie );
144 } elseif ( is_object(
$res ) &&
$res->numRows() ) {
145 foreach (
$res as $row ) {
146 $this->
output( print_r( $row,
true ) );
149 $affected = $db->affectedRows();
150 $this->
output(
"Query OK, $affected row(s) affected\n" );
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
__construct()
Default constructor.
sqlPrintResult( $res, $db)
Print the results, callback for $db->sourceStream()
wfGetLB( $wiki=false)
Get a load balancer object.
static readconsole( $prompt='> ')
Prompt the console for input.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
require_once RUN_MAINTENANCE_IF_MAIN
hasArg( $argId=0)
Does a given argument exist?
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
if( $wgAPIRequestLog) $lb
execute()
Do the actual work.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
Maintenance script that sends SQL queries from the specified file to the database.
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
static posix_isatty( $fd)
Wrapper for posix_isatty() We default as considering stdin a tty (for nice readline methods) but trea...
if(PHP_SAPI !='cli') $file
getOption( $name, $default=null)
Get an option, or return the default.
& wfGetLBFactory()
Get the load balancer factory object.
if(isset( $options['d'])) $useReadline
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
error( $err, $die=0)
Throw an error to the user.
output( $out, $channel=null)
Throw some output to the user.
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string as detected by MediaWiki Handlers will typically only apply for specific mime types object & $error
hasOption( $name)
Checks to see if a particular param exists.
getArg( $argId=0, $default=null)
Get an argument.