Merge "OutputPageTest should be independent of $wgResourceLoaderDebug setting"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 25 Sep 2018 19:36:07 +0000 (19:36 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 25 Sep 2018 19:36:07 +0000 (19:36 +0000)
RELEASE-NOTES-1.32
autoload.php
includes/api/ApiParse.php
maintenance/emptyUserGroup.php [new file with mode: 0644]
maintenance/parse.php
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/OutputPageTest.php
tests/phpunit/includes/api/ApiErrorFormatterTest.php
tests/phpunit/includes/api/ApiParseTest.php
tests/phpunit/includes/debug/DeprecationHelperTest.php

index 72c47b6..60f5e6a 100644 (file)
@@ -167,6 +167,9 @@ production.
     content is not being preserved. 'fromsection-{slot}' and 'tosection-{slot}'
     instead expand the given text as if for a section edit. This effectively
     declines T183823 in favor of T185723.
+* (T198214) The 'disabletidy' parameter to action=parse has been
+  deprecated; untidy output will not be supported by future wikitext
+  parsers.
 
 === Action API internal changes in 1.32 ===
 * Added 'ApiParseMakeOutputPage' hook.
@@ -317,6 +320,9 @@ because of Phabricator reports.
   Wikimedia\Rdbms\LBFactory.
 * The MimeMagic class, deprecated since 1.28 has been removed. Get a
   MimeAnalyzer instance from MediaWikiServices instead.
+* The '--tidy' option to maintenance/parse.php has been removed.  Tidying
+  the output is now the default.  Use '--no-tidy' to bypass the tidy
+  phase.
 
 === Deprecations in 1.32 ===
 * HTMLForm::setSubmitProgressive() is deprecated. No need to call it. Submit
index d939089..33ee128 100644 (file)
@@ -449,6 +449,7 @@ $wgAutoloadLocalClasses = [
        'EmailNotification' => __DIR__ . '/includes/mail/EmailNotification.php',
        'EmaillingJob' => __DIR__ . '/includes/jobqueue/jobs/EmaillingJob.php',
        'EmptyBagOStuff' => __DIR__ . '/includes/libs/objectcache/EmptyBagOStuff.php',
+       'EmptyUserGroup' => __DIR__ . '/maintenance/emptyUserGroup.php',
        'EnConverter' => __DIR__ . '/languages/classes/LanguageEn.php',
        'EncryptedPassword' => __DIR__ . '/includes/password/EncryptedPassword.php',
        'EnhancedChangesList' => __DIR__ . '/includes/changes/EnhancedChangesList.php',
index 5c25b5a..a78cb7f 100644 (file)
@@ -868,7 +868,10 @@ class ApiParse extends ApiBase {
                        ],
                        'disablelimitreport' => false,
                        'disableeditsection' => false,
-                       'disabletidy' => false,
+                       'disabletidy' => [
+                               ApiBase::PARAM_DFLT => false,
+                               ApiBase::PARAM_DEPRECATED => true, // Since 1.32
+                       ],
                        'disablestylededuplication' => false,
                        'generatexml' => [
                                ApiBase::PARAM_DFLT => false,
diff --git a/maintenance/emptyUserGroup.php b/maintenance/emptyUserGroup.php
new file mode 100644 (file)
index 0000000..03a38fc
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * Removes all users from a given user group.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once __DIR__ . '/Maintenance.php';
+
+use MediaWiki\MediaWikiServices;
+
+class EmptyUserGroup extends Maintenance {
+       public function __construct() {
+               parent::__construct();
+               $this->addDescription( 'Remove all users from a given user group' );
+               $this->addArg( 'group', 'Group to be removed', true );
+       }
+
+       public function execute() {
+               $group = $this->getArg( 0 );
+
+               $lb = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+
+               $users = User::findUsersByGroup( $group );
+
+               $count = iterator_count( $users );
+
+               $this->output( "Removing $count users from $group..." );
+
+               /**
+                * @var User $user
+                */
+               foreach ( $users as $user ) {
+                       $user->removeGroup( $group );
+
+                       $lb->waitForReplication();
+               }
+
+               $this->output( " Done!\n" );
+       }
+}
+
+$maintClass = EmptyUserGroup::class;
+require_once RUN_MAINTENANCE_IF_MAIN;
index d9a247c..f01d8f5 100644 (file)
@@ -71,7 +71,7 @@ class CLIParser extends Maintenance {
                        false,
                        true
                );
-               $this->addOption( 'tidy', 'Tidy the output' );
+               $this->addOption( 'no-tidy', 'Don\'t tidy the output (deprecated)' );
                $this->addArg( 'file', 'File containing wikitext (Default: stdin)', false );
        }
 
@@ -85,7 +85,7 @@ class CLIParser extends Maintenance {
         * @return string HTML Rendering
         */
        public function render( $wikitext ) {
-               return $this->parse( $wikitext )->getText();
+               return $this->parse( $wikitext )->getText( [ 'wrapperDivClass' => '' ] );
        }
 
        /**
@@ -129,9 +129,10 @@ class CLIParser extends Maintenance {
         * @return ParserOutput
         */
        protected function parse( $wikitext ) {
-               $options = new ParserOptions;
-               if ( $this->getOption( 'tidy' ) ) {
-                       $options->setTidy( true );
+               $options = ParserOptions::newCanonical();
+               $options->setOption( 'enableLimitReport', false );
+               if ( $this->getOption( 'no-tidy' ) ) {
+                       $options->setTidy( false );
                }
                return $this->parser->parse(
                        $wikitext,
index af014b9..d675e85 100644 (file)
@@ -552,6 +552,8 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                        }
                }
 
+               // Re-enable any disabled deprecation warnings
+               MWDebug::clearLog();
                // Restore mw globals
                foreach ( $this->mwGlobals as $key => $value ) {
                        $GLOBALS[$key] = $value;
index d48da70..7fa88fc 100644 (file)
@@ -184,11 +184,12 @@ class OutputPageTest extends MediaWikiTestCase {
 
        /**
         * Test the actual behavior of the method (in the case where it doesn't throw, e.g., in
-        * production).  Since it threw an exception once in this file, it won't when we call it again.
+        * production).
         *
         * @covers OutputPage::addScriptFile
         */
        public function testAddDeprecatedScriptFileNoOp() {
+               $this->hideDeprecated( 'OutputPage::addScriptFile' );
                $op = $this->newInstance();
                $op->addScriptFile( 'ignored-script.js' );
 
index aa579ab..f36faf7 100644 (file)
@@ -555,6 +555,10 @@ class ApiErrorFormatterTest extends MediaWikiLangTestCase {
         * @param array $expect
         */
        public function testGetMessageFromException_BC( $exception, $options, $expect ) {
+               if ( $exception instanceof UsageException ) {
+                       $this->hideDeprecated( 'UsageException::getMessageArray' );
+               }
+
                $result = new ApiResult( 8388608 );
                $formatter = new ApiErrorFormatter_BackCompat( $result );
 
index 7f2c1a6..b20d43e 100644 (file)
@@ -97,8 +97,7 @@ class ApiParseTest extends ApiTestCase {
                        $this->assertCount( 1, $res[0] );
                } else {
                        $this->assertCount( 2, $res[0] );
-                       // This deliberately fails if there are extra warnings
-                       $this->assertSame( [ 'parse' => [ 'warnings' => $warnings ] ], $res[0]['warnings'] );
+                       $this->assertSame( [ 'warnings' => $warnings ], $res[0]['warnings']['parse'] );
                }
        }
 
@@ -827,7 +826,8 @@ class ApiParseTest extends ApiTestCase {
                        'disabletidy' => '',
                ] );
 
-               $this->assertParsedTo( "<p><b>Mixed <i>up</b></i>\n</p>", $res2 );
+               $this->assertParsedTo( "<p><b>Mixed <i>up</b></i>\n</p>", $res2,
+                       'The parameter "disabletidy" has been deprecated.' );
        }
 
        public function testFormatCategories() {
index 55e5bbf..6b977a3 100644 (file)
@@ -20,11 +20,6 @@ class DeprecationHelperTest extends MediaWikiTestCase {
                $this->setMwGlobals( 'wgDevelopmentWarnings', false );
        }
 
-       public function tearDown() {
-               parent::tearDown();
-               MWDebug::clearLog();
-       }
-
        /**
         * @dataProvider provideGet
         */