Matthias Mullie has uploaded a new change for review.

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

Change subject: Fix submission of new topics in no-js
......................................................................

Fix submission of new topics in no-js

A workflow id is currently passed in the URL. The workflow is new still, though.
The discussion workflow is not actually created until the new post is submitted.
When attempting to submit the new topic without JS, the workflow ID in the url
will be loaded (or rather, tried to) which will fail since it doesn't yet exist.

JS was already doing this correctly, not passing a workflow id if
$workflow->isNew()

Change-Id: If2324f1ddbaeaa8d83257c70b987088186279e2e
---
M includes/BaseUrlGenerator.php
M includes/UrlGenerator.php
M templates/topiclist.html.php
3 files changed, 11 insertions(+), 9 deletions(-)


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

diff --git a/includes/BaseUrlGenerator.php b/includes/BaseUrlGenerator.php
index 9305408..8fc6c4b 100644
--- a/includes/BaseUrlGenerator.php
+++ b/includes/BaseUrlGenerator.php
@@ -151,11 +151,11 @@
 
        /**
         * @param Title|null $title
-        * @param UUID $workflowId
+        * @param UUID|null $workflowId
         * @return Title
         * @throws FlowException
         */
-       protected function resolveTitle( Title $title = null, UUID $workflowId 
) {
+       protected function resolveTitle( Title $title = null, UUID $workflowId 
= null ) {
                if ( $title ) {
                        return $title;
                }
diff --git a/includes/UrlGenerator.php b/includes/UrlGenerator.php
index 9686d51..7c65eda 100644
--- a/includes/UrlGenerator.php
+++ b/includes/UrlGenerator.php
@@ -37,17 +37,19 @@
         * Link to create new topic on a topiclist.
         *
         * @param Title|null $title
-        * @param UUID $workflowId
+        * @param UUID|null $workflowId
         * @return Anchor
         */
-       public function newTopicLink( Title $title = null, UUID $workflowId ) {
+       public function newTopicLink( Title $title = null, UUID $workflowId = 
null ) {
+               $query = array( 'action' => 'new-topic' );
+               if ( $workflowId ) {
+                       $query['workflow'] = $workflowId->getAlphadecimal();
+               }
+
                return new Anchor(
                        wfMessage( 'flow-topic-action-new' ),
                        $this->resolveTitle( $title, $workflowId ),
-                       array(
-                               'workflow' => $workflowId->getAlphadecimal(),
-                               'action' => 'new-topic',
-                       )
+                       $query
                );
        }
 
diff --git a/templates/topiclist.html.php b/templates/topiclist.html.php
index 19cfd8d..eaf429b 100644
--- a/templates/topiclist.html.php
+++ b/templates/topiclist.html.php
@@ -7,7 +7,7 @@
                'method' => 'POST',
                'action' => $this->urlGenerator->newTopicLink(
                        $workflow->getArticleTitle(),
-                       $workflow->getId()
+                       $workflow->isNew() ? null : $workflow->getId()
                )->getFullUrl(),
                'class' => 'flow-newtopic-form',
                'id' => 'flow-newtopic-form',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2324f1ddbaeaa8d83257c70b987088186279e2e
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