Go to the documentation of this file.
25 require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
36 $this->mDescription =
"Populates the rev_sha1 and ar_sha1 fields";
41 return 'populate rev_sha1';
47 if ( !$db->tableExists(
'revision' ) ) {
48 $this->
error(
"revision table does not exist",
true );
49 } elseif ( !$db->tableExists(
'archive' ) ) {
50 $this->
error(
"archive table does not exist",
true );
51 } elseif ( !$db->fieldExists(
'revision',
'rev_sha1', __METHOD__ ) ) {
52 $this->
output(
"rev_sha1 column does not exist\n\n",
true );
56 $this->
output(
"Populating rev_sha1 column\n" );
59 $this->
output(
"Populating ar_sha1 column\n" );
61 $this->
output(
"Populating ar_sha1 column legacy rows\n" );
64 $this->
output(
"rev_sha1 and ar_sha1 population complete [$rc revision rows, $ac archive rows].\n" );
76 $start = $db->selectField( $table,
"MIN($idCol)",
false, __METHOD__ );
77 $end = $db->selectField( $table,
"MAX($idCol)",
false, __METHOD__ );
78 if ( !$start || !$end ) {
79 $this->
output(
"...$table table seems to be empty.\n" );
85 $end += $this->mBatchSize - 1;
87 $blockEnd = $start + $this->mBatchSize - 1;
88 while ( $blockEnd <= $end ) {
89 $this->
output(
"...doing $idCol from $blockStart to $blockEnd\n" );
90 $cond =
"$idCol BETWEEN $blockStart AND $blockEnd
91 AND $idCol IS NOT NULL AND {$prefix}_sha1 = ''";
92 $res = $db->select( $table,
'*', $cond, __METHOD__ );
94 $db->begin( __METHOD__ );
96 if ( $this->
upgradeRow( $row, $table, $idCol, $prefix ) ) {
100 $db->commit( __METHOD__ );
115 $res = $db->select(
'archive',
'*',
116 array(
'ar_rev_id IS NULL',
'ar_sha1' =>
'' ), __METHOD__ );
119 $db->begin( __METHOD__ );
120 foreach (
$res as $row ) {
124 if ( ++$updateSize >= 100 ) {
126 $db->commit( __METHOD__ );
127 $this->
output(
"Commited row with ar_timestamp={$row->ar_timestamp}\n" );
129 $db->begin( __METHOD__ );
132 $db->commit( __METHOD__ );
143 protected function upgradeRow( $row, $table, $idCol, $prefix ) {
146 $rev = ( $table ===
'archive' )
149 $text =
$rev->getSerializedData();
151 $this->
output(
"Data of revision with {$idCol}={$row->$idCol} unavailable!\n" );
154 if ( !is_string( $text ) ) {
155 # This should not happen, but sometimes does (bug 20757)
156 $this->
output(
"Data of revision with {$idCol}={$row->$idCol} unavailable!\n" );
161 array( $idCol => $row->$idCol ),
177 $this->
output(
"Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
180 $text =
$rev->getSerializedData();
181 if ( !is_string( $text ) ) {
182 # This should not happen, but sometimes does (bug 20757)
183 $this->
output(
"Data of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
186 # Archive table as no PK, but (NS,title,time) should be near unique.
187 # Any duplicates on those should also have duplicated text anyway.
188 $db->update(
'archive',
191 'ar_namespace' => $row->ar_namespace,
192 'ar_title' => $row->ar_title,
193 'ar_timestamp' => $row->ar_timestamp,
194 'ar_len' => $row->ar_len
int $mBatchSize
Batch size.
upgradeLegacyArchiveRow( $row)
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
doDBUpdates()
Do the actual work.
require_once RUN_MAINTENANCE_IF_MAIN
getUpdateKey()
Get the update key name to go in the update log table.
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
Maintenance script that fills the rev_sha1 and ar_sha1 columns of revision and archive tables for rev...
& getDB( $db, $groups=array(), $wiki=false)
Returns a database to be used by current maintenance script.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
upgradeRow( $row, $table, $idCol, $prefix)
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
doSha1Updates( $table, $idCol, $prefix)
static newFromArchiveRow( $row, $overrides=array())
Make a fake revision object from an archive table row.
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
__construct()
Default constructor.
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.
setBatchSize( $s=0)
Set the batch size.