From b51720e16526b2230e1580deaacff0e4af1fb68e Mon Sep 17 00:00:00 2001 From: Alex Monk Date: Wed, 23 Nov 2016 00:47:42 +0000 Subject: [PATCH] Respect oldid parameter in NWE Change-Id: I5a6388f50cc432421343974eb9f721f5e5a94d93 --- ApiVisualEditor.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php index 648fa2263a..0ff5f49b07 100644 --- a/ApiVisualEditor.php +++ b/ApiVisualEditor.php @@ -232,9 +232,9 @@ class ApiVisualEditor extends ApiBase { } elseif ( $params['paction'] === 'wikitext' ) { $apiParams = [ 'action' => 'query', - 'titles' => $title->getPrefixedDBkey(), + 'revids' => $oldid, 'prop' => 'revisions', - 'rvprop' => 'content' + 'rvprop' => 'content|ids' ]; if ( isset( $params['section'] ) ) { @@ -252,9 +252,14 @@ class ApiVisualEditor extends ApiBase { $api->execute(); $result = $api->getResult()->getResultData(); $pid = $title->getArticleID(); - $content = isset( $result['query']['pages'][$pid]['revisions']['0']['content'] ) ? - $result['query']['pages'][$pid]['revisions']['0']['content'] : - false; + $content = false; + if ( isset( $result['query']['pages'][$pid]['revisions'] ) ) { + foreach ( $result['query']['pages'][$pid]['revisions'] as $revArr ) { + if ( $revArr['revid'] === $oldid ) { + $content = $revArr['content']; + } + } + } if ( $content === false ) { $this->dieUsage( 'Error contacting the document server', 'docserver' ); }