mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-12 01:16:19 +00:00
New error message when the page doesn't exist
The previous confusing error was coming from the getLatestRevision() call. Bug: T273068 Change-Id: I5bb53c875bb08f6fb087875a6e55fb033d182056
This commit is contained in:
parent
20a9836c73
commit
f21e6dfc7c
|
@ -98,6 +98,17 @@ class ApiDiscussionToolsEdit extends ApiBase {
|
|||
break;
|
||||
|
||||
case 'addcomment':
|
||||
$commentId = $params['commentid'] ?? null;
|
||||
|
||||
if ( !$commentId ) {
|
||||
$this->dieWithError( [ 'apierror-missingparam', 'commentid' ] );
|
||||
}
|
||||
|
||||
if ( !$title->exists() ) {
|
||||
// The page does not exist, so the comment we're trying to reply to can't exist either.
|
||||
$this->dieWithError( [ 'apierror-discussiontools-commentid-notfound', $commentId ] );
|
||||
}
|
||||
|
||||
// Fetch the latest revision
|
||||
$requestedRevision = $this->getLatestRevision( $title );
|
||||
$response = $this->requestRestbasePageHtml( $requestedRevision );
|
||||
|
@ -133,12 +144,6 @@ class ApiDiscussionToolsEdit extends ApiBase {
|
|||
$container = $doc->getElementsByTagName( 'body' )->item( 0 );
|
||||
'@phan-var DOMElement $container';
|
||||
|
||||
$commentId = $params['commentid'] ?? null;
|
||||
|
||||
if ( !$commentId ) {
|
||||
$this->dieWithError( [ 'apierror-missingparam', 'commentid' ] );
|
||||
}
|
||||
|
||||
$parser = CommentParser::newFromGlobalState( $container );
|
||||
|
||||
$comment = $parser->findCommentById( $commentId );
|
||||
|
|
Loading…
Reference in a new issue