Wctaiwan has uploaded a new change for review.

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

Change subject: Clean up SpecialMassMessage
......................................................................

Clean up SpecialMassMessage

Minor refactor of some logic and clean up some comments. Should not
change actual behaviour.

Change-Id: I7a92825edf24de0ad3c01f5b91b16982e79faa62
---
M includes/SpecialMassMessage.php
1 file changed, 12 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage 
refs/changes/92/160792/1

diff --git a/includes/SpecialMassMessage.php b/includes/SpecialMassMessage.php
index 85a79da..217b1a8 100644
--- a/includes/SpecialMassMessage.php
+++ b/includes/SpecialMassMessage.php
@@ -166,11 +166,10 @@
        /**
         * Callback function
         * Does some basic verification of data
-        * Decides whether to show the preview screen
-        * or the submitted message
+        * Decides whether to show the preview screen or the submitted message
         *
         * @param $data Array
-        * @return Status
+        * @return Status|bool
         */
        public function callback( array $data ) {
 
@@ -179,7 +178,6 @@
                // Die on errors.
                if ( !$this->status->isOK() ) {
                        $this->state = 'form';
-
                        return $this->status;
                }
 
@@ -187,7 +185,8 @@
                        $this->count = MassMessage::submit( 
$this->getContext(), $data );
                        return $this->status;
                } else { // $this->state can only be 'preview' here
-                       return $this->preview( $data );
+                       $this->preview( $data );
+                       return false; // No submission attempted
                }
        }
 
@@ -256,9 +255,9 @@
 
        /**
         * A preview/confirmation screen
+        * The preview generation code was hacked up from EditPage.php
         *
         * @param $data Array
-        * @return Status
         */
        protected function preview( array $data ) {
                $this->getOutput()->addWikiMsg( 'massmessage-just-preview' );
@@ -278,8 +277,6 @@
                $mockTarget = Title::newFromText( 'Project:Example' );
                $wikipage = WikiPage::factory( $mockTarget );
 
-               // Hacked up from EditPage.php
-
                // Convert into a content object
                $content = ContentHandler::makeContent( $data['message'], 
$mockTarget );
                // Parser stuff. Taken from EditPage::getPreviewText()
@@ -291,12 +288,14 @@
 
                // Hooks not being run: EditPageGetPreviewContent, 
EditPageGetPreviewText
 
-               $content = $content->preSaveTransform( $mockTarget, 
MassMessage::getMessengerUser(), $parserOptions );
+               $content = $content->preSaveTransform( $mockTarget, 
MassMessage::getMessengerUser(),
+                       $parserOptions );
                $parserOutput = $content->getParserOutput( $mockTarget, null, 
$parserOptions );
-               $previewHTML = $parserOutput->getText();
-               $fieldsetMessage = $this->msg( 'massmessage-fieldset-preview' 
)->text();
-               $wrapFieldset = Xml::fieldset( $fieldsetMessage, $previewHTML );
-               $this->getOutput()->addHTML( $wrapFieldset );
+               $previewFieldset = Xml::fieldset(
+                       $this->msg( 'massmessage-fieldset-preview' )->text(),
+                       $parserOutput->getText()
+               );
+               $this->getOutput()->addHTML( $previewFieldset );
 
                // Check if we have unescaped langlinks (Bug 54846)
                if ( $parserOutput->getLanguageLinks() ) {
@@ -317,7 +316,5 @@
                if ( !preg_match( MassMessage::getTimestampRegex(), 
$content->getNativeData() ) ) {
                        $this->status->fatal( 'massmessage-no-timestamp' );
                }
-
-               return false;
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a92825edf24de0ad3c01f5b91b16982e79faa62
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Wctaiwan <[email protected]>

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

Reply via email to