Swap isSpecialPage for canExist()
authorReedy <reedy@wikimedia.org>
Tue, 23 Oct 2012 21:36:32 +0000 (22:36 +0100)
committerMarius Hoch <hoo@online.de>
Tue, 23 Oct 2012 21:56:35 +0000 (23:56 +0200)
Add another check in ApiBase::getTitleOrPageId

Change-Id: I2123e3a3034cb815cf35f66f2fbf2b94fb27069f

includes/api/ApiBase.php
includes/api/ApiParse.php

index 1513e7d..1b176e7 100644 (file)
@@ -775,6 +775,9 @@ abstract class ApiBase extends ContextSource {
                        if ( !$titleObj ) {
                                $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
                        }
+                       if ( !$titleObj->canExist() ) {
+                               $this->dieUsage( "Namespace doesn't allow actual pages", 'pagecannotexist' );
+                       }
                        $pageObj = WikiPage::factory( $titleObj );
                        if ( $load !== false ) {
                                $pageObj->loadPageData( $load );
index 37cab04..fae8e69 100644 (file)
@@ -165,8 +165,8 @@ class ApiParse extends ApiBase {
                        if ( !$titleObj ) {
                                $this->dieUsageMsg( array( 'invalidtitle', $title ) );
                        }
-                       if ( $titleObj->isSpecialPage() ) {
-                               $this->dieUsage( 'Special pages cannot be parsed through action=parse', 'targetisspecial' );
+                       if ( !$titleObj->canExist() ) {
+                               $this->dieUsage( "Namespace doesn't allow actual pages", 'pagecannotexist' );
                        }
                        $wgTitle = $titleObj;
                        $pageObj = WikiPage::factory( $titleObj );
@@ -655,7 +655,7 @@ class ApiParse extends ApiBase {
                        array( 'invalidtitle', 'title' ),
                        array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
                        array( 'code' => 'notwikitext', 'info' => 'The requested operation is only supported on wikitext content.' ),
-                       array( 'code' => 'targetisspecial', 'info' => 'Special pages cannot be parsed through action=parse' ),
+                       array( 'code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages" ),
                ) );
        }