From: Daniel Cannon Date: Tue, 27 Nov 2007 20:37:26 +0000 (+0000) Subject: API: difftoprev fails when 'rvprop=ids' is not specified. Sort of gross way to fix... X-Git-Tag: 1.31.0-rc.0~50700 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=05fec7e664cd41a2612090b23a6b53a4c1d2e2c1;p=lhc%2Fweb%2Fwiklou.git API: difftoprev fails when 'rvprop=ids' is not specified. Sort of gross way to fix the problem, but it works. --- diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php index 70747c6621..51191d494e 100644 --- a/includes/api/ApiQueryRevisions.php +++ b/includes/api/ApiQueryRevisions.php @@ -258,10 +258,15 @@ class ApiQueryRevisions extends ApiQueryBase { $previousRevID = $revid; $oldText = $newText; } - // Now that $this->diffArr is filled with diffprev elements, add them to the result - foreach($data['query']['pages'][$pageID]['revisions'] as &$rev) - if(isset($diffArr[$rev['revid']])) - $rev['difftoprev'] = $diffArr[$rev['revid']]; + + # Populate the query result with the contents of $diffArr. + $knownrevs = array_keys($diffArr); + $i = count($knownrevs) - 1; + foreach($data['query']['pages'][$pageID]['revisions'] as &$rev) { + if ( $i >= 0 && isset ( $diffArr[$knownrevs[$i]] ) ) + $rev['difftoprev'] = $diffArr[$knownrevs[$i]]; + $i --; + } } // Ensure that all revisions are shown as '' elements