MediaWiki  1.23.6
fetchText.php
Go to the documentation of this file.
1 <?php
25 require_once __DIR__ . '/Maintenance.php';
26 
32 class FetchText extends Maintenance {
33  public function __construct() {
34  parent::__construct();
35  $this->mDescription = "Fetch the revision text from an old_id";
36  }
37 
48  public function execute() {
49  $db = wfGetDB( DB_SLAVE );
50  $stdin = $this->getStdin();
51  while ( !feof( $stdin ) ) {
52  $line = fgets( $stdin );
53  if ( $line === false ) {
54  // We appear to have lost contact...
55  break;
56  }
57  $textId = intval( $line );
58  $text = $this->doGetText( $db, $textId );
59  if ( $text === false ) {
60  # actual error, not zero-length text
61  $textLen = "-1";
62  }
63  else {
64  $textLen = strlen( $text );
65  }
66  $this->output( $textId . "\n" . $textLen . "\n" . $text );
67  }
68  }
69 
76  private function doGetText( $db, $id ) {
77  $id = intval( $id );
78  $row = $db->selectRow( 'text',
79  array( 'old_text', 'old_flags' ),
80  array( 'old_id' => $id ),
81  __METHOD__ );
82  $text = Revision::getRevisionText( $row );
83  if ( $text === false ) {
84  return false;
85  }
86  return $text;
87  }
88 }
89 
90 $maintClass = "FetchText";
91 require_once RUN_MAINTENANCE_IF_MAIN;
FetchText
Maintenance script used to fetch page text in a subprocess.
Definition: fetchText.php:32
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
Maintenance\getStdin
getStdin( $len=null)
Return input from stdin.
Definition: Maintenance.php:287
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3659
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Revision\getRevisionText
static getRevisionText( $row, $prefix='old_', $wiki=false)
Get revision text associated with an old or archive row $row is usually an object from wfFetchRow(),...
Definition: Revision.php:1212
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
FetchText\execute
execute()
returns a string containing the following in order: textid length of text (-1 on error = failure to...
Definition: fetchText.php:48
$maintClass
$maintClass
Definition: fetchText.php:90
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
FetchText\doGetText
doGetText( $db, $id)
May throw a database error if, say, the server dies during query.
Definition: fetchText.php:76
$line
$line
Definition: cdb.php:57
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
FetchText\__construct
__construct()
Default constructor.
Definition: fetchText.php:33