MediaWiki
REL1_19
|
00001 <?php 00024 require_once( dirname( __FILE__ ) . '/Maintenance.php' ); 00025 00026 class FetchText extends Maintenance { 00027 public function __construct() { 00028 parent::__construct(); 00029 $this->mDescription = "Fetch the revision text from an old_id"; 00030 } 00031 00042 public function execute() { 00043 $db = wfGetDB( DB_SLAVE ); 00044 $stdin = $this->getStdin(); 00045 while ( !feof( $stdin ) ) { 00046 $line = fgets( $stdin ); 00047 if ( $line === false ) { 00048 // We appear to have lost contact... 00049 break; 00050 } 00051 $textId = intval( $line ); 00052 $text = $this->doGetText( $db, $textId ); 00053 if ($text === false) { 00054 # actual error, not zero-length text 00055 $textLen = "-1"; 00056 } 00057 else { 00058 $textLen = strlen($text); 00059 } 00060 $this->output( $textId . "\n" . $textLen . "\n" . $text ); 00061 } 00062 } 00063 00070 private function doGetText( $db, $id ) { 00071 $id = intval( $id ); 00072 $row = $db->selectRow( 'text', 00073 array( 'old_text', 'old_flags' ), 00074 array( 'old_id' => $id ), 00075 __METHOD__ ); 00076 $text = Revision::getRevisionText( $row ); 00077 if ( $text === false ) { 00078 return false; 00079 } 00080 return $text; 00081 } 00082 } 00083 00084 $maintClass = "FetchText"; 00085 require_once( RUN_MAINTENANCE_IF_MAIN );