From: Niklas Laxström Date: Wed, 19 Jun 2013 10:21:19 +0000 (+0000) Subject: Restore API action=parse&text=foo functionality on wikidata.org X-Git-Tag: 1.31.0-rc.0~19399 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=1104392eba1b7701582054fed11d353868614d62;p=lhc%2Fweb%2Fwiklou.git Restore API action=parse&text=foo functionality on wikidata.org Bug: 48201 Change-Id: Ie4f7324c2a10700e52dadc4facd6b4fe6c76cf48 --- diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index ac6913eb46..89928fe389 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -44,6 +44,14 @@ class ApiParse extends ApiBase { $params = $this->extractRequestParams(); $text = $params['text']; $title = $params['title']; + if ( $title === '' ) { + $titleProvided = false; + // This is the old default value + $title = 'API'; + } else { + $titleProvided = true; + } + $page = $params['page']; $pageid = $params['pageid']; $oldid = $params['oldid']; @@ -51,7 +59,7 @@ class ApiParse extends ApiBase { $model = $params['contentmodel']; $format = $params['contentformat']; - if ( !is_null( $page ) && ( !is_null( $text ) || $title != 'API' ) ) { + if ( !is_null( $page ) && ( !is_null( $text ) || $titleProvided ) ) { $this->dieUsage( 'The page parameter cannot be used together with the text and title parameters', 'params' ); } @@ -171,7 +179,7 @@ class ApiParse extends ApiBase { $popts = $this->makeParserOptions( $pageObj, $params ); if ( is_null( $text ) ) { - if ( $title !== 'API' && ( $prop || $params['generatexml'] ) ) { + if ( $titleProvided && ( $prop || $params['generatexml'] ) ) { $this->setWarning( "'title' used without 'text', and parsed page properties were requested " . "(did you mean to use 'page' instead of 'title'?)" @@ -181,6 +189,16 @@ class ApiParse extends ApiBase { $text = ''; } + // If we are parsing text, do not use the content model of the default + // API title, but default to wikitext to keep BC. + if ( !$titleProvided && is_null( $model ) ) { + $model = CONTENT_MODEL_WIKITEXT; + $this->setWarning( + "Please set content model with contentmodel parameter. " . + "Assuming it is $model." + ); + } + try { $this->content = ContentHandler::makeContent( $text, $titleObj, $model, $format ); } catch ( MWContentSerializationException $ex ) { @@ -576,7 +594,7 @@ class ApiParse extends ApiBase { public function getAllowedParams() { return array( 'title' => array( - ApiBase::PARAM_DFLT => 'API', + ApiBase::PARAM_DFLT => '', ), 'text' => null, 'summary' => null,