Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/78236


Change subject: Various small changes
......................................................................

Various small changes

* rev_parent_id is not set in new submissions
* 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 container.php
M includes/Block/Topic.php
3 files changed, 29 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/36/78236/1

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/container.php b/container.php
index 6b4bddb..85d9c0e 100644
--- a/container.php
+++ b/container.php
@@ -120,7 +120,7 @@
                'order' => 'DESC',
                'shallow' => $pk,
                'create' => function( array $row ) {
-                       return $row['rev_parent_id'] === null;
+                       return !isset( $row['rev_parent_id'] ) || 
$row['rev_parent_id'] === null;
                },
        );
        $indexes = array(
@@ -187,7 +187,7 @@
                                'shallow' => $pk,
                                'create' => function( array $row ) {
                                        // return true to create instead of 
merge index
-                                       return $row['rev_parent_id'] === null;
+                                       return !isset( $row['rev_parent_id'] ) 
|| $row['rev_parent_id'] === null;
                                },
                ) ),
                new TopKIndex( $cache, $storage, 'flow_revision:latest_post',
@@ -198,7 +198,7 @@
                                'order' => 'DESC',
                                'shallow' => $pk,
                                'create' => function( array $row ) {
-                                       return $row['rev_parent_id'] === null;
+                                       return !isset( $row['rev_parent_id'] ) 
|| $row['rev_parent_id'] === null;
                                },
                ) ),
        );
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() {

-- 
To view, visit https://gerrit.wikimedia.org/r/78236
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d64d70a81e887a850403a42bafd9d888a0fac85
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to