jenkins-bot has submitted this change and it was merged.
Change subject: API: Fix action=parse without any page or title or text
......................................................................
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
---
M RELEASE-NOTES-1.22
M includes/api/ApiParse.php
2 files changed, 16 insertions(+), 3 deletions(-)
Approvals:
Anomie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22
index 52ca63f..1b434d9 100644
--- a/RELEASE-NOTES-1.22
+++ b/RELEASE-NOTES-1.22
@@ -146,6 +146,10 @@
* (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 58b46a2..ac6913e 100644
--- a/includes/api/ApiParse.php
+++ b/includes/api/ApiParse.php
@@ -171,7 +171,14 @@
$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 @@
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 @@
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',
);
}
--
To view, visit https://gerrit.wikimedia.org/r/63138
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I03c1fbcb0bd31dea8bd84e164104f7ced0ace449
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits