From: Matthew Britton Date: Mon, 6 Jun 2011 09:22:52 +0000 (+0000) Subject: ApiComparePages: Throw an error if getDiffBody returns false, instead of blank output X-Git-Tag: 1.31.0-rc.0~29677 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=3d0bc9ca1c13752264b8091d6e93edf2e338e6af;p=lhc%2Fweb%2Fwiklou.git 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. --- 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 ); }