Add check for page existence
authorAmmar Abdulhamid <ammarpad@yahoo.com>
Mon, 9 Mar 2020 08:57:43 +0000 (09:57 +0100)
committerReedy <reedy@wikimedia.org>
Mon, 9 Mar 2020 15:30:43 +0000 (15:30 +0000)
Currently even if the page does not exist at all this script just says
"there's no content" which is partially true. If the page does exist but with
no content and/or blank the same answer is also given, which is OK in that case
but less so in the former case.

Also handle special pages instead of throwing exception.

Change-Id: Ia15b336d989d3605ead1891e3396380e8e6d4347

maintenance/view.php

index 8683eed..81c3f3e 100644 (file)
@@ -41,6 +41,10 @@ class ViewCLI extends Maintenance {
                $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 );