MediaWiki REL1_30
fetchText.php
Go to the documentation of this file.
1<?php
25require_once __DIR__ . '/Maintenance.php';
26
28
34class FetchText extends Maintenance {
35 public function __construct() {
36 parent::__construct();
37 $this->addDescription( "Fetch the raw revision blob from an old_id.\n" .
38 "NOTE: Export transformations are NOT applied. " .
39 "This is left to backupTextPass.php"
40 );
41 }
42
53 public function execute() {
54 $db = $this->getDB( DB_REPLICA );
55 $stdin = $this->getStdin();
56 while ( !feof( $stdin ) ) {
57 $line = fgets( $stdin );
58 if ( $line === false ) {
59 // We appear to have lost contact...
60 break;
61 }
62 $textId = intval( $line );
63 $text = $this->doGetText( $db, $textId );
64 if ( $text === false ) {
65 # actual error, not zero-length text
66 $textLen = "-1";
67 } else {
68 $textLen = strlen( $text );
69 }
70 $this->output( $textId . "\n" . $textLen . "\n" . $text );
71 }
72 }
73
80 private function doGetText( $db, $id ) {
81 $id = intval( $id );
82 $row = $db->selectRow( 'text',
83 [ 'old_text', 'old_flags' ],
84 [ 'old_id' => $id ],
85 __METHOD__ );
86 $text = Revision::getRevisionText( $row );
87 if ( $text === false ) {
88 return false;
89 }
90
91 return $text;
92 }
93}
94
95$maintClass = "FetchText";
96require_once RUN_MAINTENANCE_IF_MAIN;
$line
Definition cdb.php:58
Maintenance script used to fetch page text in a subprocess.
Definition fetchText.php:34
doGetText( $db, $id)
May throw a database error if, say, the server dies during query.
Definition fetchText.php:80
__construct()
Default constructor.
Definition fetchText.php:35
execute()
returns a string containing the following in order: textid \n length of text (-1 on error = failure t...
Definition fetchText.php:53
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
getStdin( $len=null)
Return input from stdin.
getDB( $db, $groups=[], $wiki=false)
Returns a database to be used by current maintenance script.
addDescription( $text)
Set the description text.
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
$maintClass
Definition fetchText.php:95
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:40
require_once RUN_MAINTENANCE_IF_MAIN
const DB_REPLICA
Definition defines.php:25