Add check for page existence
[lhc/web/wiklou.git] / maintenance / view.php
index 24b5007..81c3f3e 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\Revision\RevisionRecord;
+
 require_once __DIR__ . '/Maintenance.php';
 
 /**
@@ -36,14 +38,18 @@ class ViewCLI extends Maintenance {
        }
 
        public function execute() {
-               $title = Title::newFromText( $this->getArg() );
+               $title = Title::newFromText( $this->getArg( 0 ) );
                if ( !$title ) {
                        $this->fatalError( "Invalid title" );
+               } elseif ( $title->isSpecialPage() ) {
+                       $this->fatalError( "Special Pages not supported" );
+               } elseif ( !$title->exists() ) {
+                       $this->fatalError( "Page does not exist" );
                }
 
                $page = WikiPage::factory( $title );
 
-               $content = $page->getContent( Revision::RAW );
+               $content = $page->getContent( RevisionRecord::RAW );
                if ( !$content ) {
                        $this->fatalError( "Page has no content" );
                }