25require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
36 $this->
addDescription(
'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 );
57 $this->
output(
"Populating rev_sha1 column\n" );
60 $this->
output(
"Populating ar_sha1 column\n" );
62 $this->
output(
"Populating ar_sha1 column legacy rows\n" );
65 $this->
output(
"rev_sha1 and ar_sha1 population complete "
66 .
"[$rc revision rows, $ac archive rows].\n" );
79 $start = $db->selectField( $table,
"MIN($idCol)",
false, __METHOD__ );
80 $end = $db->selectField( $table,
"MAX($idCol)",
false, __METHOD__ );
81 if ( !$start || !$end ) {
82 $this->
output(
"...$table table seems to be empty.\n" );
89 $end += $this->mBatchSize - 1;
91 $blockEnd = $start + $this->mBatchSize - 1;
92 while ( $blockEnd <= $end ) {
93 $this->
output(
"...doing $idCol from $blockStart to $blockEnd\n" );
94 $cond =
"$idCol BETWEEN $blockStart AND $blockEnd
95 AND $idCol IS NOT NULL AND {$prefix}_sha1 = ''";
96 $res = $db->select( $table,
'*', $cond, __METHOD__ );
99 foreach (
$res as $row ) {
100 if ( $this->
upgradeRow( $row, $table, $idCol, $prefix ) ) {
120 $res = $db->select(
'archive',
'*',
121 [
'ar_rev_id IS NULL',
'ar_sha1' =>
'' ], __METHOD__ );
125 foreach (
$res as $row ) {
129 if ( ++$updateSize >= 100 ) {
132 $this->
output(
"Commited row with ar_timestamp={$row->ar_timestamp}\n" );
149 protected function upgradeRow( $row, $table, $idCol, $prefix ) {
152 $rev = ( $table ===
'archive' )
155 $text =
$rev->getSerializedData();
156 }
catch ( Exception
$e ) {
157 $this->
output(
"Data of revision with {$idCol}={$row->$idCol} unavailable!\n" );
161 if ( !is_string( $text ) ) {
162 # This should not happen, but sometimes does (T22757)
163 $this->
output(
"Data of revision with {$idCol}={$row->$idCol} unavailable!\n" );
169 [ $idCol => $row->$idCol ],
185 }
catch ( Exception
$e ) {
186 $this->
output(
"Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
190 $text =
$rev->getSerializedData();
191 if ( !is_string( $text ) ) {
192 # This should not happen, but sometimes does (T22757)
193 $this->
output(
"Data of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
197 # Archive table as no PK, but (NS,title,time) should be near unique.
198 # Any duplicates on those should also have duplicated text anyway.
199 $db->update(
'archive',
202 'ar_namespace' => $row->ar_namespace,
203 'ar_title' => $row->ar_title,
204 'ar_timestamp' => $row->ar_timestamp,
205 'ar_len' => $row->ar_len
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
int $mBatchSize
Batch size.
beginTransaction(IDatabase $dbw, $fname)
Begin a transcation on a DB.
commitTransaction(IDatabase $dbw, $fname)
Commit the transcation on a DB handle and wait for replica DBs to catch up.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
addDescription( $text)
Set the description text.
setBatchSize( $s=0)
Set the batch size.
Maintenance script that fills the rev_sha1 and ar_sha1 columns of revision and archive tables for rev...
upgradeRow( $row, $table, $idCol, $prefix)
getUpdateKey()
Get the update key name to go in the update log table.
__construct()
Default constructor.
upgradeLegacyArchiveRow( $row)
doSha1Updates( $table, $idCol, $prefix)
doDBUpdates()
Do the actual work.
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
static base36Sha1( $text)
Get the base 36 SHA-1 value for a string of text.
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
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
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
require_once RUN_MAINTENANCE_IF_MAIN