Swap isSpecialPage for canExist()

Add another check in ApiBase::getTitleOrPageId

Change-Id: I2123e3a3034cb815cf35f66f2fbf2b94fb27069f
This commit is contained in:
Reedy 2012-10-23 22:36:32 +01:00 committed by Marius Hoch
parent f39292c10b
commit f921b41f15
2 changed files with 6 additions and 3 deletions

View 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 );

View 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" ),
) );
}