jenkins-bot has submitted this change and it was merged.
Change subject: Only roundtrip through parsoid for wikitext when necessary
......................................................................
Only roundtrip through parsoid for wikitext when necessary
Change-Id: I22597de676965d3fdf927ae3a04bbe3fb44b42ab
---
M includes/Block/Topic.php
M includes/Model/AbstractRevision.php
2 files changed, 15 insertions(+), 4 deletions(-)
Approvals:
Matthias Mullie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 0f63637..8a40d3a 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -350,7 +350,7 @@
$templating->getOutput()->addModules( array(
'ext.flow.history' ) );
} else {
$templating->getOutput()->addModuleStyles( array(
'ext.flow.discussion', 'ext.flow.moderation' ) );
- $templating->getOutput()->addModules( array(
'ext.flow.discussion' ) );
+ $templating->getOutput()->addModules( array(
'ext.flow.discussion' ) );
}
$prefix = '';
@@ -640,8 +640,11 @@
$output = array();
$output['post-id'] = $post->getPostId()->getHex();
- $contentFormat = 'wikitext';
+ $contentFormat = $post->getContentFormat();
+ // This may force a round trip through parsoid for the wikitext
when
+ // posts are stored as html, as such it should only be used when
+ // actually needed
if ( isset( $options['contentFormat'] ) ) {
$contentFormat = $options['contentFormat'];
}
diff --git a/includes/Model/AbstractRevision.php
b/includes/Model/AbstractRevision.php
index 014fb34..64a9c63 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -285,11 +285,12 @@
return '';
}
$raw = $this->getContentRaw();
- $sourceFormat = in_array( 'html', $this->flags ) ? 'html' :
'wikitext';
+ $sourceFormat = $this->getContentFormat();
if ( $this->xssCheck === null && $sourceFormat === 'html' ) {
// returns true if no handler aborted the hook
$this->xssCheck = wfRunHooks(
'FlowCheckHtmlContentXss', array( $raw ) );
if ( !$this->xssCheck ) {
+ wfDebugLog( __CLASS__, __FUNCTION__ . ': XSS
check prevented display of revision ' . $this->revId->getHex() );
return '';
}
}
@@ -298,7 +299,6 @@
return $raw;
}
if ( !isset( $this->convertedContent[$format] ) ) {
- // convert to requested format
$this->convertedContent[$format] =
ParsoidUtils::convert( $sourceFormat, $format, $raw );
}
@@ -388,9 +388,17 @@
}
/**
+ * @return string The content format of this revision
+ */
+ public function getContentFormat() {
+ return in_array( 'html', $this->flags ) ? 'html' : 'wikitext';
+ }
+
+ /**
* Determines the appropriate format to store content in.
* Usually, the default storage format, but if isFormatted() returns
* false, then it will return 'wikitext'.
+ * NOTE: The format of the current content is retrieved with
getContentFormat
* @return string The name of the storage format.
*/
protected function getStorageFormat() {
--
To view, visit https://gerrit.wikimedia.org/r/101120
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I22597de676965d3fdf927ae3a04bbe3fb44b42ab
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits