From 183851b06bd6c52f3cae5375f433da720d410447 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 18:12:39 +0000 Subject: MediaWiki 1.7.1 wiederhergestellt --- maintenance/storage/moveToExternal.php | 97 ++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 maintenance/storage/moveToExternal.php (limited to 'maintenance/storage/moveToExternal.php') diff --git a/maintenance/storage/moveToExternal.php b/maintenance/storage/moveToExternal.php new file mode 100644 index 00000000..0b46f70b --- /dev/null +++ b/maintenance/storage/moveToExternal.php @@ -0,0 +1,97 @@ +] \n"; + exit; + } + + $cluster = $args[0]; + $dbw =& wfGetDB( DB_MASTER ); + + if ( isset( $options['m'] ) ) { + $maxID = $options['m']; + } else { + $maxID = $dbw->selectField( 'text', 'MAX(old_id)', false, $fname ); + } + + moveToExternal( $cluster, $maxID ); +} + + + +function moveToExternal( $cluster, $maxID ) { + $fname = 'moveToExternal'; + $dbw =& wfGetDB( DB_MASTER ); + + print "Moving $maxID text rows to external storage\n"; + $ext = new ExternalStoreDB; + for ( $id = 1; $id <= $maxID; $id++ ) { + if ( !($id % REPORTING_INTERVAL) ) { + print "$id\n"; + wfWaitForSlaves( 5 ); + } + $row = $dbw->selectRow( 'text', array( 'old_flags', 'old_text' ), + array( + 'old_id' => $id, + "old_flags NOT LIKE '%external%'", + ), $fname ); + if ( !$row ) { + # Non-existent or already done + continue; + } + + # Resolve stubs + $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; + } + + #print "Storing " . strlen( $text ) . " bytes to $url\n"; + + $url = $ext->store( $cluster, $text ); + if ( !$url ) { + print "Error writing to external storage\n"; + exit; + } + $dbw->update( 'text', + array( 'old_flags' => $flags, 'old_text' => $url ), + array( 'old_id' => $id ), $fname ); + } +} + +?> -- cgit v1.2.3-54-g00ecf