From 3d0bc9ca1c13752264b8091d6e93edf2e338e6af Mon Sep 17 00:00:00 2001 From: Matthew Britton Date: Mon, 6 Jun 2011 09:22:52 +0000 Subject: [PATCH] ApiComparePages: Throw an error if getDiffBody returns false, instead of blank output This lets the client distinguish a legitimately blank diff (identical revisions) from one that does not exist or which they do not have permission to view. getDiffBody doesn't tell the caller why it failed, so there may be a better way to do this. --- includes/api/ApiComparePages.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/api/ApiComparePages.php b/includes/api/ApiComparePages.php index 43d3d1f972..38fce50bd4 100644 --- a/includes/api/ApiComparePages.php +++ b/includes/api/ApiComparePages.php @@ -53,7 +53,13 @@ class ApiComparePages extends ApiBase { $vals['torevid'] = $rev2; $difftext = $de->getDiffBody(); - ApiResult::setContent( $vals, $difftext ); + + if ( $difftext === false ) { + $this->dieUsage( 'The diff cannot be retrieved. ' . + 'Maybe one or both revisions do not exist or you do not have permission to view them.', 'baddiff' ); + } else { + ApiResult::setContent( $vals, $difftext ); + } $this->getResult()->addValue( null, $this->getModuleName(), $vals ); } -- 2.20.1