00001 <?php
00023 require_once( dirname(__FILE__) . '/Maintenance.php' );
00024
00025 class FetchText extends Maintenance {
00026 public function __construct() {
00027 parent::__construct();
00028 $this->mDescription = "Fetch the revision text from an old_id";
00029 }
00030
00031 public function execute() {
00032 $db = wfGetDB( DB_SLAVE );
00033 $stdin = $this->getStdin();
00034 while( !feof( $stdin ) ) {
00035 $line = fgets( $stdin );
00036 if( $line === false ) {
00037
00038 break;
00039 }
00040 $textId = intval( $line );
00041 $text = $this->doGetText( $db, $textId );
00042 $this->output( strlen( $text ) . "\n". $text );
00043 }
00044 }
00045
00052 private function doGetText( $db, $id ) {
00053 $id = intval( $id );
00054 $row = $db->selectRow( 'text',
00055 array( 'old_text', 'old_flags' ),
00056 array( 'old_id' => $id ),
00057 'TextPassDumper::getText' );
00058 $text = Revision::getRevisionText( $row );
00059 if( $text === false ) {
00060 return false;
00061 }
00062 return $text;
00063 }
00064 }
00065
00066 $maintClass = "FetchText";
00067 require_once( DO_MAINTENANCE );