From: Platonides Date: Sun, 17 Jan 2010 16:00:36 +0000 (+0000) Subject: Follow up r59331. X-Git-Tag: 1.31.0-rc.0~38228 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=373d92023afb5a0f11feed879ec542f441da3303;p=lhc%2Fweb%2Fwiklou.git Follow up r59331. *Check for false on $rev->getText() *Use prefixed title on the messages. *Add --show-private option to bypass revision delete. --- diff --git a/maintenance/getText.php b/maintenance/getText.php index b8d9676122..6326267dea 100644 --- a/maintenance/getText.php +++ b/maintenance/getText.php @@ -27,27 +27,32 @@ class GetTextMaint extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = '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() { - $this->db = wfGetDB( DB_MASTER ); + $this->db = wfGetDB( DB_SLAVE ); $titleText = $this->getArg( 0 ); $title = Title::newFromText( $titleText ); if ( !$title ) { - $this->error( "$titleText is not a valid title\n", true ); + $this->error( "$titleText is not a valid title.\n", true ); } $rev = Revision::newFromTitle( $title ); if ( !$rev ) { - $titleText = $title->getText(); - $this->error( "Page $titleText does not exist\n", true ); + $titleText = $title->getPrefixedText(); + $this->error( "Page $titleText does not exist.\n", true ); } - - $this->output( $rev->getText() ); + $text = $rev->getText( $this->hasOption('show-private') ? Revision::RAW : Revision::FOR_PUBLIC ); + if ( $text === false ) { + $titleText = $title->getPrefixedText(); + $this->error( "Couldn't extract the text from $titleText.\n", true ); + } + $this->output( $text ); } } $maintClass = "GetTextMaint"; -require_once( DO_MAINTENANCE ); \ No newline at end of file +require_once( DO_MAINTENANCE );