summaryrefslogtreecommitdiff
path: root/maintenance/populateRevisionSha1.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-01-18 16:46:04 +0100
commit63601400e476c6cf43d985f3e7b9864681695ed4 (patch)
treef7846203a952e38aaf66989d0a4702779f549962 /maintenance/populateRevisionSha1.php
parent8ff01378c9e0207f9169b81966a51def645b6a51 (diff)
Update to MediaWiki 1.20.2
this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'maintenance/populateRevisionSha1.php')
-rw-r--r--maintenance/populateRevisionSha1.php48
1 files changed, 32 insertions, 16 deletions
diff --git a/maintenance/populateRevisionSha1.php b/maintenance/populateRevisionSha1.php
index 55e2a93d..2e14d31e 100644
--- a/maintenance/populateRevisionSha1.php
+++ b/maintenance/populateRevisionSha1.php
@@ -18,11 +18,18 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
+ * @file
* @ingroup Maintenance
*/
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
+require_once( __DIR__ . '/Maintenance.php' );
+/**
+ * Maintenance script that fills the rev_sha1 and ar_sha1 columns of revision
+ * and archive tables for revisions created before MW 1.19.
+ *
+ * @ingroup Maintenance
+ */
class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
public function __construct() {
parent::__construct();
@@ -81,13 +88,13 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
AND $idCol IS NOT NULL AND {$prefix}_sha1 = ''";
$res = $db->select( $table, '*', $cond, __METHOD__ );
- $db->begin();
+ $db->begin( __METHOD__ );
foreach ( $res as $row ) {
if ( $this->upgradeRow( $row, $table, $idCol, $prefix ) ) {
$count++;
}
}
- $db->commit();
+ $db->commit( __METHOD__ );
$blockStart += $this->mBatchSize;
$blockEnd += $this->mBatchSize;
@@ -102,23 +109,24 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
protected function doSha1LegacyUpdates() {
$count = 0;
$db = $this->getDB( DB_MASTER );
- $res = $db->select( 'archive', '*', array( 'ar_rev_id IS NULL' ), __METHOD__ );
+ $res = $db->select( 'archive', '*',
+ array( 'ar_rev_id IS NULL', 'ar_sha1' => '' ), __METHOD__ );
$updateSize = 0;
- $db->begin();
+ $db->begin( __METHOD__ );
foreach ( $res as $row ) {
if ( $this->upgradeLegacyArchiveRow( $row ) ) {
++$count;
}
if ( ++$updateSize >= 100 ) {
$updateSize = 0;
- $db->commit();
+ $db->commit( __METHOD__ );
$this->output( "Commited row with ar_timestamp={$row->ar_timestamp}\n" );
wfWaitForSlaves();
- $db->begin();
+ $db->begin( __METHOD__ );
}
}
- $db->commit();
+ $db->commit( __METHOD__ );
return $count;
}
@@ -131,12 +139,15 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
*/
protected function upgradeRow( $row, $table, $idCol, $prefix ) {
$db = $this->getDB( DB_MASTER );
- if ( $table === 'archive' ) {
- $rev = Revision::newFromArchiveRow( $row );
- } else {
- $rev = new Revision( $row );
+ try {
+ $rev = ( $table === 'archive' )
+ ? Revision::newFromArchiveRow( $row )
+ : new Revision( $row );
+ $text = $rev->getRawText();
+ } catch ( MWException $e ) {
+ $this->output( "Text of revision with {$idCol}={$row->$idCol} unavailable!\n" );
+ return false; // bug 22624?
}
- $text = $rev->getRawText();
if ( !is_string( $text ) ) {
# This should not happen, but sometimes does (bug 20757)
$this->output( "Text of revision with {$idCol}={$row->$idCol} unavailable!\n" );
@@ -145,7 +156,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
$db->update( $table,
array( "{$prefix}_sha1" => Revision::base36Sha1( $text ) ),
array( $idCol => $row->$idCol ),
- __METHOD__
+ __METHOD__
);
return true;
}
@@ -157,7 +168,12 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
*/
protected function upgradeLegacyArchiveRow( $row ) {
$db = $this->getDB( DB_MASTER );
- $rev = Revision::newFromArchiveRow( $row );
+ try {
+ $rev = Revision::newFromArchiveRow( $row );
+ } catch ( MWException $e ) {
+ $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
+ return false; // bug 22624?
+ }
$text = $rev->getRawText();
if ( !is_string( $text ) ) {
# This should not happen, but sometimes does (bug 20757)
@@ -174,7 +190,7 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
'ar_timestamp' => $row->ar_timestamp,
'ar_len' => $row->ar_len // extra sanity
),
- __METHOD__
+ __METHOD__
);
return true;
}