summaryrefslogtreecommitdiff
path: root/maintenance/fetchText.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/fetchText.php')
-rw-r--r--maintenance/fetchText.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/maintenance/fetchText.php b/maintenance/fetchText.php
new file mode 100644
index 00000000..3b745c0a
--- /dev/null
+++ b/maintenance/fetchText.php
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * Communications protocol...
+ */
+
+require "commandLine.inc";
+
+$db = wfGetDB( DB_SLAVE );
+$stdin = fopen( "php://stdin", "rt" );
+while( !feof( $stdin ) ) {
+ $line = fgets( $stdin );
+ $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;
+ }
+ return $text;
+}
+
+
+?> \ No newline at end of file