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