From: umherirrender Date: Fri, 1 Mar 2013 15:01:26 +0000 (+0100) Subject: API: Throw error when interwiki is given for various title param X-Git-Tag: 1.31.0-rc.0~20525^2 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=5880f89707793c30c402cfe3439412349d2de9f2;p=lhc%2Fweb%2Fwiklou.git API: Throw error when interwiki is given for various title param See bug 44341 for action=parse, but the problem with interwiki processing can also be happen in other modules. This gives clearer error message on some modules For example action=move: Bad title "*title*" instead of: Unknown error: "immobile-target-namespace-iw" Change-Id: I86524533dfd778a169b39968999918a1f531efeb --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index aff7a2ecbc..d90ea264ed 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -756,7 +756,7 @@ abstract class ApiBase extends ContextSource { $pageObj = null; if ( isset( $params['title'] ) ) { $titleObj = Title::newFromText( $params['title'] ); - if ( !$titleObj ) { + if ( !$titleObj || $titleObj->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } if ( !$titleObj->canExist() ) { diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php index 6b894c17f1..79ffcb0adf 100644 --- a/includes/api/ApiComparePages.php +++ b/includes/api/ApiComparePages.php @@ -85,7 +85,7 @@ class ApiComparePages extends ApiBase { return $revision; } elseif( $titleText ) { $title = Title::newFromText( $titleText ); - if( !$title ) { + if( !$title || $title->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $titleText ) ); } return $title->getLatestRevID(); diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index b642c6de00..1b9df68e1f 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -46,10 +46,6 @@ class ApiEditPage extends ApiBase { $pageObj = $this->getTitleOrPageId( $params ); $titleObj = $pageObj->getTitle(); - if ( $titleObj->isExternal() ) { - $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); - } - $apiResult = $this->getResult(); if ( $params['redirect'] ) { diff --git a/includes/api/ApiExpandTemplates.php b/includes/api/ApiExpandTemplates.php index 826171b46f..f5898fb34b 100644 --- a/includes/api/ApiExpandTemplates.php +++ b/includes/api/ApiExpandTemplates.php @@ -42,7 +42,7 @@ class ApiExpandTemplates extends ApiBase { // Create title for parser $title_obj = Title::newFromText( $params['title'] ); - if ( !$title_obj ) { + if ( !$title_obj || $title_obj->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 3f54fee428..ba1d6c9a71 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -38,7 +38,7 @@ class ApiMove extends ApiBase { if ( isset( $params['from'] ) ) { $fromTitle = Title::newFromText( $params['from'] ); - if ( !$fromTitle ) { + if ( !$fromTitle || $fromTitle->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['from'] ) ); } } elseif ( isset( $params['fromid'] ) ) { @@ -54,7 +54,7 @@ class ApiMove extends ApiBase { $fromTalk = $fromTitle->getTalkPage(); $toTitle = Title::newFromText( $params['to'] ); - if ( !$toTitle ) { + if ( !$toTitle || $toTitle->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['to'] ) ); } $toTalk = $toTitle->getTalkPage(); diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index b81e5c777e..ec8bfee0a0 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -161,7 +161,7 @@ class ApiParse extends ApiBase { } } else { // Not $oldid, $pageid, $page. Hence based on $text $titleObj = Title::newFromText( $title ); - if ( !$titleObj ) { + if ( !$titleObj || $titleObj->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $title ) ); } if ( !$titleObj->canExist() ) { diff --git a/includes/api/ApiQueryAllMessages.php b/includes/api/ApiQueryAllMessages.php index 6b6b1a36b6..b0ecca856a 100644 --- a/includes/api/ApiQueryAllMessages.php +++ b/includes/api/ApiQueryAllMessages.php @@ -48,7 +48,7 @@ class ApiQueryAllMessages extends ApiQueryBase { if ( $params['enableparser'] ) { if ( !is_null( $params['title'] ) ) { $title = Title::newFromText( $params['title'] ); - if ( !$title ) { + if ( !$title || $title->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } } else { diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index 6e55a5eef1..b9873f49ce 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -181,7 +181,7 @@ class ApiRollback extends ApiBase { $this->mTitleObj = Title::newFromText( $params['title'] ); - if ( !$this->mTitleObj ) { + if ( !$this->mTitleObj || $this->mTitleObj->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } if ( !$this->mTitleObj->exists() ) { diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index f53f065a1b..4bbe568d0b 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -41,7 +41,7 @@ class ApiUndelete extends ApiBase { } $titleObj = Title::newFromText( $params['title'] ); - if ( !$titleObj ) { + if ( !$titleObj || $titleObj->isExternal() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 2454e3373b..7106b06626 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -40,7 +40,7 @@ class ApiWatch extends ApiBase { $params = $this->extractRequestParams(); $title = Title::newFromText( $params['title'] ); - if ( !$title || $title->getNamespace() < 0 ) { + if ( !$title || $title->isExternal() || !$title->canExist() ) { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); }