Nullzero has uploaded a new change for review. https://gerrit.wikimedia.org/r/108307
Change subject: Update documentation and suppress warning when parsing summary ...................................................................... Update documentation and suppress warning when parsing summary The documentation states that if contentmodel and title are not given, but text exists, "wikitext" will be the default model. However, the actual code will show a warning if do so. This patch fixes the inconsistence by removing some parts of the documentation which encourages giving only text as the parameter and corrects the example. The patch also suppresses the warning that contentmodel must be given when summary parameter is given. bug: 60192 Change-Id: I0f41c83763fbb5551aa3ceaff59c1f8fe38310be --- M includes/api/ApiParse.php 1 file changed, 6 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/07/108307/1 diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 464fde6..13d234c 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -186,8 +186,9 @@ } $popts = $this->makeParserOptions( $pageObj, $params ); + $textProvided = !is_null( $text ); - if ( is_null( $text ) ) { + if ( !$textProvided ) { if ( $titleProvided && ( $prop || $params['generatexml'] ) ) { $this->setWarning( "'title' used without 'text', and parsed page properties were requested " . @@ -200,7 +201,7 @@ // 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 ) ) { + if ( $textProvided && !$titleProvided && is_null( $model ) ) { $model = CONTENT_MODEL_WIKITEXT; $this->setWarning( "No 'title' or 'contentmodel' was given, assuming $model." ); } @@ -710,14 +711,13 @@ public function getParamDescription() { $p = $this->getModulePrefix(); - $wikitext = CONTENT_MODEL_WIKITEXT; return array( 'text' => "Text to parse. Use {$p}title or {$p}contentmodel to control the content model", 'summary' => 'Summary to parse', 'redirects' => "If the {$p}page or the {$p}pageid parameter is set to a redirect, resolve it", 'title' => "Title of page the text belongs to. " . - "If omitted, \"API\" is used as the title with content model $wikitext", + "If omitted, \"API\" is used as the title", 'page' => "Parse the content of this page. Cannot be used together with {$p}text and {$p}title", 'pageid' => "Parse the content of this page. Overrides {$p}page", 'oldid' => "Parse the content of this revision. Overrides {$p}page and {$p}pageid", @@ -768,7 +768,7 @@ ), 'contentmodel' => array( "Content model of the input text. Default is the model of the " . - "specified ${p}title, or $wikitext if ${p}title is not specified", + "specified ${p}title if ${p}title is specified", "Only valid when used with {$p}text", ), ); @@ -814,7 +814,7 @@ public function getExamples() { return array( 'api.php?action=parse&page=Project:Sandbox' => 'Parse a page', - 'api.php?action=parse&text={{Project:Sandbox}}' => 'Parse wikitext', + 'api.php?action=parse&text={{Project:Sandbox}}&contentmodel=wikitext' => 'Parse wikitext', 'api.php?action=parse&text={{PAGENAME}}&title=Test' => 'Parse wikitext, specifying the page title', 'api.php?action=parse&summary=Some+[[link]]&prop=' => 'Parse a summary', -- To view, visit https://gerrit.wikimedia.org/r/108307 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0f41c83763fbb5551aa3ceaff59c1f8fe38310be Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Nullzero <nullzero.f...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits