Matthias Mullie has uploaded a new change for review.

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

Change subject: Stop accepting Workflow object in BoardContent
......................................................................

Stop accepting Workflow object in BoardContent

Change-Id: Iec3577efbe3d712e4c348c81d2b20f0cbc8de911
---
M includes/Content/BoardContent.php
M includes/Content/BoardContentHandler.php
M includes/TalkpageManager.php
3 files changed, 12 insertions(+), 37 deletions(-)


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

diff --git a/includes/Content/BoardContent.php 
b/includes/Content/BoardContent.php
index ca4b76e..c9d1e09 100644
--- a/includes/Content/BoardContent.php
+++ b/includes/Content/BoardContent.php
@@ -18,24 +18,12 @@
 use Title;
 
 class BoardContent extends \AbstractContent {
-       /** @var Workflow|UUID|null */
-       protected $workflow;
+       /** @var UUID|null */
+       protected $workflowId;
 
-       public function __construct( $contentModel = CONTENT_MODEL_FLOW_BOARD, 
$workflow = null ) {
-               parent::__construct( CONTENT_MODEL_FLOW_BOARD );
-
-               // Allowed ways of loading a Workflow
-               if ( ! (
-                       $workflow === null ||
-                       $workflow instanceof UUID ||
-                       $workflow instanceof Workflow
-               ) ) {
-                       throw new MWException( "Invalid argument for 'workflow' 
parameter." );
-               }
-
-               if ( $workflow instanceof UUID || $workflow instanceof Workflow 
) {
-                       $this->workflow = $workflow;
-               }
+       public function __construct( $contentModel = CONTENT_MODEL_FLOW_BOARD, 
UUID $workflowId = null ) {
+               parent::__construct( $contentModel );
+               $this->workflowId = $workflowId;
        }
 
        /**
@@ -208,32 +196,19 @@
        /**
         * @param Title $title
         * @return \Flow\WorkflowLoader
-        * @throws MWException
         * @throws \Flow\Exception\CrossWikiException
         * @throws \Flow\Exception\InvalidInputException
         */
        protected function getWorkflowLoader( Title $title ) {
-               if ( $this->workflow instanceof Workflow && 
$this->workflow->isNew() ) {
-                       // as long as workflow is new, we shouldn't rely on its 
id
-                       $workflowId = null;
-               } else {
-                       $workflowId = $this->getWorkflowId();
-               }
-
                /** @var WorkflowLoaderFactory $factory */
                $factory = Container::get( 'factory.loader.workflow' );
-               return $factory->createWorkflowLoader( $title, $workflowId );
+               return $factory->createWorkflowLoader( $title, 
$this->getWorkflowId() );
        }
 
+       /**
+        * @return UUID|null
+        */
        public function getWorkflowId() {
-               if ( $this->workflow instanceof UUID ) {
-                       return $this->workflow;
-               } elseif ( $this->workflow instanceof Workflow ) {
-                       return $this->workflow->getId();
-               } elseif ( $this->workflow === null ) {
-                       return null;
-               } else {
-                       throw new MWException( "Unknown Workflow specifier" );
-               }
+               return $this->workflowId;
        }
 }
diff --git a/includes/Content/BoardContentHandler.php 
b/includes/Content/BoardContentHandler.php
index d6375a7..ffa64ad 100644
--- a/includes/Content/BoardContentHandler.php
+++ b/includes/Content/BoardContentHandler.php
@@ -68,7 +68,7 @@
                $info = FormatJson::decode( $blob, true );
                $uuid = null;
 
-               if ( ! $info ) {
+               if ( !$info ) {
                        // For transition from wikitext-type pages
                        // Make a plain content object and then when we get a 
chance
                        // we can insert a proper object.
diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php
index 74cb7d3..433393d 100644
--- a/includes/TalkpageManager.php
+++ b/includes/TalkpageManager.php
@@ -151,7 +151,7 @@
                }
 
                $status = $page->doEditContent(
-                       new BoardContent( CONTENT_MODEL_FLOW_BOARD, $workflow ),
+                       new BoardContent( CONTENT_MODEL_FLOW_BOARD, 
$workflow->isNew() ? null : $workflow->getId() ),
                        $comment,
                        EDIT_FORCE_BOT | EDIT_SUPPRESS_RC,
                        false,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec3577efbe3d712e4c348c81d2b20f0cbc8de911
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to