MediaWiki  1.33.0
dumpRev.php
Go to the documentation of this file.
1 <?php
26 
27 require_once __DIR__ . '/../Maintenance.php';
28 
35 class 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 
65 require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance\fatalError
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Definition: Maintenance.php:485
DumpRev
Maintenance script that gets the text of a revision, resolving external storage if needed.
Definition: dumpRev.php:35
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
DumpRev\__construct
__construct()
Default constructor.
Definition: dumpRev.php:36
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$maintClass
$maintClass
Definition: dumpRev.php:64
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:300
$rev
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:1769
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:434
$content
$content
Definition: pageupdater.txt:72
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
DumpRev\execute
execute()
Do the actual work.
Definition: dumpRev.php:41
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:352
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:39