Go to the documentation of this file.
24 require_once __DIR__ .
'/Maintenance.php';
33 parent::__construct();
34 $this->mDescription =
"Populate the img_sha1 field";
35 $this->
addOption(
'force',
"Recalculate sha1 for rows that already have a value" );
36 $this->
addOption(
'method',
"Use 'pipe' to pipe to mysql command line,\n" .
37 "\t\tdefault uses Database class",
false,
true );
38 $this->
addOption(
'file',
'Fix for a specific file, without File: namespace prefixed',
false,
true );
42 return 'populate img_sha1';
46 return 'img_sha1 column of image table already populated.';
58 $method = $this->
getOption(
'method',
'normal' );
61 $isRegen = ( $force ||
$file !=
'' );
63 $t = -microtime(
true );
73 $this->
error(
"No such file: $file",
true );
76 $this->
output(
"Populating img_sha1 field for specified files\n" );
80 $this->
output(
"Populating and recalculating img_sha1 field\n" );
82 $conds =
array(
'img_sha1' =>
'' );
83 $this->
output(
"Populating img_sha1 field\n" );
85 $res = $dbw->select(
'image',
array(
'img_name' ), $conds, __METHOD__ );
88 $imageTable = $dbw->tableName(
'image' );
89 $oldImageTable = $dbw->tableName(
'oldimage' );
91 if ( $method ==
'pipe' ) {
100 $this->
output(
"Using pipe method\n" );
101 $pipe = popen( $cmd,
'w' );
104 $numRows =
$res->numRows();
106 foreach (
$res as $row ) {
107 if ( $i % $this->mBatchSize == 0 ) {
109 "Done %d of %d, %5.3f%% \r", $i, $numRows, $i / $numRows * 100 ) );
117 $sha1 =
$file->getRepo()->getFileSha1(
$file->getPath() );
118 if ( strval( $sha1 ) !==
'' ) {
119 if ( $isRegen &&
$file->getSha1() !== $sha1 ) {
124 $sql =
"UPDATE $imageTable SET img_sha1=" . $dbw->addQuotes( $sha1 ) .
125 " WHERE img_name=" . $dbw->addQuotes(
$file->getName() );
126 if ( $method ==
'pipe' ) {
127 fwrite( $pipe,
"$sql;\n" );
129 $dbw->query( $sql, __METHOD__ );
134 foreach (
$file->getHistory()
as $oldFile ) {
135 $sha1 = $oldFile->getRepo()->getFileSha1( $oldFile->getPath() );
136 if ( strval( $sha1 ) !==
'' ) {
137 if ( $isRegen && $oldFile->getSha1() !== $sha1 ) {
140 $oldFile->upgradeRow();
142 $sql =
"UPDATE $oldImageTable SET oi_sha1=" . $dbw->addQuotes( $sha1 ) .
143 " WHERE (oi_name=" . $dbw->addQuotes( $oldFile->getName() ) .
" AND" .
144 " oi_archive_name=" . $dbw->addQuotes( $oldFile->getArchiveName() ) .
")";
145 if ( $method ==
'pipe' ) {
146 fwrite( $pipe,
"$sql;\n" );
148 $dbw->query( $sql, __METHOD__ );
155 if ( $method ==
'pipe' ) {
159 $t += microtime(
true );
160 $this->
output( sprintf(
"\nDone %d files in %.1f seconds\n", $numRows,
$t ) );
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
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
require_once RUN_MAINTENANCE_IF_MAIN
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
controlled by $wgMainCacheType controlled by $wgParserCacheType controlled by $wgMessageCacheType If you set CACHE_NONE to one of the three control default value for MediaWiki still create a but requests to it are no ops and we always fall through to the database If the cache daemon can t be it should also disable itself fairly smoothly By $wgMemc is used but when it is $parserMemc or $messageMemc this is mentioned $wgDBname
getUpdateKey()
Get the update key name to go in the update log table.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
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
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
__construct()
Default constructor.
wfEscapeShellArg()
Windows-compatible version of escapeshellarg() Windows doesn't recognise single-quotes in the shell,...
Maintenance script to populate the img_sha1 field.
doDBUpdates()
Do the actual work.
if(PHP_SAPI !='cli') $file
getOption( $name, $default=null)
Get an option, or return the default.
execute()
Do the actual work.
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.
wfLocalFile( $title)
Get an object referring to a locally registered file.