24require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
36 $this->
addDescription(
'Populates the rev_len and ar_len fields' );
41 return 'populate rev_len and ar_len';
46 if ( !$dbw->tableExists(
'revision' ) ) {
47 $this->
error(
"revision table does not exist",
true );
48 } elseif ( !$dbw->tableExists(
'archive' ) ) {
49 $this->
error(
"archive table does not exist",
true );
50 } elseif ( !$dbw->fieldExists(
'revision',
'rev_len', __METHOD__ ) ) {
51 $this->
output(
"rev_len column does not exist\n\n",
true );
56 $this->
output(
"Populating rev_len column\n" );
59 $this->
output(
"Populating ar_len column\n" );
62 $this->
output(
"rev_len and ar_len population complete "
63 .
"[$rev revision rows, $ar archive rows].\n" );
75 protected function doLenUpdates( $table, $idCol, $prefix, $fields ) {
78 $start = $dbw->selectField( $table,
"MIN($idCol)",
false, __METHOD__ );
79 $end = $dbw->selectField( $table,
"MAX($idCol)",
false, __METHOD__ );
80 if ( !$start || !$end ) {
81 $this->
output(
"...$table table seems to be empty.\n" );
87 $blockStart = intval( $start );
88 $blockEnd = intval( $start ) + $this->mBatchSize - 1;
91 while ( $blockStart <= $end ) {
92 $this->
output(
"...doing $idCol from $blockStart to $blockEnd\n" );
97 "$idCol >= $blockStart",
98 "$idCol <= $blockEnd",
99 "{$prefix}_len IS NULL"
104 if (
$res->numRows() > 0 ) {
106 # Go through and update rev_len from these rows.
107 foreach (
$res as $row ) {
108 if ( $this->
upgradeRow( $row, $table, $idCol, $prefix ) ) {
130 protected function upgradeRow( $row, $table, $idCol, $prefix ) {
133 $rev = ( $table ===
'archive' )
137 $content =
$rev->getContent();
139 # This should not happen, but sometimes does (T22757)
141 $this->
output(
"Content of $table $id unavailable!\n" );
147 $dbw->update( $table,
148 [
"{$prefix}_len" => $content->getSize() ],
149 [ $idCol => $row->$idCol ],
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 populates the rev_len and ar_len fields when they are NULL.
doLenUpdates( $table, $idCol, $prefix, $fields)
__construct()
Default constructor.
doDBUpdates()
Do the actual work.
upgradeRow( $row, $table, $idCol, $prefix)
getUpdateKey()
Get the update key name to go in the update log table.
static selectArchiveFields()
Return the list of revision fields that should be selected to create a new revision from an archive r...
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
static newFromArchiveRow( $row, $overrides=[])
Make a fake revision object from an archive table row.
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
require_once RUN_MAINTENANCE_IF_MAIN