- $title_obj = $rev->getTitle();
- } else {
- $title_obj = Title::newFromText( $params['title'] );
- if ( !$title_obj || $title_obj->isExternal() ) {
- $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $params['title'] ) ] );
+ $pTitleObj = $titleObj;
+ $titleObj = $rev->getTitle();
+ if ( $titleProvided ) {
+ if ( !$titleObj->equals( $pTitleObj ) ) {
+ $this->addWarning( [ 'apierror-revwrongpage', $rev->getId(),
+ wfEscapeWikiText( $pTitleObj->getPrefixedText() ) ] );
+ }
+ } else {
+ // Consider the title derived from the revid as having
+ // been provided.
+ $titleProvided = true;