Merge "Respect oldid parameter in NWE"

This commit is contained in:
jenkins-bot 2016-11-23 17:55:30 +00:00 committed by Gerrit Code Review
commit f0a70ce6a2

View file

@ -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' );
}