X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpopulateRevisionLength.php;h=297bed242e1abc736c8317cf0ec5c11f1070db8a;hb=4dc3ac1c375b3d2eb6172dfef8fdebe71b8c5f43;hp=d5e40e4843f1b220f29218f6921cbb3ab799ed8d;hpb=79ebb4b0288b709fb53cff8f7ebc5f50221931c9;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index d5e40e4843..297bed242e 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -33,7 +33,7 @@ require_once __DIR__ . '/Maintenance.php'; class PopulateRevisionLength extends LoggedUpdateMaintenance { public function __construct() { parent::__construct(); - $this->mDescription = "Populates the rev_len and ar_len fields"; + $this->addDescription( 'Populates the rev_len and ar_len fields' ); $this->setBatchSize( 200 ); } @@ -49,6 +49,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $this->error( "archive table does not exist", true ); } elseif ( !$db->fieldExists( 'revision', 'rev_len', __METHOD__ ) ) { $this->output( "rev_len column does not exist\n\n", true ); + return false; } @@ -58,7 +59,9 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $this->output( "Populating ar_len column\n" ); $ar = $this->doLenUpdates( 'archive', 'ar_id', 'ar', Revision::selectArchiveFields() ); - $this->output( "rev_len and ar_len population complete [$rev revision rows, $ar archive rows].\n" ); + $this->output( "rev_len and ar_len population complete " + . "[$rev revision rows, $ar archive rows].\n" ); + return true; } @@ -75,6 +78,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ ); if ( !$start || !$end ) { $this->output( "...$table table seems to be empty.\n" ); + return 0; } @@ -96,14 +100,14 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { __METHOD__ ); - $db->begin( __METHOD__ ); + $this->beginTransaction( $db, __METHOD__ ); # Go through and update rev_len from these rows. foreach ( $res as $row ) { if ( $this->upgradeRow( $row, $table, $idCol, $prefix ) ) { $count++; } } - $db->commit( __METHOD__ ); + $this->commitTransaction( $db, __METHOD__ ); $blockStart += $this->mBatchSize; $blockEnd += $this->mBatchSize; @@ -132,6 +136,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { # This should not happen, but sometimes does (bug 20757) $id = $row->$idCol; $this->output( "Content of $table $id unavailable!\n" ); + return false; }