Merge "Update wikimedia/wrappedstring to v3.0.0"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 24 May 2018 02:14:00 +0000 (02:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 24 May 2018 02:14:00 +0000 (02:14 +0000)
74 files changed:
.phpcs.xml
INSTALL
RELEASE-NOTES-1.32
composer.json
includes/OutputPage.php
includes/Setup.php
includes/actions/FormAction.php
includes/actions/WatchAction.php
includes/cache/CacheHelper.php
includes/composer/ComposerHookHandler.php
includes/composer/ComposerPackageModifier.php
includes/composer/ComposerVersionNormalizer.php
includes/dao/DBAccessBase.php
includes/interwiki/InterwikiLookupAdapter.php
includes/libs/CSSMin.php
includes/libs/GenericArrayObject.php
includes/libs/IP.php
includes/libs/JavaScriptMinifier.php
includes/logging/BlockLogFormatter.php
includes/logging/DeleteLogFormatter.php
includes/logging/ImportLogFormatter.php
includes/logging/LogEntry.php
includes/logging/LogFormatter.php
includes/logging/MergeLogFormatter.php
includes/logging/MoveLogFormatter.php
includes/logging/NewUsersLogFormatter.php
includes/logging/PageLangLogFormatter.php
includes/logging/PatrolLogFormatter.php
includes/logging/ProtectLogFormatter.php
includes/logging/RightsLogFormatter.php
includes/logging/UploadLogFormatter.php
includes/logging/WikitextLogFormatter.php
includes/media/Exif.php
includes/media/FormatMetadata.php
includes/media/SVGMetadataExtractor.php
includes/site/CachingSiteStore.php
includes/site/DBSiteStore.php
includes/site/FileBasedSiteLookup.php
includes/site/MediaWikiPageNameNormalizer.php
includes/site/MediaWikiSite.php
includes/site/Site.php
includes/site/SiteExporter.php
includes/site/SiteImporter.php
includes/site/SiteList.php
includes/site/SiteLookup.php
includes/site/SiteSQLStore.php
includes/site/SiteStore.php
includes/site/SitesCacheFileBuilder.php
includes/specials/helpers/License.php
includes/watcheditem/WatchedItemQueryService.php
includes/watcheditem/WatchedItemQueryServiceExtension.php
includes/widget/SizeFilterWidget.php
languages/classes/LanguageBe_tarask.php
languages/messages/MessagesLv.php
languages/messages/MessagesNn.php
maintenance/addSite.php
maintenance/deleteAutoPatrolLogs.php
maintenance/exportSites.php
maintenance/importSites.php
maintenance/parse.php
maintenance/reassignEdits.php
maintenance/showSiteStats.php
opensearch_desc.php
tests/phpunit/includes/actions/ActionTest.php
tests/phpunit/includes/actions/WatchActionTest.php [new file with mode: 0644]
tests/phpunit/includes/htmlform/HTMLFormTest.php
tests/phpunit/includes/jobqueue/JobQueueMemoryTest.php
tests/phpunit/includes/jobqueue/jobs/CategoryMembershipChangeJobTest.php
tests/phpunit/includes/jobqueue/jobs/ClearUserWatchlistJobTest.php
tests/phpunit/includes/libs/IPTest.php
tests/phpunit/includes/specials/SpecialBlankPageTest.php
tests/phpunit/includes/specials/SpecialPageTestBase.php
tests/phpunit/includes/specials/SpecialShortpagesTest.php
tests/phpunit/maintenance/deleteAutoPatrolLogsTest.php

index 440adaf..fb9d232 100644 (file)
@@ -10,7 +10,6 @@
                <exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle" />
                <exclude name="MediaWiki.Commenting.IllegalSingleLineComment.IllegalSingleLineCommentStart" />
                <exclude name="MediaWiki.Commenting.IllegalSingleLineComment.IllegalSingleLineCommentEnd" />
-               <exclude name="MediaWiki.Commenting.LicenseComment.InvalidLicenseTag" />
                <exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
                <exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
                <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
diff --git a/INSTALL b/INSTALL
index 3b93505..5cdbbf3 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -56,7 +56,7 @@ ie. /wiki/index.php/Article.
   |  will appear. It is common in this case to use w as the folder name and  |
   |  /wiki/ as the virtual article path where your articles pretend to be.   |
   |                                                                          |
-  |    See: https://www.mediawiki.org/wiki/Manual:Short_URL                  |
+  |  See: https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Short_URL |
   +--------------------------------------------------------------------------+
 
 Hop into your browser and surf into the wiki directory. It'll direct you into
index fa7c962..f1efd4f 100644 (file)
@@ -26,8 +26,8 @@ production.
 * (T112474) Generalized the ResourceLoader mechanism for overriding modules
   using a particular page during edit previews.
 * Added 'ApiParseMakeOutputPage' hook.
-* (T174313) Added checkbox on Special:ListUsers to display only users in temporary
-  user groups.
+* (T174313) Added checkbox on Special:ListUsers to display only users in
+  temporary user groups.
 
 === External library changes in 1.32 ===
 * …
@@ -97,15 +97,15 @@ because of Phabricator reports.
 * mw.util.updateTooltipAccessKeys(), deprecated in 1.24, was removed. Use
   jquery.accessKeyLabel instead.
 * The SqlDataUpdate class, deprecated in 1.28, has been removed.
-* The Html5Internal and Html5Depurate tidy driver classes were removed, along with the
-  Balancer tidy implementation. Both implementations were experimental, and were replaced
-  by RemexHtml.
+* The Html5Internal and Html5Depurate tidy driver classes were removed, along
+  with the Balancer tidy implementation. Both implementations were experimental,
+  and were replaced by RemexHtml.
 * (T179624) Job::insert() and ::batchInsert(), deprecated in 1.21, were both
   removed. Use JobQueueGroup::singleton()->push() instead.
 * The jquery.footHovzer module, for mediawiki.debug, was removed.
 * The es5-shim module, empty and deprecated since 1.29, was removed.
-* The mediawiki.widgets.visibleByteLimit module, deprecated in 1.32, was removed.
-  Use mediawiki.widgets.visibleLengthLimit instead.
+* The mediawiki.widgets.visibleByteLimit module alias, deprecated in 1.32, was
+  removed. Use mediawiki.widgets.visibleLengthLimit instead.
 * The jquery.farbtastic module, unused since 1.18, was removed.
 
 === Deprecations in 1.32 ===
@@ -129,6 +129,8 @@ because of Phabricator reports.
   mediawiki.api.messages, and mediawiki.api.rollback.
 * ApiBase::truncateArray() is deprecated. No replacement, as nothing is known
   to use it.
+* WatchAction::getUnwatchToken is deprecated. Use WatchAction::getWatchToken
+  with the 'unwatch' action parameter instead.
 
 === Other changes in 1.32 ===
 * Soft hyphens (U+00AD) are now automatically removed from titles; these
index f9fe6e8..8cdec2e 100644 (file)
@@ -59,7 +59,7 @@
                "jakub-onderka/php-parallel-lint": "0.9.2",
                "jetbrains/phpstorm-stubs": "dev-master#1b9906084d6635456fcf3f3a01f0d7d5b99a578a",
                "justinrainbow/json-schema": "~5.2",
-               "mediawiki/mediawiki-codesniffer": "17.0.0",
+               "mediawiki/mediawiki-codesniffer": "18.0.0",
                "monolog/monolog": "~1.22.1",
                "nikic/php-parser": "3.1.3",
                "nmred/kafka-php": "0.1.5",
index 6c45d9c..7f72d36 100644 (file)
@@ -468,9 +468,9 @@ class OutputPage extends ContextSource {
         * Internal use only. Use OutputPage::addModules() if possible.
         *
         * @param string $file URL to file (absolute path, protocol-relative, or full url)
-        * @param string $version Style version of the file. Defaults to $wgStyleVersion
+        * @param string $unused Previously used to change the cache-busting query parameter
         */
-       public function addScriptFile( $file, $version = null ) {
+       public function addScriptFile( $file, $unused = null ) {
                if ( substr( $file, 0, 1 ) !== '/' && !preg_match( '#^[a-z]*://#i', $file ) ) {
                        // This is not an absolute path, protocol-relative url, or full scheme url,
                        // presumed to be an old call intended to include a file from /w/skins/common,
@@ -478,11 +478,7 @@ class OutputPage extends ContextSource {
                        wfDeprecated( __METHOD__, '1.24' );
                        return;
                }
-               $path = $file;
-               if ( is_null( $version ) ) {
-                       $version = $this->getConfig()->get( 'StyleVersion' );
-               }
-               $this->addScript( Html::linkedScript( wfAppendQuery( $path, $version ), $this->getCSPNonce() ) );
+               $this->addScript( Html::linkedScript( $file, $this->getCSPNonce() ) );
        }
 
        /**
@@ -3666,8 +3662,11 @@ class OutputPage extends ContextSource {
                        $url = $style;
                } else {
                        $config = $this->getConfig();
-                       $url = $config->get( 'StylePath' ) . '/' . $style . '?' .
-                               $config->get( 'StyleVersion' );
+                       // Append file hash as query parameter
+                       $url = self::transformResourcePath(
+                               $config,
+                               $config->get( 'StylePath' ) . '/' . $style
+                       );
                }
 
                $link = Html::linkedStyle( $url, $media );
index 2c315a3..9d7a155 100644 (file)
@@ -629,8 +629,6 @@ MWExceptionHandler::installHandler();
 
 require_once "$IP/includes/compat/normal/UtfNormalUtil.php";
 
-$ps_validation = Profiler::instance()->scopedProfileIn( $fname . '-validation' );
-
 // T48998: Bail out early if $wgArticlePath is non-absolute
 foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) {
        if ( $$varName && !preg_match( '/^(https?:\/\/|\/)/', $$varName ) ) {
@@ -643,8 +641,6 @@ foreach ( [ 'wgArticlePath', 'wgVariantArticlePath' ] as $varName ) {
        }
 }
 
-Profiler::instance()->scopedProfileOut( $ps_validation );
-
 $ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' );
 
 if ( $wgCanonicalServer === false ) {
@@ -705,7 +701,7 @@ if ( $wgMainWANCache === false ) {
 
 Profiler::instance()->scopedProfileOut( $ps_default2 );
 
-$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc1' );
+$ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc' );
 
 // Raise the memory limit if it's too low
 wfMemoryLimit();
@@ -774,9 +770,6 @@ if ( $wgCommandLineMode ) {
        wfDebug( $debug );
 }
 
-Profiler::instance()->scopedProfileOut( $ps_misc );
-$ps_memcached = Profiler::instance()->scopedProfileIn( $fname . '-memcached' );
-
 $wgMemc = wfGetMainCache();
 $messageMemc = wfGetMessageCacheStorage();
 
@@ -795,7 +788,7 @@ wfDebugLog( 'caches',
        ', session: ' . get_class( ObjectCache::getInstance( $wgSessionCacheType ) )
 );
 
-Profiler::instance()->scopedProfileOut( $ps_memcached );
+Profiler::instance()->scopedProfileOut( $ps_misc );
 
 // Most of the config is out, some might want to run hooks here.
 Hooks::run( 'SetupAfterCache' );
@@ -827,8 +820,6 @@ if ( $wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin ) {
        ], '$wgAuth is ' . get_class( $wgAuth ) );
 }
 
-// Set up the session
-$ps_session = Profiler::instance()->scopedProfileIn( $fname . '-session' );
 /**
  * @var MediaWiki\Session\SessionId|null $wgInitialSessionId The persistent
  * session ID (if any) loaded at startup
@@ -892,7 +883,6 @@ if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
                );
        }
 }
-Profiler::instance()->scopedProfileOut( $ps_session );
 
 /**
  * @var User $wgUser
@@ -929,22 +919,7 @@ $ps_extensions = Profiler::instance()->scopedProfileIn( $fname . '-extensions' )
 // of the extension file. This allows the extension to perform
 // any necessary initialisation in the fully initialised environment
 foreach ( $wgExtensionFunctions as $func ) {
-       // Allow closures in PHP 5.3+
-       if ( is_object( $func ) && $func instanceof Closure ) {
-               $profName = $fname . '-extensions-closure';
-       } elseif ( is_array( $func ) ) {
-               if ( is_object( $func[0] ) ) {
-                       $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
-               } else {
-                       $profName = $fname . '-extensions-' . implode( '::', $func );
-               }
-       } else {
-               $profName = $fname . '-extensions-' . strval( $func );
-       }
-
-       $ps_ext_func = Profiler::instance()->scopedProfileIn( $profName );
        call_user_func( $func );
-       Profiler::instance()->scopedProfileOut( $ps_ext_func );
 }
 
 // If the session user has a 0 id but a valid name, that means we need to
@@ -952,13 +927,11 @@ foreach ( $wgExtensionFunctions as $func ) {
 if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
        $sessionUser = MediaWiki\Session\SessionManager::getGlobalSession()->getUser();
        if ( $sessionUser->getId() === 0 && User::isValidUserName( $sessionUser->getName() ) ) {
-               $ps_autocreate = Profiler::instance()->scopedProfileIn( $fname . '-autocreate' );
                $res = MediaWiki\Auth\AuthManager::singleton()->autoCreateUser(
                        $sessionUser,
                        MediaWiki\Auth\AuthManager::AUTOCREATE_SOURCE_SESSION,
                        true
                );
-               Profiler::instance()->scopedProfileOut( $ps_autocreate );
                \MediaWiki\Logger\LoggerFactory::getInstance( 'authevents' )->info( 'Autocreation attempt', [
                        'event' => 'autocreate',
                        'status' => $res,
index 0141b9e..ec63910 100644 (file)
@@ -109,8 +109,13 @@ abstract class FormAction extends Action {
         *
         * If you don't want to do anything with the form, just return false here.
         *
+        * This method will be passed to the HTMLForm as a submit callback (see
+        * HTMLForm::setSubmitCallback) and must return as documented for HTMLForm::trySubmit.
+        *
+        * @see HTMLForm::setSubmitCallback()
+        * @see HTMLForm::trySubmit()
         * @param array $data
-        * @return bool|array True for success, false for didn't-try, array of errors on failure
+        * @return bool|string|array|Status Must return as documented for HTMLForm::trySubmit
         */
        abstract public function onSubmit( $data );
 
index 528e0e2..aaccc0c 100644 (file)
@@ -40,9 +40,7 @@ class WatchAction extends FormAction {
        }
 
        public function onSubmit( $data ) {
-               self::doWatch( $this->getTitle(), $this->getUser() );
-
-               return true;
+               return self::doWatch( $this->getTitle(), $this->getUser() );
        }
 
        protected function checkCanExecute( User $user ) {
@@ -183,8 +181,10 @@ class WatchAction extends FormAction {
         * @param string $action Optionally override the action to 'watch'
         * @return string Token
         * @since 1.18
+        * @deprecated since 1.32 Use WatchAction::getWatchToken() with action 'unwatch' directly.
         */
        public static function getUnwatchToken( Title $title, User $user, $action = 'unwatch' ) {
+               wfDeprecated( __METHOD__, '1.32' );
                return self::getWatchToken( $title, $user, $action );
        }
 
index e77e251..b2a91c2 100644 (file)
@@ -18,7 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @license GNU GPL v2 or later
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 
index a1943be..b26a479 100644 (file)
@@ -7,7 +7,7 @@ $GLOBALS['IP'] = __DIR__ . '/../../';
 require_once __DIR__ . '/../AutoLoader.php';
 
 /**
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 class ComposerHookHandler {
index 168336b..6aa0b5b 100644 (file)
@@ -5,7 +5,7 @@ use Composer\Package\Package;
 use Composer\Semver\Constraint\Constraint;
 
 /**
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 class ComposerPackageModifier {
index 2194bed..52bc0cd 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 class ComposerVersionNormalizer {
index beac91e..b6ccb53 100644 (file)
@@ -28,7 +28,7 @@ use Wikimedia\Rdbms\LoadBalancer;
  * @file
  * @ingroup Database
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Daniel Kinzler
  */
 abstract class DBAccessBase implements IDBAccessObject {
index 076c37f..d906498 100644 (file)
@@ -24,7 +24,7 @@ namespace MediaWiki\Interwiki;
  * @since 1.29
  * @ingroup InterwikiLookup
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  */
 
 use Interwiki;
index 454fd41..dd734af 100644 (file)
@@ -19,7 +19,7 @@
  * @version 0.1.1 -- 2010-09-11
  * @author Trevor Parscal <tparscal@wikimedia.org>
  * @copyright Copyright 2010 Wikimedia Foundation
- * @license http://www.apache.org/licenses/LICENSE-2.0
+ * @license Apache-2.0
  */
 
 /**
index 79d1374..a9b26ac 100644 (file)
@@ -29,7 +29,7 @@
  *
  * @file
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 abstract class GenericArrayObject extends ArrayObject {
index f95bb1e..06589d2 100644 (file)
@@ -164,7 +164,7 @@ class IP {
                }
                if ( self::isIPv4( $ip ) ) {
                        // Remove leading 0's from octet representation of IPv4 address
-                       $ip = preg_replace( '/(?:^|(?<=\.))0+(?=[1-9]|0\.|0$)/', '', $ip );
+                       $ip = preg_replace( '!(?:^|(?<=\.))0+(?=[1-9]|0[./]|0$)!', '', $ip );
                        return $ip;
                }
                // Remove any whitespaces, convert to upper case
index 5ecfc7c..43cd7db 100644 (file)
@@ -4,7 +4,10 @@
  *
  * @file
  * @author Paul Copperman <paul.copperman@gmail.com>
- * @license Choose any of Apache, MIT, GPL, LGPL
+ * @license Apache-2.0
+ * @license MIT
+ * @license GPL-2.0-or-later
+ * @license LGPL-2.1-or-later
  */
 
 /**
index a5af026..0d22382 100644 (file)
@@ -18,7 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.25
  */
 
index ef00634..8078e2e 100644 (file)
@@ -19,7 +19,7 @@
  *
  * @file
  * @author Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.22
  */
 
index a2a899b..ee67618 100644 (file)
@@ -18,7 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.27
  */
 
index 31c196a..e9e338d 100644 (file)
@@ -24,7 +24,7 @@
  *
  * @file
  * @author Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.19
  */
 
index 0ffe691..0cf3e6d 100644 (file)
@@ -19,7 +19,7 @@
  *
  * @file
  * @author Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.19
  */
 use MediaWiki\Linker\LinkRenderer;
index 8775097..7a6fb9d 100644 (file)
@@ -18,7 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.25
  */
 
index 43ca0ea..637a8e7 100644 (file)
@@ -19,7 +19,7 @@
  *
  * @file
  * @author Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.22
  */
 
index 382e4ad..911ab95 100644 (file)
@@ -19,7 +19,7 @@
  *
  * @file
  * @author Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.22
  */
 
index 694fa7f..a08427a 100644 (file)
@@ -19,7 +19,7 @@
  *
  * @file
  * @author Kunal Grover
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.24
  */
 
index 894f59b..e02a703 100644 (file)
@@ -19,7 +19,7 @@
  *
  * @file
  * @author Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.22
  */
 
index 64ec626..931829a 100644 (file)
@@ -18,7 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.26
  */
 
index 4b4d19f..8cdd2af 100644 (file)
@@ -19,7 +19,7 @@
  *
  * @file
  * @author Alexandre Emsenhuber
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.22
  */
 
index 6c53671..a73052d 100644 (file)
@@ -18,7 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  * @since 1.25
  */
 
index 13b5559..19f5144 100644 (file)
@@ -18,7 +18,7 @@
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  */
 
 /**
index a38e79b..e4de0a1 100644 (file)
@@ -20,7 +20,7 @@
  * @ingroup Media
  * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason, 2009 Brent Garber
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
+ * @license GPL-2.0-or-later
  * @see http://exif.org/Exif2-2.PDF The Exif 2.2 specification
  * @file
  */
index f683da2..2a8b375 100644 (file)
@@ -20,7 +20,7 @@
  * @ingroup Media
  * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason, 2009 Brent Garber, 2010 Brian Wolff
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
+ * @license GPL-2.0-or-later
  * @see http://exif.org/Exif2-2.PDF The Exif 2.2 specification
  * @file
  */
index fc93b23..e00a5b3 100644 (file)
@@ -22,7 +22,7 @@
  * @author "Derk-Jan Hartman <hartman _at_ videolan d0t org>"
  * @author Brion Vibber
  * @copyright Copyright © 2010-2010 Brion Vibber, Derk-Jan Hartman
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
+ * @license GPL-2.0-or-later
  */
 
 /**
index f3cd1e8..625c899 100644 (file)
@@ -24,7 +24,7 @@
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  * @author Katie Filbert < aude.wiki@gmail.com >
  */
index 7fcfbe5..b1da25c 100644 (file)
@@ -26,7 +26,7 @@ use Wikimedia\Rdbms\LoadBalancer;
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  * @author Daniel Kinzler
  */
index 9654440..c168a47 100644 (file)
@@ -17,7 +17,7 @@
  *
  * @file
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  */
 
 /**
index 8a12c4f..a81ddca 100644 (file)
@@ -26,7 +26,7 @@ use UtfNormal\Validator;
  *
  * @since 1.27
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author John Erling Blad < jeblad@gmail.com >
  * @author Daniel Kinzler
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
index e1e7ce6..14c9a73 100644 (file)
@@ -22,7 +22,7 @@ use MediaWiki\Site\MediaWikiPageNameNormalizer;
  *
  * @file
  * @ingroup Site
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author John Erling Blad < jeblad@gmail.com >
  * @author Daniel Kinzler
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
index f5e3f22..01b2a3c 100644 (file)
@@ -23,7 +23,7 @@
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 class Site implements Serializable {
index 01b838e..0c9f996 100644 (file)
@@ -24,7 +24,7 @@
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Daniel Kinzler
  */
 class SiteExporter {
index 5e13d06..956bdab 100644 (file)
@@ -24,7 +24,7 @@
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Daniel Kinzler
  */
 class SiteImporter {
index b942d6e..726ab46 100644 (file)
@@ -23,7 +23,7 @@
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 class SiteList extends GenericArrayObject {
index 610bf0b..70fc453 100644 (file)
@@ -23,7 +23,7 @@
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  */
 interface SiteLookup {
 
index 2f8a113..e0b8d27 100644 (file)
@@ -23,7 +23,7 @@
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Daniel Kinzler
  */
 class SiteSQLStore {
index 10e0c1b..13800d0 100644 (file)
@@ -23,7 +23,7 @@
  * @file
  * @ingroup Site
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 interface SiteStore extends SiteLookup {
index b4046e3..f0d6ce1 100644 (file)
@@ -20,7 +20,7 @@
  *
  * @file
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  */
 class SitesCacheFileBuilder {
 
index 940f69c..fbd801d 100644 (file)
@@ -21,7 +21,7 @@
  * @ingroup SpecialPage
  * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  */
 
 /**
index 506ee00..a477b64 100644 (file)
@@ -13,7 +13,7 @@ use Wikimedia\Rdbms\LoadBalancer;
  * @file
  * @ingroup Watchlist
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  */
 class WatchedItemQueryService {
 
index 93d5033..873ae2d 100644 (file)
@@ -11,7 +11,7 @@ use Wikimedia\Rdbms\IDatabase;
  * @file
  * @ingroup Watchlist
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  */
 interface WatchedItemQueryServiceExtension {
 
index c4d1dfc..18c05bf 100644 (file)
@@ -10,7 +10,7 @@ use \OOUI\LabelWidget;
  * Select and input widget.
  *
  * @copyright 2011-2018 MediaWiki Widgets Team and others; see AUTHORS.txt
- * @license The MIT License (MIT); see LICENSE.txt
+ * @license MIT
  */
 class SizeFilterWidget extends \OOUI\Widget {
 
index 1f9b767..07005d4 100644 (file)
@@ -19,8 +19,8 @@
  *
  * @file
  * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
- * @license http://www.gnu.org/copyleft/fdl.html GNU Free Documentation License
+ * @license GPL-2.0-or-later
+ * @license GFDL-1.3-or-later
  * @ingroup Language
  */
 
index 4c75a51..94aac60 100644 (file)
@@ -29,7 +29,7 @@
 
 /**
  * @copyright Copyright © 2006, Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  */
 
 $linkTrail = '/^([a-zA-ZĀāČčĒēĢģĪīĶķĻļŅņŠšŪūŽž]+)(.*)$/sDu';
index 7572c67..816cff0 100644 (file)
@@ -35,8 +35,8 @@
  */
 
 /**
- * @license http://www.gnu.org/copyleft/fdl.html GNU Free Documentation License
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
+ * @license GFDL-1.3-or-later
+ * @license GPL-2.0-or-later
  *
  * @see https://meta.wikimedia.org/w/index.php?title=LanguageNn.php&action=history
  * @see https://nn.wikipedia.org/w/index.php?title=Brukar:Dittaeva/LanguageNn.php&action=history
index 4953343..b0ee966 100644 (file)
@@ -11,7 +11,7 @@ require_once $basePath . '/maintenance/Maintenance.php';
  *
  * @since 1.29
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Florian Schmidt
  */
 class AddSite extends Maintenance {
index c1935a7..82bb928 100644 (file)
@@ -31,8 +31,7 @@ class DeleteAutoPatrolLogs extends Maintenance {
                $this->addOption( 'dry-run', 'Print debug info instead of actually deleting' );
                $this->addOption(
                        'check-old',
-                       'Check old patrol logs (for deleting old format autopatrols).' .
-                               'Note that this will not delete rows older than 2011 (MediaWiki 1.18).'
+                       'Check old patrol logs (for deleting old format autopatrols).'
                );
                $this->addOption(
                        'before',
@@ -156,17 +155,27 @@ class DeleteAutoPatrolLogs extends Maintenance {
                $autopatrols = [];
                foreach ( $result as $row ) {
                        $last = $row->log_id;
-                       Wikimedia\suppressWarnings();
-                       $params = unserialize( $row->log_params );
-                       Wikimedia\restoreWarnings();
+                       $logEntry = DatabaseLogEntry::newFromRow( $row );
+                       $params = $logEntry->getParameters();
+                       if ( !is_array( $params ) ) {
+                               continue;
+                       }
 
-                       // Skipping really old rows, before 2011
-                       if ( !is_array( $params ) || !array_key_exists( '6::auto', $params ) ) {
+                       // This logic belongs to PatrolLogFormatter::getMessageKey
+                       // and LogFormatter::extractParameters the 'auto' value is logically presented as key [5].
+                       // For legacy case the logical key is index + 3, meaning [2].
+                       // For the modern case, the logical key is index - 1 meaning [6].
+                       if ( array_key_exists( '6::auto', $params ) ) {
+                               // Between 2011-2016 autopatrol logs
+                               $auto = $params['6::auto'] === true;
+                       } elseif ( $logEntry->isLegacy() === true && array_key_exists( 2, $params ) ) {
+                               // Pre-2011 autopatrol logs
+                               $auto = $params[2] === '1';
+                       } else {
                                continue;
                        }
 
-                       $auto = $params['6::auto'];
-                       if ( $auto ) {
+                       if ( $auto === true ) {
                                $autopatrols[] = $row->log_id;
                        }
                }
index 736b12b..4456c75 100644 (file)
@@ -9,7 +9,7 @@ require_once $basePath . '/maintenance/Maintenance.php';
  *
  * @since 1.25
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Daniel Kinzler
  */
 class ExportSites extends Maintenance {
index be6cc05..6859eb4 100644 (file)
@@ -9,7 +9,7 @@ require_once $basePath . '/maintenance/Maintenance.php';
  *
  * @since 1.25
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Daniel Kinzler
  */
 class ImportSites extends Maintenance {
index b87a716..cf2fe54 100644 (file)
@@ -46,7 +46,7 @@
  * @file
  * @ingroup Maintenance
  * @author Antoine Musso <hashar at free dot fr>
- * @license GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  */
 
 require_once __DIR__ . '/Maintenance.php';
index 4458901..d90a4a7 100644 (file)
@@ -20,7 +20,7 @@
  * @file
  * @ingroup Maintenance
  * @author Rob Church <robchur@gmail.com>
- * @license GNU General Public Licence 2.0 or later
+ * @license GPL-2.0-or-later
  */
 
 use Wikimedia\Rdbms\IDatabase;
index 08f009b..1adb13e 100644 (file)
@@ -26,7 +26,7 @@
  * @author Brion Vibber
  * @author Rob Church <robchur@gmail.com>
  *
- * @license GNU General Public License 2.0 or later
+ * @license GPL-2.0-or-later
  */
 
 require_once __DIR__ . '/Maintenance.php';
index b9b2161..b92ff2e 100644 (file)
@@ -46,8 +46,8 @@ $response->header( 'Cache-control: max-age=600' );
 print '<?xml version="1.0"?>';
 print Xml::openElement( 'OpenSearchDescription',
        [
-               'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
-               'xmlns:moz' => 'http://www.mozilla.org/2006/browser/search/' ] );
+               'xmlns' => 'http://www.opensearch.org/Specifications/OpenSearch/1.1',
+               'xmlns:moz' => 'https://www.mozilla.org/2006/browser/search/' ] );
 
 /* The spec says the ShortName must be no longer than 16 characters,
  * but 16 is *realllly* short. In practice, browsers don't appear to care
index b96b491..9c8b957 100644 (file)
@@ -6,7 +6,7 @@
  * @group Action
  * @group Database
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Thiemo Kreuz
  */
 class ActionTest extends MediaWikiTestCase {
diff --git a/tests/phpunit/includes/actions/WatchActionTest.php b/tests/phpunit/includes/actions/WatchActionTest.php
new file mode 100644 (file)
index 0000000..044c30a
--- /dev/null
@@ -0,0 +1,367 @@
+<?php
+
+/**
+ * @covers WatchAction
+ *
+ * @group Action
+ */
+class WatchActionTest extends MediaWikiTestCase {
+
+       /**
+        * @var WatchAction
+        */
+       private $watchAction;
+
+       /**
+        * @var WikiPage
+        */
+       private $testWikiPage;
+
+       protected function setUp() {
+               parent::setUp();
+
+               $testTitle = Title::newFromText( 'UTTest' );
+               $this->testWikiPage = new WikiPage( $testTitle );
+               $testContext = new DerivativeContext( RequestContext::getMain() );
+               $testContext->setTitle( $testTitle );
+               $this->watchAction = new WatchAction( $this->testWikiPage, $testContext );
+       }
+
+       /**
+        * @throws MWException
+        */
+       protected function tearDown() {
+               parent::tearDown();
+
+               Hooks::clear( 'WatchArticle' );
+               Hooks::clear( 'UnwatchArticle' );
+       }
+
+       /**
+        * @covers WatchAction::getName()
+        */
+       public function testGetName() {
+               $this->assertEquals( 'watch', $this->watchAction->getName() );
+       }
+
+       /**
+        * @covers WatchAction::requiresUnblock()
+        */
+       public function testRequiresUnlock() {
+               $this->assertFalse( $this->watchAction->requiresUnblock() );
+       }
+
+       /**
+        * @covers WatchAction::doesWrites()
+        */
+       public function testDoesWrites() {
+               $this->assertTrue( $this->watchAction->doesWrites() );
+       }
+
+       /**
+        * @covers WatchAction::onSubmit()
+        * @covers WatchAction::doWatch()
+        */
+       public function testOnSubmit() {
+               /** @var Status $actual */
+               $actual = $this->watchAction->onSubmit( [] );
+
+               $this->assertTrue( $actual->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::onSubmit()
+        * @covers WatchAction::doWatch()
+        */
+       public function testOnSubmitHookAborted() {
+               Hooks::register( 'WatchArticle', function () {
+                       return false;
+               } );
+
+               /** @var Status $actual */
+               $actual = $this->watchAction->onSubmit( [] );
+
+               $this->assertInstanceOf( Status::class, $actual );
+               $this->assertTrue( $actual->hasMessage( 'hookaborted' ) );
+       }
+
+       /**
+        * @covers WatchAction::checkCanExecute()
+        */
+       public function testShowUserNotLoggedIn() {
+               $notLoggedInUser = new User();
+               $testContext = new DerivativeContext( $this->watchAction->getContext() );
+               $testContext->setUser( $notLoggedInUser );
+               $watchAction = new WatchAction( $this->testWikiPage, $testContext );
+               $this->setExpectedException( UserNotLoggedIn::class );
+
+               $watchAction->show();
+       }
+
+       /**
+        * @covers WatchAction::checkCanExecute()
+        */
+       public function testShowUserLoggedInNoException() {
+               $loggedInUser = $this->getMock( User::class );
+               $loggedInUser->method( 'isLoggedIn' )->willReturn( true );
+               $testContext = new DerivativeContext( $this->watchAction->getContext() );
+               $testContext->setUser( $loggedInUser );
+               $watchAction = new WatchAction( $this->testWikiPage, $testContext );
+
+               $exception = null;
+               try {
+                       $watchAction->show();
+               } catch ( UserNotLoggedIn $e ) {
+                       $exception = $e;
+               }
+               $this->assertNull( $exception,
+                       'UserNotLoggedIn exception should not be thrown if user is logged in.' );
+       }
+
+       /**
+        * @covers WatchAction::onSuccess()
+        */
+       public function testOnSuccessMainNamespaceTitle() {
+               $testContext = $this->getMock(
+                       DerivativeContext::class,
+                       [ 'msg' ],
+                       [ $this->watchAction->getContext() ]
+               );
+               $testOutput = new OutputPage( $testContext );
+               $testContext->setOutput( $testOutput );
+               $testContext->method( 'msg' )->willReturnCallback( function ( $msgKey ) {
+                       return new RawMessage( $msgKey );
+               } );
+               $watchAction = new WatchAction( $this->testWikiPage, $testContext );
+
+               $watchAction->onSuccess();
+
+               $this->assertEquals( '<p>addedwatchtext
+</p>', $testOutput->getHTML() );
+       }
+
+       /**
+        * @covers WatchAction::onSuccess()
+        */
+       public function testOnSuccessTalkPage() {
+               $testContext = $this->getMock(
+                       DerivativeContext::class,
+                       [],
+                       [ $this->watchAction->getContext() ]
+               );
+               $testOutput = new OutputPage( $testContext );
+               $testContext->method( 'getOutput' )->willReturn( $testOutput );
+               $testContext->method( 'msg' )->willReturnCallback( function ( $msgKey ) {
+                       return new RawMessage( $msgKey );
+               } );
+               $talkPageTitle = Title::newFromText( 'Talk:UTTest' );
+               $testContext->setTitle( $talkPageTitle );
+               $watchAction = new WatchAction( new WikiPage( $talkPageTitle ), $testContext );
+
+               $watchAction->onSuccess();
+
+               $this->assertEquals( '<p>addedwatchtext-talk
+</p>', $testOutput->getHTML() );
+       }
+
+       /**
+        * @covers WatchAction::doWatch()
+        */
+       public function testDoWatchNoCheckRights() {
+               $notPermittedUser = $this->getMock( User::class );
+               $notPermittedUser->method( 'isAllowed' )->willReturn( false );
+
+               $actual = WatchAction::doWatch( $this->testWikiPage->getTitle(), $notPermittedUser, false );
+
+               $this->assertTrue( $actual->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::doWatch()
+        */
+       public function testDoWatchUserNotPermittedStatusNotGood() {
+               $notPermittedUser = $this->getMock( User::class );
+               $notPermittedUser->method( 'isAllowed' )->willReturn( false );
+
+               $actual = WatchAction::doWatch( $this->testWikiPage->getTitle(), $notPermittedUser, true );
+
+               $this->assertFalse( $actual->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::doWatch()
+        */
+       public function testDoWatchCallsUserAddWatch() {
+               $permittedUser = $this->getMock( User::class );
+               $permittedUser->method( 'isAllowed' )->willReturn( true );
+               $permittedUser->expects( $this->once() )
+                       ->method( 'addWatch' )
+                       ->with( $this->equalTo( $this->testWikiPage->getTitle() ), $this->equalTo( true ) );
+
+               $actual = WatchAction::doWatch( $this->testWikiPage->getTitle(), $permittedUser );
+
+               $this->assertTrue( $actual->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::doUnWatch()
+        */
+       public function testDoUnWatchWithoutRights() {
+               $notPermittedUser = $this->getMock( User::class );
+               $notPermittedUser->method( 'isAllowed' )->willReturn( false );
+
+               $actual = WatchAction::doUnWatch( $this->testWikiPage->getTitle(), $notPermittedUser );
+
+               $this->assertFalse( $actual->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::doUnWatch()
+        */
+       public function testDoUnWatchUserHookAborted() {
+               $permittedUser = $this->getMock( User::class );
+               $permittedUser->method( 'isAllowed' )->willReturn( true );
+               Hooks::register( 'UnwatchArticle', function () {
+                       return false;
+               } );
+
+               $status = WatchAction::doUnWatch( $this->testWikiPage->getTitle(), $permittedUser );
+
+               $this->assertFalse( $status->isGood() );
+               $errors = $status->getErrors();
+               $this->assertEquals( 1, count( $errors ) );
+               $this->assertEquals( 'hookaborted', $errors[0]['message'] );
+       }
+
+       /**
+        * @covers WatchAction::doUnWatch()
+        */
+       public function testDoUnWatchCallsUserRemoveWatch() {
+               $permittedUser = $this->getMock( User::class );
+               $permittedUser->method( 'isAllowed' )->willReturn( true );
+               $permittedUser->expects( $this->once() )
+                       ->method( 'removeWatch' )
+                       ->with( $this->equalTo( $this->testWikiPage->getTitle() ) );
+
+               $actual = WatchAction::doUnWatch( $this->testWikiPage->getTitle(), $permittedUser );
+
+               $this->assertTrue( $actual->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::getWatchToken()
+        */
+       public function testGetWatchTokenNormalizesToWatch() {
+               $user = $this->getMock( User::class );
+               $user->expects( $this->once() )
+                       ->method( 'getEditToken' )
+                       ->with( $this->equalTo( 'watch' ) );
+
+               WatchAction::getWatchToken( $this->watchAction->getTitle(), $user, 'INVALID_ACTION' );
+       }
+
+       /**
+        * @covers WatchAction::getWatchToken()
+        */
+       public function testGetWatchTokenProxiesUserGetEditToken() {
+               $user = $this->getMock( User::class );
+               $user->expects( $this->once() )->method( 'getEditToken' );
+
+               WatchAction::getWatchToken( $this->watchAction->getTitle(), $user );
+       }
+
+       /**
+        * @covers WatchAction::getUnwatchToken()
+        */
+       public function testGetUnwatchToken() {
+               $user = $this->getMock( User::class );
+               $user->expects( $this->once() )->method( 'getEditToken' );
+               $this->hideDeprecated( 'WatchAction::getUnwatchToken' );
+
+               WatchAction::getUnWatchToken( $this->watchAction->getTitle(), $user );
+       }
+
+       /**
+        * @covers WatchAction::doWatchOrUnwatch()
+        */
+       public function testDoWatchOrUnwatchUserNotLoggedIn() {
+               $user = $this->getLoggedInIsWatchedUser( false );
+               $user->expects( $this->never() )->method( 'removeWatch' );
+               $user->expects( $this->never() )->method( 'addWatch' );
+
+               $status = WatchAction::doWatchOrUnwatch( true, $this->watchAction->getTitle(), $user );
+
+               $this->assertTrue( $status->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::doWatchOrUnwatch()
+        */
+       public function testDoWatchOrUnwatchSkipsIfAlreadyWatched() {
+               $user = $this->getLoggedInIsWatchedUser();
+               $user->expects( $this->never() )->method( 'removeWatch' );
+               $user->expects( $this->never() )->method( 'addWatch' );
+
+               $status = WatchAction::doWatchOrUnwatch( true, $this->watchAction->getTitle(), $user );
+
+               $this->assertTrue( $status->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::doWatchOrUnwatch()
+        */
+       public function testDoWatchOrUnwatchSkipsIfAlreadyUnWatched() {
+               $user = $this->getLoggedInIsWatchedUser( true, false );
+               $user->expects( $this->never() )->method( 'removeWatch' );
+               $user->expects( $this->never() )->method( 'addWatch' );
+
+               $status = WatchAction::doWatchOrUnwatch( false, $this->watchAction->getTitle(), $user );
+
+               $this->assertTrue( $status->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::doWatchOrUnwatch()
+        */
+       public function testDoWatchOrUnwatchWatchesIfWatch() {
+               $user = $this->getLoggedInIsWatchedUser( true, false );
+               $user->expects( $this->never() )->method( 'removeWatch' );
+               $user->expects( $this->once() )
+                       ->method( 'addWatch' )
+                       ->with( $this->equalTo( $this->testWikiPage->getTitle() ), $this->equalTo( false ) );
+
+               $status = WatchAction::doWatchOrUnwatch( true, $this->watchAction->getTitle(), $user );
+
+               $this->assertTrue( $status->isGood() );
+       }
+
+       /**
+        * @covers WatchAction::doWatchOrUnwatch()
+        */
+       public function testDoWatchOrUnwatchUnwatchesIfUnwatch() {
+               $user = $this->getLoggedInIsWatchedUser();
+               $user->method( 'isAllowed' )->willReturn( true );
+               $user->expects( $this->never() )->method( 'addWatch' );
+               $user->expects( $this->once() )
+                       ->method( 'removeWatch' )
+                       ->with( $this->equalTo( $this->testWikiPage->getTitle() ) );
+
+               $status = WatchAction::doWatchOrUnwatch( false, $this->watchAction->getTitle(), $user );
+
+               $this->assertTrue( $status->isGood() );
+       }
+
+       /**
+        * @param bool $isLoggedIn Whether the user should be "marked" as logged in
+        * @param bool $isWatched The value any call to isWatched should return
+        * @return PHPUnit_Framework_MockObject_MockObject
+        */
+       private function getLoggedInIsWatchedUser( $isLoggedIn = true, $isWatched = true ) {
+               $user = $this->getMock( User::class );
+               $user->method( 'isLoggedIn' )->willReturn( $isLoggedIn );
+               $user->method( 'isWatched' )->willReturn( $isWatched );
+
+               return $user;
+       }
+
+}
index e20cf94..05e15a3 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * @covers HTMLForm
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Gergő Tisza
  * @author Thiemo Mättig
  */
index bf8603d..b2e7ea4 100644 (file)
@@ -5,7 +5,7 @@
  *
  * @group JobQueue
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Thiemo Kreuz
  */
 class JobQueueMemoryTest extends PHPUnit\Framework\TestCase {
index 5960a16..1f73324 100644 (file)
@@ -6,7 +6,7 @@
  * @group JobQueue
  * @group Database
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Addshore
  */
 class CategoryMembershipChangeJobTest extends MediaWikiTestCase {
index 6ae7d60..27cae8a 100644 (file)
@@ -7,7 +7,7 @@ use MediaWiki\MediaWikiServices;
  * @group JobQueue
  * @group Database
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Addshore
  */
 class ClearUserWatchlistJobTest extends MediaWikiTestCase {
index 9702c82..9ec53c0 100644 (file)
@@ -325,6 +325,7 @@ class IPTest extends PHPUnit\Framework\TestCase {
                        [ '0.0.0.0', '0.0.0.0' ],
                        [ '0.0.0.0', '00.00.00.00' ],
                        [ '0.0.0.0', '000.000.000.000' ],
+                       [ '0.0.0.0/24', '000.000.000.000/24' ],
                        [ '141.0.11.253', '141.000.011.253' ],
                        [ '1.2.4.5', '1.2.4.5' ],
                        [ '1.2.4.5', '01.02.04.05' ],
index e0d059f..879acfe 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Addshore
  *
  * @covers SpecialBlankpage
index 274a23c..4809e1b 100644 (file)
@@ -5,7 +5,7 @@
  *
  * @since 1.26
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  * @author Daniel Kinzler
  * @author Addshore
index f799b11..236c5c4 100644 (file)
@@ -5,7 +5,7 @@
  *
  * @since 1.30
  *
- * @license GNU GPL v2+
+ * @license GPL-2.0-or-later
  */
 class SpecialShortpagesTest extends MediaWikiTestCase {
 
index c141817..cd68fa5 100644 (file)
@@ -92,6 +92,24 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                        'log_timestamp' => 20091223210426
                ];
 
+               // Autopatrol #4 very old way
+               $logs[] = [
+                       'log_type' => 'patrol',
+                       'log_action' => 'patrol',
+                       'log_user' => 7257,
+                       'log_params' => "9227851\n0\n1",
+                       'log_timestamp' => 20081223210426
+               ];
+
+               // Manual patrol #3 very old way
+               $logs[] = [
+                       'log_type' => 'patrol',
+                       'log_action' => 'patrol',
+                       'log_user' => 7258,
+                       'log_params' => "9227851\n0\n0",
+                       'log_timestamp' => 20091223210426
+               ];
+
                wfGetDB( DB_MASTER )->insert( 'logging', $logs );
        }
 
@@ -132,6 +150,16 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                                'log_action' => 'patrol',
                                'log_user' => '7256',
                        ],
+                       (object)[
+                               'log_type' => 'patrol',
+                               'log_action' => 'patrol',
+                               'log_user' => '7257',
+                       ],
+                       (object)[
+                               'log_type' => 'patrol',
+                               'log_action' => 'patrol',
+                               'log_user' => '7258',
+                       ],
                ];
 
                $cases = [
@@ -146,6 +174,8 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                                        $allRows[3],
                                        $allRows[5],
                                        $allRows[6],
+                                       $allRows[7],
+                                       $allRows[8],
                                ],
                                [ '--sleep', '0', '-q' ]
                        ],
@@ -157,6 +187,8 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                                        $allRows[4],
                                        $allRows[5],
                                        $allRows[6],
+                                       $allRows[7],
+                                       $allRows[8],
                                ],
                                [ '--sleep', '0', '--before', '20060123210426', '-q' ]
                        ],
@@ -168,6 +200,7 @@ class DeleteAutoPatrolLogsTest extends MaintenanceBaseTestCase {
                                        $allRows[3],
                                        $allRows[4],
                                        $allRows[6],
+                                       $allRows[8],
                                ],
                                [ '--sleep', '0', '--check-old', '-q' ]
                        ],