<?php
define( 'REPORTING_INTERVAL', 100 );
-define( 'STUB_HEADER', 'O:15:"historyblobstub"' );
if ( !defined( 'MEDIAWIKI' ) ) {
$optionsWithArgs = array( 'm' );
}
# Resolve stubs
- $flags = explode( ',', $row->old_flags );
- if ( in_array( 'object', $flags )
- && substr( $row->old_text, 0, strlen( STUB_HEADER ) ) === STUB_HEADER )
- {
- resolveStub( $id, $row->old_text, $row->old_flags );
+ $text = $row->old_text;
+ if ( $row->old_flags === '' ) {
+ $flags = 'external';
+ } else {
+ $flags = "{$row->old_flags},external";
+ }
+
+ if ( strpos( $flags, 'object' ) !== false ) {
+ $obj = unserialize( $text );
+ $className = strtolower( get_class( $obj ) );
+ if ( $className == 'historyblobstub' ) {
+ resolveStub( $id, $row->old_text, $row->old_flags );
+ continue;
+ } elseif ( $className == 'historyblobcurstub' ) {
+ $text = gzdeflate( $obj->getText() );
+ $flags = 'utf-8,gzip,external';
+ } elseif ( $className == 'concatenatedgziphistoryblob' ) {
+ // Do nothing
+ } else {
+ print "Warning: unrecognised object class \"$className\"\n";
+ continue;
+ }
+ }
+
+ if ( strlen( $text ) < 100 ) {
+ // Don't move tiny revisions
continue;
}
- $url = $ext->store( $cluster, $row->old_text );
+ #print "Storing " . strlen( $text ) . " bytes to $url\n";
+
+ $url = $ext->store( $cluster, $text );
if ( !$url ) {
print "Error writing to external storage\n";
exit;
}
- if ( $row->old_flags === '' ) {
- $flags = 'external';
- } else {
- $flags = "{$row->old_flags},external";
- }
$dbw->update( 'text',
array( 'old_flags' => $flags, 'old_text' => $url ),
array( 'old_id' => $id ), $fname );