Merge "RevertedPresentationModel: Don't double-parse summary"

This commit is contained in:
jenkins-bot 2016-03-30 20:29:34 +00:00 committed by Gerrit Code Review
commit 6e8e68d6ba
2 changed files with 17 additions and 7 deletions

View file

@ -826,8 +826,7 @@ abstract class EchoDiscussionParser {
}
/**
* This function returns plain text snippet, it also removes html tag,
* template from text content
* Parse wikitext into truncated plain text.
* @param $text string
* @param Language $lang
* @param $length int default 150
@ -840,4 +839,19 @@ abstract class EchoDiscussionParser {
$plaintext = trim( html_entity_decode( strip_tags( $html ), ENT_QUOTES ) );
return $lang->truncate( $plaintext, $length );
}
/**
* Parse an edit summary into truncated plain text.
* @param $text string
* @param Language $lang
* @param $length int default 150
* @return string
*/
static function getTextSnippetFromSummary( $text, Language $lang, $length = 150 ) {
// Parse wikitext with summary parser
$html = Linker::formatLinksInComment( Sanitizer::escapeHtmlAllowEntities( $text ) );
// Remove HTML tags and decode HTML entities
$plaintext = trim( html_entity_decode( strip_tags( $html ), ENT_QUOTES ) );
return $lang->truncate( $plaintext, $length );
}
}

View file

@ -29,11 +29,7 @@ class EchoRevertedPresentationModel extends EchoEventPresentationModel {
}
private function formatSummary( $wikitext ) {
$html = Linker::formatLinksInComment( Sanitizer::escapeHtmlAllowEntities( $wikitext ) );
return EchoDiscussionParser::getTextSnippet(
$html,
$this->language
);
return EchoDiscussionParser::getTextSnippetFromSummary( $wikitext, $this->language );
}
public function getPrimaryLink() {