mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-13 18:37:07 +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;
|
break;
|
||||||
|
|
||||||
case 'addcomment':
|
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
|
// Fetch the latest revision
|
||||||
$requestedRevision = $this->getLatestRevision( $title );
|
$requestedRevision = $this->getLatestRevision( $title );
|
||||||
$response = $this->requestRestbasePageHtml( $requestedRevision );
|
$response = $this->requestRestbasePageHtml( $requestedRevision );
|
||||||
|
@ -133,12 +144,6 @@ class ApiDiscussionToolsEdit extends ApiBase {
|
||||||
$container = $doc->getElementsByTagName( 'body' )->item( 0 );
|
$container = $doc->getElementsByTagName( 'body' )->item( 0 );
|
||||||
'@phan-var DOMElement $container';
|
'@phan-var DOMElement $container';
|
||||||
|
|
||||||
$commentId = $params['commentid'] ?? null;
|
|
||||||
|
|
||||||
if ( !$commentId ) {
|
|
||||||
$this->dieWithError( [ 'apierror-missingparam', 'commentid' ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
$parser = CommentParser::newFromGlobalState( $container );
|
$parser = CommentParser::newFromGlobalState( $container );
|
||||||
|
|
||||||
$comment = $parser->findCommentById( $commentId );
|
$comment = $parser->findCommentById( $commentId );
|
||||||
|
|
Loading…
Reference in a new issue