X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpopulateRevisionSha1.php;h=b401db0377e20f4e84df637adb7a9c3e7912145f;hb=69217704148a5751754fb1b9587e7f6d5c774b13;hp=dfe905eea764113cf5847a1e5eba804eb3b6b017;hpb=c752c43a374a49fe77dacac5a0a514c5a43f838b;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateRevisionSha1.php b/maintenance/populateRevisionSha1.php index dfe905eea7..b401db0377 100644 --- a/maintenance/populateRevisionSha1.php +++ b/maintenance/populateRevisionSha1.php @@ -22,7 +22,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/Maintenance.php' ); +require_once __DIR__ . '/Maintenance.php'; /** * Maintenance script that fills the rev_sha1 and ar_sha1 columns of revision @@ -50,6 +50,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $this->error( "archive table does not exist", true ); } elseif ( !$db->fieldExists( 'revision', 'rev_sha1', __METHOD__ ) ) { $this->output( "rev_sha1 column does not exist\n\n", true ); + return false; } @@ -61,15 +62,17 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $this->output( "Populating ar_sha1 column legacy rows\n" ); $ac += $this->doSha1LegacyUpdates(); - $this->output( "rev_sha1 and ar_sha1 population complete [$rc revision rows, $ac archive rows].\n" ); + $this->output( "rev_sha1 and ar_sha1 population complete " + . "[$rc revision rows, $ac archive rows].\n" ); + return true; } /** - * @param $table string - * @param $idCol - * @param $prefix string - * @return Integer Rows changed + * @param string $table + * @param string $idCol + * @param string $prefix + * @return int Rows changed */ protected function doSha1Updates( $table, $idCol, $prefix ) { $db = $this->getDB( DB_MASTER ); @@ -77,6 +80,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ ); if ( !$start || !$end ) { $this->output( "...$table table seems to be empty.\n" ); + return 0; } @@ -103,6 +107,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { $blockEnd += $this->mBatchSize; wfWaitForSlaves(); } + return $count; } @@ -130,14 +135,15 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { } } $db->commit( __METHOD__ ); + return $count; } /** - * @param $row - * @param $table - * @param $idCol - * @param $prefix + * @param stdClass $row + * @param string $table + * @param string $idCol + * @param string $prefix * @return bool */ protected function upgradeRow( $row, $table, $idCol, $prefix ) { @@ -147,13 +153,15 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { ? Revision::newFromArchiveRow( $row ) : new Revision( $row ); $text = $rev->getSerializedData(); - } catch ( MWException $e ) { + } catch ( Exception $e ) { $this->output( "Data of revision with {$idCol}={$row->$idCol} unavailable!\n" ); + return false; // bug 22624? } if ( !is_string( $text ) ) { # This should not happen, but sometimes does (bug 20757) $this->output( "Data of revision with {$idCol}={$row->$idCol} unavailable!\n" ); + return false; } else { $db->update( $table, @@ -161,26 +169,29 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { array( $idCol => $row->$idCol ), __METHOD__ ); + return true; } } /** - * @param $row + * @param stdClass $row * @return bool */ protected function upgradeLegacyArchiveRow( $row ) { $db = $this->getDB( DB_MASTER ); try { $rev = Revision::newFromArchiveRow( $row ); - } catch ( MWException $e ) { + } catch ( Exception $e ) { $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" ); + return false; // bug 22624? } $text = $rev->getSerializedData(); if ( !is_string( $text ) ) { # This should not happen, but sometimes does (bug 20757) $this->output( "Data of revision with timestamp {$row->ar_timestamp} unavailable!\n" ); + return false; } else { # Archive table as no PK, but (NS,title,time) should be near unique. @@ -195,10 +206,11 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance { ), __METHOD__ ); + return true; } } } $maintClass = "PopulateRevisionSha1"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN;