2007-11-20 12:58:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Communications protocol...
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
require "commandLine.inc";
|
|
|
|
|
|
|
|
|
|
$db = wfGetDB( DB_SLAVE );
|
|
|
|
|
$stdin = fopen( "php://stdin", "rt" );
|
|
|
|
|
while( !feof( $stdin ) ) {
|
|
|
|
|
$line = fgets( $stdin );
|
2008-05-19 15:49:05 +00:00
|
|
|
if( $line === false ) {
|
|
|
|
|
// We appear to have lost contact...
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-11-20 12:58:34 +00:00
|
|
|
$textId = intval( $line );
|
|
|
|
|
$text = doGetText( $db, $textId );
|
|
|
|
|
echo strlen( $text ) . "\n";
|
|
|
|
|
echo $text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* May throw a database error if, say, the server dies during query.
|
|
|
|
|
*/
|
|
|
|
|
function doGetText( $db, $id ) {
|
|
|
|
|
$id = intval( $id );
|
|
|
|
|
$row = $db->selectRow( 'text',
|
|
|
|
|
array( 'old_text', 'old_flags' ),
|
|
|
|
|
array( 'old_id' => $id ),
|
|
|
|
|
'TextPassDumper::getText' );
|
|
|
|
|
$text = Revision::getRevisionText( $row );
|
|
|
|
|
if( $text === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2007-11-20 17:34:42 +00:00
|
|
|
return $text;
|
2007-11-20 12:58:34 +00:00
|
|
|
}
|