Merge "Use Parsoid API for action=parsefragment"

This commit is contained in:
jenkins-bot 2014-04-19 00:13:43 +00:00 committed by Gerrit Code Review
commit b657f37795

View file

@ -161,6 +161,15 @@ class ApiVisualEditor extends ApiBase {
);
}
protected function parseWikitextFragment( $title, $wikitext ) {
return $this->requestParsoid( 'POST', $title,
array(
'wt' => $wikitext,
'body' => 1,
)
);
}
protected function parseWikitext( $title ) {
$apiParams = array(
'action' => 'parse',
@ -197,29 +206,6 @@ class ApiVisualEditor extends ApiBase {
);
}
protected function parseWikitextFragment( $wikitext, $title = null ) {
$apiParams = array(
'action' => 'parse',
'title' => $title,
'prop' => 'text',
'disablepp' => true,
'pst' => true,
'text' => $wikitext
);
$api = new ApiMain(
new DerivativeRequest(
$this->getRequest(),
$apiParams,
false // was posted?
),
true // enable write?
);
$api->execute();
$result = $api->getResultData();
return isset( $result['parse']['text']['*'] ) ? $result['parse']['text']['*'] : false;
}
protected function diffWikitext( $title, $wikitext ) {
$apiParams = array(
'action' => 'query',
@ -426,9 +412,9 @@ class ApiVisualEditor extends ApiBase {
break;
case 'parsefragment':
$content = $this->parseWikitextFragment( $params['wikitext'], $page->getText() );
$content = $this->parseWikitextFragment( $page, $params['wikitext'] );
if ( $content === false ) {
$this->dieUsage( 'Error querying MediaWiki API', 'parsoidserver' );
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
} else {
$result = array(
'result' => 'success',