From 05fec7e664cd41a2612090b23a6b53a4c1d2e2c1 Mon Sep 17 00:00:00 2001 From: Daniel Cannon Date: Tue, 27 Nov 2007 20:37:26 +0000 Subject: [PATCH] API: difftoprev fails when 'rvprop=ids' is not specified. Sort of gross way to fix the problem, but it works. --- includes/api/ApiQueryRevisions.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 -- 2.20.1