MediaWiki
REL1_24
|
00001 <?php 00025 require_once __DIR__ . '/Maintenance.php'; 00026 00032 class FetchText extends Maintenance { 00033 public function __construct() { 00034 parent::__construct(); 00035 $this->mDescription = "Fetch the revision text from an old_id"; 00036 } 00037 00048 public function execute() { 00049 $db = wfGetDB( DB_SLAVE ); 00050 $stdin = $this->getStdin(); 00051 while ( !feof( $stdin ) ) { 00052 $line = fgets( $stdin ); 00053 if ( $line === false ) { 00054 // We appear to have lost contact... 00055 break; 00056 } 00057 $textId = intval( $line ); 00058 $text = $this->doGetText( $db, $textId ); 00059 if ( $text === false ) { 00060 # actual error, not zero-length text 00061 $textLen = "-1"; 00062 } else { 00063 $textLen = strlen( $text ); 00064 } 00065 $this->output( $textId . "\n" . $textLen . "\n" . $text ); 00066 } 00067 } 00068 00075 private function doGetText( $db, $id ) { 00076 $id = intval( $id ); 00077 $row = $db->selectRow( 'text', 00078 array( 'old_text', 'old_flags' ), 00079 array( 'old_id' => $id ), 00080 __METHOD__ ); 00081 $text = Revision::getRevisionText( $row ); 00082 if ( $text === false ) { 00083 return false; 00084 } 00085 00086 return $text; 00087 } 00088 } 00089 00090 $maintClass = "FetchText"; 00091 require_once RUN_MAINTENANCE_IF_MAIN;