From: Ilmari Karonen Date: Thu, 4 Mar 2010 00:27:44 +0000 (+0000) Subject: followup to r63221: skip update and emit warning if revision text cannot be found X-Git-Tag: 1.31.0-rc.0~37555 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=e407460bcb3af0e44169f614a30d781a2509097f;p=lhc%2Fweb%2Fwiklou.git followup to r63221: skip update and emit warning if revision text cannot be found --- diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index 2ee67794b6..13868f051a 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -49,6 +49,7 @@ class PopulateRevisionLength extends Maintenance { $blockStart = intval( $start ); $blockEnd = intval( $start ) + $this->mBatchSize - 1; $count = 0; + $missing = 0; while( $blockStart <= $end ) { $this->output( "...doing rev_id from $blockStart to $blockEnd\n" ); $res = $db->select( 'revision', @@ -61,12 +62,19 @@ class PopulateRevisionLength extends Maintenance { foreach( $res as $row ) { $rev = new Revision( $row ); $text = $rev->getRawText(); - # Update the row... - $db->update( 'revision', - array( 'rev_len' => strlen( $text ) ), - array( 'rev_id' => $row->rev_id ), - __METHOD__ ); - $count++; + if( !is_string( $text ) ) { + # This should not happen, but sometimes does (bug 20757) + $this->output("Text of revision {$row->rev_id} unavailable!\n"); + $missing++; + } + else { + # Update the row... + $db->update( 'revision', + array( 'rev_len' => strlen( $text ) ), + array( 'rev_id' => $row->rev_id ), + __METHOD__ ); + $count++; + } } $blockStart += $this->mBatchSize; $blockEnd += $this->mBatchSize; @@ -77,7 +85,7 @@ class PopulateRevisionLength extends Maintenance { __METHOD__, 'IGNORE' ); if( $logged ) { - $this->output( "rev_len population complete ... {$count} rows changed\n" ); + $this->output( "rev_len population complete ... {$count} rows changed ({$missing} missing)\n" ); return true; } else { $this->output( "Could not insert rev_len population row.\n" );