summaryrefslogtreecommitdiff
path: root/includes/api/ApiComparePages.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiComparePages.php')
-rw-r--r--includes/api/ApiComparePages.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php
index ed72b29b..79ffcb0a 100644
--- a/includes/api/ApiComparePages.php
+++ b/includes/api/ApiComparePages.php
@@ -25,17 +25,21 @@
class ApiComparePages extends ApiBase {
- public function __construct( $main, $action ) {
- parent::__construct( $main, $action );
- }
-
public function execute() {
$params = $this->extractRequestParams();
$rev1 = $this->revisionOrTitleOrId( $params['fromrev'], $params['fromtitle'], $params['fromid'] );
$rev2 = $this->revisionOrTitleOrId( $params['torev'], $params['totitle'], $params['toid'] );
- $de = new DifferenceEngine( $this->getContext(),
+ $revision = Revision::newFromId( $rev1 );
+
+ if ( !$revision ) {
+ $this->dieUsage( 'The diff cannot be retrieved, ' .
+ 'one revision does not exist or you do not have permission to view it.', 'baddiff' );
+ }
+
+ $contentHandler = $revision->getContentHandler();
+ $de = $contentHandler->createDifferenceEngine( $this->getContext(),
$rev1,
$rev2,
null, // rcid
@@ -77,11 +81,11 @@ class ApiComparePages extends ApiBase {
* @return int
*/
private function revisionOrTitleOrId( $revision, $titleText, $titleId ) {
- if( $revision ){
+ if( $revision ) {
return $revision;
} elseif( $titleText ) {
$title = Title::newFromText( $titleText );
- if( !$title ){
+ if( !$title || $title->isExternal() ) {
$this->dieUsageMsg( array( 'invalidtitle', $titleText ) );
}
return $title->getLatestRevID();
@@ -164,8 +168,4 @@ class ApiComparePages extends ApiBase {
'api.php?action=compare&fromrev=1&torev=2' => 'Create a diff between revision 1 and 2',
);
}
-
- public function getVersion() {
- return __CLASS__ . ': $Id$';
- }
}