Index: trunk/phase3/maintenance/getText.php |
— | — | @@ -27,27 +27,32 @@ |
28 | 28 | public function __construct() { |
29 | 29 | parent::__construct(); |
30 | 30 | $this->mDescription = 'Outputs page text to stdout'; |
| 31 | + $this->addOption( 'show-private', 'Show the text even if it\'s not available to the public' ); |
31 | 32 | $this->addArg( 'title', 'Page title' ); |
32 | 33 | } |
33 | 34 | |
34 | 35 | public function execute() { |
35 | | - $this->db = wfGetDB( DB_MASTER ); |
| 36 | + $this->db = wfGetDB( DB_SLAVE ); |
36 | 37 | |
37 | 38 | $titleText = $this->getArg( 0 ); |
38 | 39 | $title = Title::newFromText( $titleText ); |
39 | 40 | if ( !$title ) { |
40 | | - $this->error( "$titleText is not a valid title\n", true ); |
| 41 | + $this->error( "$titleText is not a valid title.\n", true ); |
41 | 42 | } |
42 | 43 | |
43 | 44 | $rev = Revision::newFromTitle( $title ); |
44 | 45 | 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 ); |
47 | 48 | } |
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 ); |
50 | 55 | } |
51 | 56 | } |
52 | 57 | |
53 | 58 | $maintClass = "GetTextMaint"; |
54 | | -require_once( DO_MAINTENANCE ); |
\ No newline at end of file |
| 59 | +require_once( DO_MAINTENANCE ); |