addDescription( 'Outputs page text to stdout' ); $this->addOption( 'show-private', 'Show the text even if it\'s not available to the public' ); $this->addArg( 'title', 'Page title' ); } public function execute() { $titleText = $this->getArg( 0 ); $title = Title::newFromText( $titleText ); if ( !$title ) { $this->fatalError( "$titleText is not a valid title.\n" ); } $rev = MediaWikiServices::getInstance() ->getRevisionLookup() ->getRevisionByTitle( $title ); if ( !$rev ) { $titleText = $title->getPrefixedText(); $this->fatalError( "Page $titleText does not exist.\n" ); } $audience = $this->hasOption( 'show-private' ) ? RevisionRecord::RAW : RevisionRecord::FOR_PUBLIC; $content = $rev->getContent( SlotRecord::MAIN, $audience ); if ( $content === false ) { $titleText = $title->getPrefixedText(); $this->fatalError( "Couldn't extract the text from $titleText.\n" ); } $this->output( $content->serialize() ); } } $maintClass = GetTextMaint::class; require_once RUN_MAINTENANCE_IF_MAIN;