MediaWiki REL1_33
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;
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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.
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition hooks.txt:1779
$maintClass
Definition dumpRev.php:64
require_once RUN_MAINTENANCE_IF_MAIN
$content