MediaWiki REL1_37
dumpRev.php
Go to the documentation of this file.
1<?php
26
27require_once __DIR__ . '/../Maintenance.php';
28
35class DumpRev extends Maintenance {
36 public function __construct() {
37 parent::__construct();
38 $this->addArg( 'rev-id', 'Revision ID', true );
39 }
40
41 public function execute() {
42 $id = (int)$this->getArg( 0 );
43
44 $lookup = MediaWikiServices::getInstance()->getRevisionLookup();
45 $rev = $lookup->getRevisionById( $id );
46 if ( !$rev ) {
47 $this->fatalError( "Row not found" );
48 }
49
50 $content = $rev->getContent( SlotRecord::MAIN );
51 if ( !$content ) {
52 $this->fatalError( "Text not found" );
53 }
54
55 $blobStore = MediaWikiServices::getInstance()->getBlobStore();
56 $slot = $rev->getSlot( SlotRecord::MAIN );
57 $text = $blobStore->getBlob( $slot->getAddress() );
58
59 $this->output( "Text length: " . strlen( $text ) . "\n" );
60 $this->output( substr( $text, 0, 100 ) . "\n" );
61 }
62}
63
64$maintClass = DumpRev::class;
65require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that gets the text of a revision, resolving external storage if needed.
Definition dumpRev.php:35
execute()
Do the actual work.
Definition dumpRev.php:41
__construct()
Default constructor.
Definition dumpRev.php:36
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
Add some args that are needed.
output( $out, $channel=null)
Throw some output to the user.
getArg( $argId=0, $default=null)
Get an argument.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
MediaWikiServices is the service locator for the application scope of MediaWiki.
Value object representing a content slot associated with a page revision.
$maintClass
Definition dumpRev.php:64
$content
Definition router.php:76