Merge "Fix duplicate wikitext parse for displaytitle"

This commit is contained in:
jenkins-bot 2014-12-09 22:54:37 +00:00 committed by Gerrit Code Review
commit 54b938e629
2 changed files with 11 additions and 11 deletions

View file

@ -186,7 +186,7 @@ class ApiVisualEditor extends ApiBase {
$apiParams = array( $apiParams = array(
'action' => 'parse', 'action' => 'parse',
'page' => $title->getPrefixedDBkey(), 'page' => $title->getPrefixedDBkey(),
'prop' => 'text|revid|categorieshtml', 'prop' => 'text|revid|categorieshtml|displaytitle',
); );
$api = new ApiMain( $api = new ApiMain(
new DerivativeRequest( new DerivativeRequest(
@ -205,16 +205,25 @@ class ApiVisualEditor extends ApiBase {
$links = isset( $result['parse']['links'] ) ? $result['parse']['links'] : array(); $links = isset( $result['parse']['links'] ) ? $result['parse']['links'] : array();
$revision = Revision::newFromId( $result['parse']['revid'] ); $revision = Revision::newFromId( $result['parse']['revid'] );
$timestamp = $revision ? $revision->getTimestamp() : wfTimestampNow(); $timestamp = $revision ? $revision->getTimestamp() : wfTimestampNow();
$displaytitle = isset( $result['parse']['displaytitle'] ) ?
$result['parse']['displaytitle'] : false;
if ( $content === false || ( strlen( $content ) && $revision === null ) ) { if ( $content === false || ( strlen( $content ) && $revision === null ) ) {
return false; return false;
} }
if ( $displaytitle !== false ) {
// Escape entities as in OutputPage::setPageTitle()
$displaytitle = Sanitizer::normalizeCharReferences(
Sanitizer::removeHTMLtags( $displaytitle ) );
}
return array( return array(
'content' => $content, 'content' => $content,
'categorieshtml' => $categorieshtml, 'categorieshtml' => $categorieshtml,
'basetimestamp' => $timestamp, 'basetimestamp' => $timestamp,
'starttimestamp' => wfTimestampNow() 'starttimestamp' => wfTimestampNow(),
'displayTitleHtml' => $displaytitle
); );
} }

View file

@ -147,15 +147,6 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
$view->displayTag(); $view->displayTag();
} }
$result['contentSub'] = $this->getOutput()->getSubtitle(); $result['contentSub'] = $this->getOutput()->getSubtitle();
$content = new WikitextContent( $wikitext );
$parserOutput = $content->getParserOutput( $page );
if ( $parserOutput ) {
$result['displayTitleHtml'] = $parserOutput->getDisplayTitle();
} else {
wfDebug( '[VE] ApiVisualEditorEdit - parserOutput was false' );
}
$lang = $this->getLanguage(); $lang = $this->getLanguage();
if ( isset( $saveresult['edit']['newtimestamp'] ) ) { if ( isset( $saveresult['edit']['newtimestamp'] ) ) {