r61170 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61169‎ | r61170 | r61171 >
Date:16:00, 17 January 2010
Author:platonides
Status:ok
Tags:
Comment:
Follow up r59331.
*Check for false on $rev->getText()
*Use prefixed title on the messages.
*Add --show-private option to bypass revision delete.
Modified paths:
  • /trunk/phase3/maintenance/getText.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/getText.php
@@ -27,27 +27,32 @@
2828 public function __construct() {
2929 parent::__construct();
3030 $this->mDescription = 'Outputs page text to stdout';
 31+ $this->addOption( 'show-private', 'Show the text even if it\'s not available to the public' );
3132 $this->addArg( 'title', 'Page title' );
3233 }
3334
3435 public function execute() {
35 - $this->db = wfGetDB( DB_MASTER );
 36+ $this->db = wfGetDB( DB_SLAVE );
3637
3738 $titleText = $this->getArg( 0 );
3839 $title = Title::newFromText( $titleText );
3940 if ( !$title ) {
40 - $this->error( "$titleText is not a valid title\n", true );
 41+ $this->error( "$titleText is not a valid title.\n", true );
4142 }
4243
4344 $rev = Revision::newFromTitle( $title );
4445 if ( !$rev ) {
45 - $titleText = $title->getText();
46 - $this->error( "Page $titleText does not exist\n", true );
 46+ $titleText = $title->getPrefixedText();
 47+ $this->error( "Page $titleText does not exist.\n", true );
4748 }
48 -
49 - $this->output( $rev->getText() );
 49+ $text = $rev->getText( $this->hasOption('show-private') ? Revision::RAW : Revision::FOR_PUBLIC );
 50+ if ( $text === false ) {
 51+ $titleText = $title->getPrefixedText();
 52+ $this->error( "Couldn't extract the text from $titleText.\n", true );
 53+ }
 54+ $this->output( $text );
5055 }
5156 }
5257
5358 $maintClass = "GetTextMaint";
54 -require_once( DO_MAINTENANCE );
\ No newline at end of file
 59+require_once( DO_MAINTENANCE );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59331Small script to output page text to stdoutmaxsem11:30, 22 November 2009

Status & tagging log