* 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();
*/
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->getSerializedData();
+ } catch ( MWException $e ) {
+ $this->output( "Data 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" );
+ $this->output( "Data of revision with {$idCol}={$row->$idCol} unavailable!\n" );
return false;
} else {
$db->update( $table,
*/
protected function upgradeLegacyArchiveRow( $row ) {
$db = $this->getDB( DB_MASTER );
- $rev = Revision::newFromArchiveRow( $row );
- $text = $rev->getRawText();
+ 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->getSerializedData();
if ( !is_string( $text ) ) {
# This should not happen, but sometimes does (bug 20757)
- $this->output( "Text of revision with timestamp {$row->ar_timestamp} unavailable!\n" );
+ $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.