Legoktm has uploaded a new change for review.

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

Change subject: Revert "Show an error to the user if the spamlist has no 
targets on it"
......................................................................

Revert "Show an error to the user if the spamlist has no targets on it"

This is causing T139303

This reverts commit 581beff268d5a50cfff13787d54a255f85aa3b9d.

Bug: T139303
Change-Id: Ia033cc0a4d8b2fe4fac9d47d9462ebed6005c86b
---
M i18n/en.json
M i18n/qqq.json
M includes/ApiMassMessage.php
M includes/MassMessage.php
M includes/MassMessageTargets.php
M includes/SpecialMassMessage.php
M tests/api/ApiMassMessageTest.php
7 files changed, 16 insertions(+), 45 deletions(-)


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

diff --git a/i18n/en.json b/i18n/en.json
index 5494a77..902f97b 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -19,8 +19,7 @@
        "massmessage-preview-count": "Your message will be sent to 
{{PLURAL:$1|$1 page|$1 pages}}.",
        "massmessage-submitted": "Your message delivery to {{PLURAL:$1|$1 
page|$1 pages}} has been queued.",
        "massmessage-just-preview": "This is just a preview. Press 
\"{{int:massmessage-form-submit}}\" to send the message.",
-       "massmessage-spamlist-doesnotexist": "The specified list of pages does 
not exist.",
-       "massmessage-spamlist-notargets": "The specified list of pages does not 
have any targets on it.",
+       "massmessage-spamlist-doesnotexist": "The specified delivery list page 
or category does not exist.",
        "massmessage-spamlist-invalid": "The specified page does not contain a 
valid delivery list.",
        "massmessage-empty-subject": "The subject line is empty.",
        "massmessage-empty-message": "The message body is empty.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index d48b416..4c52951 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -25,8 +25,7 @@
        "massmessage-preview-count": "Text indicating how many pages the 
message will be sent to. Parameters:\n* $1 - the number of pages",
        "massmessage-submitted": "Confirmation message the user sees after the 
form is submitted successfully and the request is queued in the job 
queue.\n\nParameters:\n* $1 - the number of deliveries that have been queued",
        "massmessage-just-preview": "Warning to user that what they are seeing 
is just a preview, and they should hit the send button to actually submit 
it.\n\nRefers to {{msg-mw|Massmessage-form-submit}}.",
-       "massmessage-spamlist-doesnotexist": "Error message the user sees if an 
invalid list of pages is provided.",
-       "massmessage-spamlist-notargets": "Error message that the user sees if 
the list of pages provided by the user has no targets listed on it.",
+       "massmessage-spamlist-doesnotexist": "Error message the user sees if 
the delivery list page or category they entered does not exist.",
        "massmessage-spamlist-invalid": "Error message the user sees if the 
delivery list page they entered is invalid.",
        "massmessage-empty-subject": "Error message the user sees if the 
\"subject\" field is empty.",
        "massmessage-empty-message": "Error message the user sees if the 
\"message\" field is empty.",
diff --git a/includes/ApiMassMessage.php b/includes/ApiMassMessage.php
index 19e3dbf..25eb370 100644
--- a/includes/ApiMassMessage.php
+++ b/includes/ApiMassMessage.php
@@ -16,7 +16,7 @@
                $data = $this->extractRequestParams();
 
                $status = new Status();
-               MassMessage::verifyData( $data, $status, $this );
+               MassMessage::verifyData( $data, $status );
                if ( !$status->isOK() ) {
                        $this->dieStatus( $status );
                }
diff --git a/includes/MassMessage.php b/includes/MassMessage.php
index c920766..615d8fc 100644
--- a/includes/MassMessage.php
+++ b/includes/MassMessage.php
@@ -195,9 +195,8 @@
         * Verify and cleanup the main user submitted data
         * @param array &$data should have subject, message, and spamlist keys
         * @param Status &$status
-        * @param IContextSource $ctx
         */
-       public static function verifyData( array &$data, Status &$status, 
IContextSource $ctx ) {
+       public static function verifyData( array &$data, Status &$status ) {
                // Trim all the things!
                foreach ( $data as $k => $v ) {
                        $data[$k] = trim( $v );
@@ -220,18 +219,10 @@
                                );
                        }
                        $data['comment'] = [
-                               $ctx->getUser()->getName(),
+                               RequestContext::getMain()->getUser()->getName(),
                                wfWikiID(),
                                $url
                        ];
-
-                       // Check that the spamlist has targets
-                       $targets = 
MassMessageTargets::getParserFunctionTargets( $spamlist, $ctx );
-                       if ( !is_array( $targets ) ) {
-                               $status->fatal( $targets );
-                       } elseif ( !$targets ) {
-                               $status->fatal( 
'massmessage-spamlist-notargets' );
-                       }
                } else { // $spamlist contains a message key for an error 
message
                        $status->fatal( $spamlist );
                }
diff --git a/includes/MassMessageTargets.php b/includes/MassMessageTargets.php
index ad2d402..8504ffd 100644
--- a/includes/MassMessageTargets.php
+++ b/includes/MassMessageTargets.php
@@ -140,27 +140,11 @@
         * Get an array of targets via the #target parser function
         * @param  Title $spamlist
         * @param  IContextSource $context
-        * @return array|string if a string, it'll be the error message key
+        * @return array
         */
-       public static function getParserFunctionTargets( Title $spamlist ) {
-               global $wgMemc;
+       protected static function getParserFunctionTargets( Title $spamlist ) {
                $page = WikiPage::factory( $spamlist );
-
-               $content = $page->getContent( Revision::RAW );
-               $text = $content->getNativeData();
-
-               $key = wfMemcKey( 'massmessage', 'targets', 
$page->getRevision()->getId() );
-               $data = $wgMemc->get( $key );
-               if ( $data !== false ) {
-                       return $data;
-               }
-               if ( $content instanceof WikitextContent ) {
-                       // The content type should have already been checked
-                       // earlier, but we'll be safe.
-                       $text = $content->getNativeData();
-               } else {
-                       return 'massmessage-spamlist-doesnotexist';
-               }
+               $text = $page->getContent( Revision::RAW )->getNativeData();
 
                // Prep the parser
                $parserOptions = $page->makeParserOptions( 'canonical' );
@@ -177,11 +161,9 @@
                $data = unserialize( $output->getProperty( 
'massmessage-targets' ) );
 
                if ( $data ) {
-                       $data = self::normalizeTargets( $data );
+                       return $data;
                } else {
-                       $data = []; // No parser functions on page
+                       return []; // No parser functions on page
                }
-               $wgMemc->set( $key, $data, 60 * 60 );
-               return $data;
        }
 }
diff --git a/includes/SpecialMassMessage.php b/includes/SpecialMassMessage.php
index c1118b2..0a35e12 100644
--- a/includes/SpecialMassMessage.php
+++ b/includes/SpecialMassMessage.php
@@ -178,7 +178,7 @@
         */
        public function callback( array $data ) {
 
-               MassMessage::verifyData( $data, $this->status, 
$this->getContext() );
+               MassMessage::verifyData( $data, $this->status );
 
                // Die on errors.
                if ( !$this->status->isOK() ) {
diff --git a/tests/api/ApiMassMessageTest.php b/tests/api/ApiMassMessageTest.php
index c4ef23a..feb9b2f 100644
--- a/tests/api/ApiMassMessageTest.php
+++ b/tests/api/ApiMassMessageTest.php
@@ -9,14 +9,14 @@
 class ApiMassMessageTest extends MassMessageApiTestCase {
 
        protected static $spamlist = 'Help:ApiMassMessageTest_spamlist';
-       protected static $spamlist2 = 'Help:ApiMassMessageTest_spamlist2';
+       protected static $emptyspamlist = 'Help:ApiMassMessageTest_spamlist2';
 
        protected function setUp() {
                parent::setUp();
                $spamlist = Title::newFromText( self::$spamlist );
                self::updatePage( $spamlist, '{{#target:Project:ApiTest1}}' );
-               $emptyspamlist = Title::newFromText( self::$spamlist2 );
-               self::updatePage( $emptyspamlist, 
'{{#target:Project:ApiTest2}}{{#target:Project:ApiTest3}}' );
+               $emptyspamlist = Title::newFromText( self::$emptyspamlist );
+               self::updatePage( $emptyspamlist, 'rawr' );
                $this->doLogin();
        }
 
@@ -57,7 +57,7 @@
         */
        public function testInvalidSpamlist() {
                $this->setExpectedException( 'UsageException',
-                       'The specified list of pages does not exist.' );
+                       'The specified delivery list page or category does not 
exist.' );
                $this->doApiRequestWithToken( [
                        'action' => 'massmessage',
                        'spamlist' => '<InvalidPageTitle>',
@@ -69,7 +69,7 @@
        public static function provideCount() {
                return [
                        [ self::$spamlist, 1 ],
-                       [ self::$spamlist2, 2 ]
+                       [ self::$emptyspamlist, 0 ]
                ];
        }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia033cc0a4d8b2fe4fac9d47d9462ebed6005c86b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: wmf/1.28.0-wmf.8
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Wctaiwan <wctai...@gmail.com>

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

Reply via email to