r89550 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89549‎ | r89550 | r89551 >
Date:09:22, 6 June 2011
Author:gurch
Status:resolved
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/api/ApiComparePages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiComparePages.php
@@ -53,7 +53,13 @@
5454 $vals['torevid'] = $rev2;
5555
5656 $difftext = $de->getDiffBody();
57 - ApiResult::setContent( $vals, $difftext );
 57+
 58+ if ( $difftext === false ) {
 59+ $this->dieUsage( 'The diff cannot be retrieved. ' .
 60+ 'Maybe one or both revisions do not exist or you do not have permission to view them.', 'baddiff' );
 61+ } else {
 62+ ApiResult::setContent( $vals, $difftext );
 63+ }
5864
5965 $this->getResult()->addValue( null, $this->getModuleName(), $vals );
6066 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r89552Followup r89550, add new error message to getPossibleErrorsreedy09:40, 6 June 2011

Status & tagging log