-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetRevision.php
More file actions
40 lines (33 loc) · 1.07 KB
/
getRevision.php
File metadata and controls
40 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once __DIR__ . '/Maintenance.php';
/**
* Maintenance script that outputs revision text to stdout.
*
* @ingroup Maintenance
*/
class GetRevisionMaint extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = 'Outputs revision text to stdout';
$this->addOption( 'show-private', 'Show the text even if it\'s not available to the public' );
$this->addArg( 'revision', 'Revision ID' );
}
public function execute() {
$this->db = wfGetDB( DB_SLAVE );
$revisionText = $this->getArg( 0 );
$rev = Revision::newFromId( $revisionText );
if ( !$rev ) {
$this->error( "Revision $revisionText does not exist.\n", true );
}
$content = $rev->getContent( $this->hasOption( 'show-private' )
? Revision::RAW
: Revision::FOR_PUBLIC );
if ( $content === false ) {
$titleText = $title->getPrefixedText();
$this->error( "Couldn't extract the text from revision $revisionText.\n", true );
}
$this->output( $content->serialize() );
}
}
$maintClass = "GetRevisionMaint";
require_once RUN_MAINTENANCE_IF_MAIN;