jenkins-bot has submitted this change and it was merged.
Change subject: Post topic without comment
......................................................................
Post topic without comment
Allows creation of new topic without creating a related first post
Change-Id: I6b37cb130bff14d94303f545d38fe1676776ff02
---
M includes/Block/TopicList.php
M includes/Notifications/Controller.php
M modules/discussion/forms.js
3 files changed, 24 insertions(+), 23 deletions(-)
Approvals:
Matthias Mullie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Block/TopicList.php b/includes/Block/TopicList.php
index 75fe251..7285d3c 100644
--- a/includes/Block/TopicList.php
+++ b/includes/Block/TopicList.php
@@ -35,9 +35,6 @@
if ( !isset( $this->submitted['topic'] ) ) {
$this->errors['topic'] = wfMessage(
'flow-error-missing-title' );
}
- if ( !isset( $this->submitted['content'] ) ) {
- $this->errors['content'] = wfMessage(
'flow-error-missing-content' );
- }
}
public function commit() {
@@ -57,15 +54,22 @@
// Should we really have a top level post for the topic title?
Simplifies allowing
// a revisioned title.
$topicPost = PostRevision::create( $topicWorkflow,
$this->submitted['topic'] );
- $firstPost = $topicPost->reply( $this->user,
$this->submitted['content'] );
+ $topicChildren = array();
+ $firstPost = null;
+ if ( !empty( $this->submitted['content'] ) ) {
+ $firstPost = $topicPost->reply( $this->user,
$this->submitted['content'] );
+ $firstPost->setChildren( array() );
+ $topicChildren[] = $firstPost;
+ }
$topicListEntry = TopicListEntry::create( $this->workflow,
$topicWorkflow );
- $topicPost->setChildren( array( $firstPost ) );
- $firstPost->setChildren( array() );
+ $topicPost->setChildren( $topicChildren );
$storage->put( $topicWorkflow );
$storage->put( $topicListEntry );
$storage->put( $topicPost );
- $storage->put( $firstPost );
+ if ( $firstPost !== null ) {
+ $storage->put( $firstPost );
+ }
$this->notificationController->notifyNewTopic( array(
'board-workflow' => $this->workflow,
@@ -79,7 +83,7 @@
$notificationController = $this->notificationController;
$output = array(
'created-topic-id' => $topicWorkflow->getId(),
- 'created-post-id' => $firstPost->getRevisionId(),
+ 'created-post-id' => $firstPost ?
$firstPost->getRevisionId() : null,
'render-function' => function( $templating )
use ( $topicWorkflow, $firstPost,
$topicPost, $storage, $user, $notificationController )
{
diff --git a/includes/Notifications/Controller.php
b/includes/Notifications/Controller.php
index 8abc2e5..7ca9da0 100644
--- a/includes/Notifications/Controller.php
+++ b/includes/Notifications/Controller.php
@@ -125,7 +125,7 @@
* * topic-workflow: Workflow object for the new Topic.
* * title-post: PostRevision object for the "topic post", containing
the
* title.
- * * first-post: PostRevision object for the first post.
+ * * first-post: PostRevision object for the first post, or null when
no first post.
* * user: The User who created the topic.
* @return array Array of created EchoEvent objects.
*/
@@ -148,9 +148,9 @@
'extra' => array(
'board-workflow' => $boardWorkflow->getId(),
'topic-workflow' => $topicWorkflow->getId(),
- 'post-id' => $firstPost->getRevisionId(),
+ 'post-id' => $firstPost ?
$firstPost->getRevisionId() : null,
'topic-title' => $topicPost->getContentRaw(),
- 'content' => $firstPost->getContent(),
+ 'content' => $firstPost ?
$firstPost->getContent() : null,
)
) );
@@ -185,16 +185,16 @@
$topicWorkflow = $data['topic-workflow'];
$events = array();
- $mentionedUsers = $this->getMentionedUsers( $newRevision,
$title );
+ $mentionedUsers = $newRevision ? $this->getMentionedUsers(
$newRevision, $title ) : array();
if ( count( $mentionedUsers ) ) {
$events[] = EchoEvent::create( array(
'type' => 'flow-mention',
'title' => $title,
'extra' => array(
- 'content' => $newRevision->getContent(),
+ 'content' => $newRevision ?
$newRevision->getContent() : null,
'topic-title' => $data['topic-title'],
- 'post-id' => $newRevision->getPostId(),
+ 'post-id' => $newRevision ?
$newRevision->getPostId() : null,
'mentioned-users' => $mentionedUsers,
'topic-workflow' =>
$topicWorkflow->getId(),
),
@@ -377,7 +377,7 @@
protected static function getCreatorsFromPostIDs( array $posts ) {
$users = array();
$container = Container::getContainer();
-
+
foreach ( $posts as $postId ) {
$post = $container['storage']->find(
'PostRevision',
@@ -403,5 +403,5 @@
}
return $users;
- }
-}
\ No newline at end of file
+ }
+}
diff --git a/modules/discussion/forms.js b/modules/discussion/forms.js
index 2ee3544..50b0da4 100644
--- a/modules/discussion/forms.js
+++ b/modules/discussion/forms.js
@@ -7,15 +7,12 @@
);
$( 'form.flow-newtopic-form' ).flow( 'setupEmptyDisabler',
- [
- '.flow-newtopic-title',
- '.flow-newtopic-content'
- ],
+ [ '.flow-newtopic-title' ],
'.flow-newtopic-submit'
);
$container.find( 'form.flow-topic-reply-form' ).flow(
'setupEmptyDisabler',
- ['.flow-topic-reply-content'],
+ [ '.flow-topic-reply-content' ],
'.flow-topic-reply-submit'
);
@@ -32,7 +29,7 @@
return [ workflowParam, title, content ];
},
function ( workflowParam, title, content ) {
- return title && content;
+ return !!title;
},
function ( promise ) {
promise
--
To view, visit https://gerrit.wikimedia.org/r/92454
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6b37cb130bff14d94303f545d38fe1676776ff02
Gerrit-PatchSet: 3
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: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits