MediaWiki master
dumpRev.php
Go to the documentation of this file.
1<?php
25
26// @codeCoverageIgnoreStart
27require_once __DIR__ . '/../Maintenance.php';
28// @codeCoverageIgnoreEnd
29
36class DumpRev extends Maintenance {
37 public function __construct() {
38 parent::__construct();
39 $this->addArg( 'rev-id', 'Revision ID', true );
40 }
41
42 public function execute() {
43 $id = (int)$this->getArg( 0 );
44
45 $lookup = $this->getServiceContainer()->getRevisionLookup();
46 $rev = $lookup->getRevisionById( $id );
47 if ( !$rev ) {
48 $this->fatalError( "Row not found" );
49 }
50
51 $content = $rev->getContent( SlotRecord::MAIN );
52 if ( !$content ) {
53 $this->fatalError( "Text not found" );
54 }
55
56 $blobStore = $this->getServiceContainer()->getBlobStore();
57 $slot = $rev->getSlot( SlotRecord::MAIN );
58 $text = $blobStore->getBlob( $slot->getAddress() );
59
60 $this->output( "Text length: " . strlen( $text ) . "\n" );
61 $this->output( substr( $text, 0, 100 ) . "\n" );
62 }
63}
64
65// @codeCoverageIgnoreStart
66$maintClass = DumpRev::class;
67require_once RUN_MAINTENANCE_IF_MAIN;
68// @codeCoverageIgnoreEnd
Maintenance script that gets the text of a revision, resolving external storage if needed.
Definition dumpRev.php:36
execute()
Definition dumpRev.php:42
__construct()
Definition dumpRev.php:37
Value object representing a content slot associated with a page revision.
$maintClass
Definition dumpRev.php:66