From: Brad Jorsch Date: Fri, 10 May 2013 15:59:11 +0000 (-0400) Subject: API: Fix action=parse without any page or title or text X-Git-Tag: 1.31.0-rc.0~19426 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=484770e8d2f8f768f07917a2ede1dbe0aba3ddf5;p=lhc%2Fweb%2Fwiklou.git API: Fix action=parse without any page or title or text action=parse was raising an error about missing 'text' with 'title' even when 'title' wasn't actually passed, due to a fix for bug 33865. But this broke using action=parse to parse an edit summary without also giving it wikitext to parse. Instead, let's give the client a warning (unless it seems clear they know what they are doing) and assume the empty string for 'text'. Also, while we're editing the file, add some more examples as also requested in bug 48319. Bug: 48319 Change-Id: I03c1fbcb0bd31dea8bd84e164104f7ced0ace449 --- diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 52ca63f86c..1b434d9d1e 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -146,6 +146,10 @@ production. * (bug 14176) System messages that are empty were previously incorrectly treated as non-existent, causing a fallback to the default. This stopped users from overriding system messages to make them blank. +* (bug 48319) action=parse no longer returns an error if passed none of 'oldid', + 'pageid', 'page', 'title', and 'text' (e.g. if only passed 'summary'). A + warning will instead be issued if 'title' is non-default, unless no props are + requested. === API changes in 1.22 === * (bug 46626) xmldoublequote parameter was removed. Because of a bug, the diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 58b46a2c3c..ac6913eb46 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -171,7 +171,14 @@ class ApiParse extends ApiBase { $popts = $this->makeParserOptions( $pageObj, $params ); if ( is_null( $text ) ) { - $this->dieUsage( 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?', 'params' ); + if ( $title !== 'API' && ( $prop || $params['generatexml'] ) ) { + $this->setWarning( + "'title' used without 'text', and parsed page properties were requested " . + "(did you mean to use 'page' instead of 'title'?)" + ); + } + // Prevent warning from ContentHandler::makeContent() + $text = ''; } try { @@ -685,7 +692,6 @@ class ApiParse extends ApiBase { public function getPossibleErrors() { return array_merge( parent::getPossibleErrors(), array( array( 'code' => 'params', 'info' => 'The page parameter cannot be used together with the text and title parameters' ), - array( 'code' => 'params', 'info' => 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?' ), array( 'code' => 'missingrev', 'info' => 'There is no revision ID oldid' ), array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revisions' ), array( 'code' => 'missingtitle', 'info' => 'The page you specified doesn\'t exist' ), @@ -700,7 +706,10 @@ class ApiParse extends ApiBase { public function getExamples() { return array( - 'api.php?action=parse&text={{Project:Sandbox}}' + 'api.php?action=parse&page=Project:Sandbox' => 'Parse a page', + 'api.php?action=parse&text={{Project:Sandbox}}' => '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', ); }