From f921b41f152508ff44e2151dfc2c88759973de3c Mon Sep 17 00:00:00 2001 From: Reedy Date: Tue, 23 Oct 2012 22:36:32 +0100 Subject: [PATCH] Swap isSpecialPage for canExist() Add another check in ApiBase::getTitleOrPageId Change-Id: I2123e3a3034cb815cf35f66f2fbf2b94fb27069f --- includes/api/ApiBase.php | 3 +++ includes/api/ApiParse.php | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 1513e7d2d8..1b176e7f1e 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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 ); diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 37cab047d9..fae8e690b0 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -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" ), ) ); } -- 2.20.1