EBernhardson (WMF) has submitted this change and it was merged. Change subject: Various small changes ......................................................................
Various small changes * Compacter kicks in too early, potentially stripping columns (in this case: rev_parent_id) that are used for the callback to check if index needs to be created or merged. Compact later, when saving to cache. * I didn't manage to get Parsoid's _wikitext test form running, but wikitext to HTML doesn't even need Parsoid; MW parser can do that (and unless the HTML to wikitext conversion will also be needed, we should probably not add a dependency on Parsoid) Change-Id: I2d64d70a81e887a850403a42bafd9d888a0fac85 --- M Flow.php M includes/Block/Topic.php M includes/Data/ObjectManager.php 3 files changed, 37 insertions(+), 16 deletions(-) Approvals: EBernhardson (WMF): Verified; Looks good to me, approved diff --git a/Flow.php b/Flow.php index 182b860..b55e54e 100755 --- a/Flow.php +++ b/Flow.php @@ -157,6 +157,7 @@ // use this workflow $wgFlowDefaultWorkflow = 'discussion'; +$wgFlowUseParsoid = false; $wgFlowParsoidURL = 'http://localhost:8000'; $wgFlowParsoidPrefix = '_wikitext'; $wgFlowParsoidTimeout = 100; diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php index 5b377bc..3599ce0 100644 --- a/includes/Block/Topic.php +++ b/includes/Block/Topic.php @@ -133,20 +133,34 @@ } } + // @todo: I assume not only topic reply, but also TopicListBlock & SummaryBlock's content need to be converted? protected function convertWikitextToHtml5( $wikitext ) { - global $wgFlowParsoidURL, $wgFlowParsoidPrefix, $wgFlowParsoidTimeout; + global $wgFlowUseParsoid; - return \Http::post( - $wgFlowParsoidURL . '/' . $wgFlowParsoidPrefix . '/', - array( - 'postData' => array( - 'content' => $wikitext, - 'format' => 'html', - ), - 'timeout' => $wgFlowParsoidTimeout - ) - ); + if ( $wgFlowUseParsoid ) { + global $wgFlowParsoidURL, $wgFlowParsoidPrefix, $wgFlowParsoidTimeout; + return \Http::post( + $wgFlowParsoidURL . '/' . $wgFlowParsoidPrefix . '/', + array( + 'postData' => array( + 'content' => $wikitext, + 'format' => 'html', + ), + 'timeout' => $wgFlowParsoidTimeout + ) + ); + } else { + global $wgParser; + + $title = \Title::newFromText( 'Flow', NS_SPECIAL ); + + $options = new \ParserOptions; + $options->setTidy( true ); + + $output = $wgParser->parse( $wikitext, $title, $options ); + return $output->getText(); + } } public function commit() { diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php index 8a26128..08657a7 100644 --- a/includes/Data/ObjectManager.php +++ b/includes/Data/ObjectManager.php @@ -649,7 +649,7 @@ if ( !$indexed ) { throw new \MWException( 'Unindexable row: ' .json_encode( $new ) ); } - $this->addToIndex( $indexed, $this->rowCompactor->compactRow( $new ) ); + $this->addToIndex( $indexed, $new ); } public function onAfterUpdate( $object, array $old, array $new ) { @@ -664,8 +664,8 @@ if ( !$newIndexed ) { throw new \MWException( 'Unindexable row: ' .json_encode( $newIndexed ) ); } - $this->removeFromIndex( $oldIndexed, $this->rowCompactor->compactRow( $old ) ); - $this->addToIndex( $newIndexed, $this->rowCompactor->compactRow( $new ) ); + $this->removeFromIndex( $oldIndexed, $old ); + $this->addToIndex( $newIndexed, $new ); } public function onAfterRemove( $object, array $old ) { @@ -673,7 +673,7 @@ if ( !$indexed ) { throw new \MWException( 'Unindexable row: ' .json_encode( $old ) ); } - $this->removeFromIndex( $indexed, $this->rowCompactor->compactRow( $old ) ); + $this->removeFromIndex( $indexed, $old ); } public function onAfterLoad( $object, array $old ) { @@ -792,6 +792,7 @@ } protected function addToIndex( array $indexed, array $row ) { + $row = $this->rowCompactor->compactRow( $row ); $this->cache->set( $this->cacheKey( $indexed ), array( $row ) ); } @@ -831,8 +832,11 @@ } protected function addToIndex( array $indexed, array $row ) { + $create = call_user_func( $this->options['create'], $indexed + $row ); + + $row = $this->rowCompactor->compactRow( $row ); $cacheKey = $this->cacheKey( $indexed ); - if ( call_user_func( $this->options['create'], $indexed + $row ) ) { + if ( $create ) { $this->cache->set( $cacheKey, array( $row ) ); return; } @@ -857,6 +861,8 @@ } protected function removeFromIndex( array $indexed, array $row ) { + $row = $this->rowCompactor->compactRow( $row ); + $this->cache->merge( $this->cacheKey( $indexed ), function( BagOStuff $cache, $key, $value ) use( $row ) { -- To view, visit https://gerrit.wikimedia.org/r/78236 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2d64d70a81e887a850403a42bafd9d888a0fac85 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: EBernhardson (WMF) <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits