Merge "Change disabled saved filter tooltip"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 13 Nov 2017 13:42:11 +0000 (13:42 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 13 Nov 2017 13:42:11 +0000 (13:42 +0000)
98 files changed:
RELEASE-NOTES-1.30
RELEASE-NOTES-1.31
autoload.php
composer.json
includes/DefaultSettings.php
includes/EditPage.php
includes/GlobalFunctions.php
includes/Html.php
includes/Setup.php
includes/Title.php
includes/WatchedItem.php [deleted file]
includes/WatchedItemQueryService.php [deleted file]
includes/WatchedItemQueryServiceExtension.php [deleted file]
includes/WatchedItemStore.php [deleted file]
includes/api/i18n/ko.json
includes/api/i18n/nb.json
includes/db/MWLBFactory.php
includes/deferred/HTMLCacheUpdate.php
includes/deferred/LinksUpdate.php
includes/filerepo/file/File.php
includes/filerepo/file/LocalFile.php
includes/installer/i18n/eu.json
includes/jobqueue/jobs/HTMLCacheUpdateJob.php
includes/libs/HashRing.php
includes/page/PageArchive.php
includes/page/WikiFilePage.php
includes/page/WikiPage.php
includes/profiler/ProfilerFunctions.php [deleted file]
includes/watcheditem/WatchedItem.php [new file with mode: 0644]
includes/watcheditem/WatchedItemQueryService.php [new file with mode: 0644]
includes/watcheditem/WatchedItemQueryServiceExtension.php [new file with mode: 0644]
includes/watcheditem/WatchedItemStore.php [new file with mode: 0644]
languages/i18n/ast.json
languages/i18n/azb.json
languages/i18n/be-tarask.json
languages/i18n/ca.json
languages/i18n/cs.json
languages/i18n/de.json
languages/i18n/en.json
languages/i18n/et.json
languages/i18n/fa.json
languages/i18n/fr.json
languages/i18n/ga.json
languages/i18n/gl.json
languages/i18n/hu.json
languages/i18n/la.json
languages/i18n/lad.json
languages/i18n/lb.json
languages/i18n/lki.json
languages/i18n/lv.json
languages/i18n/map-bms.json
languages/i18n/mr.json
languages/i18n/nb.json
languages/i18n/nl.json
languages/i18n/ps.json
languages/i18n/pt-br.json
languages/i18n/sat.json
languages/i18n/shn.json
languages/i18n/sr-ec.json
languages/i18n/sr-el.json
languages/i18n/sv.json
languages/i18n/zh-hant.json
languages/messages/MessagesMwl.php
maintenance/checkComposerLockUpToDate.php
maintenance/populateRecentChangesSource.php
maintenance/userOptions.inc [deleted file]
maintenance/userOptions.php
resources/src/mediawiki.action/mediawiki.action.history.styles.css
resources/src/mediawiki.legacy/commonPrint.css
resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js
resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.ItemModel.js
resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.SavedQueriesModel.js
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.skinning/content.externallinks.css
resources/src/mediawiki.skinning/elements.css
resources/src/mediawiki.skinning/interface.css
resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.less
resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.styles.less
resources/src/mediawiki/mediawiki.notification.css
tests/common/TestsAutoLoader.php
tests/parser/parserTests.txt
tests/phpunit/autoload.ide.php
tests/phpunit/includes/RevisionContentHandlerDbTest.php [new file with mode: 0644]
tests/phpunit/includes/RevisionDbTestBase.php [new file with mode: 0644]
tests/phpunit/includes/RevisionIntegrationTest.php [deleted file]
tests/phpunit/includes/RevisionNoContentHandlerDbTest.php [new file with mode: 0644]
tests/phpunit/includes/RevisionTest.php [new file with mode: 0644]
tests/phpunit/includes/RevisionUnitTest.php [deleted file]
tests/phpunit/includes/WatchedItemIntegrationTest.php [deleted file]
tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php [deleted file]
tests/phpunit/includes/WatchedItemStoreIntegrationTest.php [deleted file]
tests/phpunit/includes/WatchedItemStoreUnitTest.php [deleted file]
tests/phpunit/includes/WatchedItemUnitTest.php [deleted file]
tests/phpunit/includes/watcheditem/WatchedItemIntegrationTest.php [new file with mode: 0644]
tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php [new file with mode: 0644]
tests/phpunit/includes/watcheditem/WatchedItemStoreIntegrationTest.php [new file with mode: 0644]
tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php [new file with mode: 0644]
tests/phpunit/includes/watcheditem/WatchedItemUnitTest.php [new file with mode: 0644]

index f79ae83..d92c38c 100644 (file)
@@ -80,12 +80,18 @@ section).
 === External library changes in 1.30 ===
 
 ==== Upgraded external libraries ====
-* mediawiki/mediawiki-codesniffer updated to 0.8.1.
-* wikimedia/composer-merge-plugin updated to 1.4.1.
+* Updated justinrainbow/json-schema from v3.0 to v5.2.
+* Updated mediawiki/mediawiki-codesniffer from v0.7.2 to v0.12.0.
+* Updated wikimedia/composer-merge-plugin from v1.4.0 to v1.4.1.
+* Updated wikimedia/relpath from v1.0.3 to v2.0.0.
+* Updated OOjs from v2.0.0 to v2.1.0.
+* Updated OOUI from v0.21.1 to v0.23.0.
+* Updated QUnit from v1.23.1 to v2.4.0.
 
 ==== New external libraries ====
 * The class \TestingAccessWrapper has been moved to the external library
   wikimedia/testing-access-wrapper and renamed \Wikimedia\TestingAccessWrapper.
+* Purtle, a fast, lightweight RDF generator.
 
 ==== Removed and replaced external libraries ====
 * …
index 9a4c74c..9ded68c 100644 (file)
@@ -24,7 +24,7 @@ production.
 === External library changes in 1.31 ===
 
 ==== Upgraded external libraries ====
-* 
+* Updated dev dependancy phpunit/phpunit from v4.8.35 to v4.8.36.
 
 ==== New external libraries ====
 * …
@@ -55,7 +55,7 @@ MediaWiki supports over 350 languages. Many localisations are updated
 regularly. Below only new and removed languages are listed, as well as
 changes to languages because of Phabricator reports.
 
-* 
+* (T180052) Mirandese (mwl) now supports gendered NS_USER/NS_USER_TALK namespaces.
 
 === Other changes in 1.31 ===
 * MessageBlobStore::insertMessageBlob() (deprecated in 1.27) was removed.
index 39ec4b0..edac2c5 100644 (file)
@@ -1568,7 +1568,7 @@ $wgAutoloadLocalClasses = [
        'UserMailer' => __DIR__ . '/includes/mail/UserMailer.php',
        'UserNamePrefixSearch' => __DIR__ . '/includes/user/UserNamePrefixSearch.php',
        'UserNotLoggedIn' => __DIR__ . '/includes/exception/UserNotLoggedIn.php',
-       'UserOptions' => __DIR__ . '/maintenance/userOptions.inc',
+       'UserOptionsMaintenance' => __DIR__ . '/maintenance/userOptions.php',
        'UserPasswordPolicy' => __DIR__ . '/includes/password/UserPasswordPolicy.php',
        'UserRightsProxy' => __DIR__ . '/includes/user/UserRightsProxy.php',
        'UserrightsPage' => __DIR__ . '/includes/specials/SpecialUserrights.php',
@@ -1591,10 +1591,10 @@ $wgAutoloadLocalClasses = [
        'WantedQueryPage' => __DIR__ . '/includes/specialpage/WantedQueryPage.php',
        'WantedTemplatesPage' => __DIR__ . '/includes/specials/SpecialWantedtemplates.php',
        'WatchAction' => __DIR__ . '/includes/actions/WatchAction.php',
-       'WatchedItem' => __DIR__ . '/includes/WatchedItem.php',
-       'WatchedItemQueryService' => __DIR__ . '/includes/WatchedItemQueryService.php',
-       'WatchedItemQueryServiceExtension' => __DIR__ . '/includes/WatchedItemQueryServiceExtension.php',
-       'WatchedItemStore' => __DIR__ . '/includes/WatchedItemStore.php',
+       'WatchedItem' => __DIR__ . '/includes/watcheditem/WatchedItem.php',
+       'WatchedItemQueryService' => __DIR__ . '/includes/watcheditem/WatchedItemQueryService.php',
+       'WatchedItemQueryServiceExtension' => __DIR__ . '/includes/watcheditem/WatchedItemQueryServiceExtension.php',
+       'WatchedItemStore' => __DIR__ . '/includes/watcheditem/WatchedItemStore.php',
        'WatchlistCleanup' => __DIR__ . '/maintenance/cleanupWatchlist.php',
        'WebInstaller' => __DIR__ . '/includes/installer/WebInstaller.php',
        'WebInstallerComplete' => __DIR__ . '/includes/installer/WebInstallerComplete.php',
index 7031cad..71c9398 100644 (file)
@@ -58,7 +58,7 @@
                "monolog/monolog": "~1.22.1",
                "nikic/php-parser": "2.1.0",
                "nmred/kafka-php": "0.1.5",
-               "phpunit/phpunit": "4.8.35",
+               "phpunit/phpunit": "4.8.36",
                "psy/psysh": "0.8.11",
                "wikimedia/avro": "1.7.7",
                "wikimedia/testing-access-wrapper": "~1.0",
index d9f032c..3cd7ef1 100644 (file)
@@ -5785,7 +5785,7 @@ $wgPasswordAttemptThrottle = [
 ];
 
 /**
- * @var Array Map of (grant => right => boolean)
+ * @var array Map of (grant => right => boolean)
  * Users authorize consumers (like Apps) to act on their behalf but only with
  * a subset of the user's normal account rights (signed off on by the user).
  * The possible rights to grant to a consumer are bundled into groups called
@@ -5887,7 +5887,7 @@ $wgGrantPermissions['createaccount']['createaccount'] = true;
 $wgGrantPermissions['privateinfo']['viewmyprivateinfo'] = true;
 
 /**
- * @var Array Map of grants to their UI grouping
+ * @var array Map of grants to their UI grouping
  * @since 1.27
  */
 $wgGrantPermissionGroups = [
index 4260c99..ff224c5 100644 (file)
@@ -3288,7 +3288,7 @@ class EditPage {
 
        protected function showFormBeforeText() {
                $out = $this->context->getOutput();
-               $out->addHTML( Html::hidden( 'wpSection', htmlspecialchars( $this->section ) ) );
+               $out->addHTML( Html::hidden( 'wpSection', $this->section ) );
                $out->addHTML( Html::hidden( 'wpStarttime', $this->starttime ) );
                $out->addHTML( Html::hidden( 'wpEdittime', $this->edittime ) );
                $out->addHTML( Html::hidden( 'editRevId', $this->editRevId ) );
index 1cff881..404d115 100644 (file)
@@ -3487,3 +3487,37 @@ function wfArrayPlus2d( array $baseArray, array $newValues ) {
 
        return $baseArray;
 }
+
+/**
+ * Get system resource usage of current request context.
+ * Invokes the getrusage(2) system call, requesting RUSAGE_SELF if on PHP5
+ * or RUSAGE_THREAD if on HHVM. Returns false if getrusage is not available.
+ *
+ * @since 1.24
+ * @return array|bool Resource usage data or false if no data available.
+ */
+function wfGetRusage() {
+       if ( !function_exists( 'getrusage' ) ) {
+               return false;
+       } elseif ( defined( 'HHVM_VERSION' ) && PHP_OS === 'Linux' ) {
+               return getrusage( 2 /* RUSAGE_THREAD */ );
+       } else {
+               return getrusage( 0 /* RUSAGE_SELF */ );
+       }
+}
+
+/**
+ * Begin profiling of a function
+ * @param string $functionname Name of the function we will profile
+ * @deprecated since 1.25
+ */
+function wfProfileIn( $functionname ) {
+}
+
+/**
+ * Stop profiling of a function
+ * @param string $functionname Name of the function we have profiled
+ * @deprecated since 1.25
+ */
+function wfProfileOut( $functionname = 'missing' ) {
+}
index 8fe4dbe..0988b05 100644 (file)
@@ -544,28 +544,7 @@ class Html {
                        if ( in_array( $key, self::$boolAttribs ) ) {
                                $ret .= " $key=\"\"";
                        } else {
-                               // Apparently we need to entity-encode \n, \r, \t, although the
-                               // spec doesn't mention that.  Since we're doing strtr() anyway,
-                               // we may as well not call htmlspecialchars().
-                               // @todo FIXME: Verify that we actually need to
-                               // escape \n\r\t here, and explain why, exactly.
-                               // We could call Sanitizer::encodeAttribute() for this, but we
-                               // don't because we're stubborn and like our marginal savings on
-                               // byte size from not having to encode unnecessary quotes.
-                               // The only difference between this transform and the one by
-                               // Sanitizer::encodeAttribute() is ' is not encoded.
-                               $map = [
-                                       '&' => '&amp;',
-                                       '"' => '&quot;',
-                                       '>' => '&gt;',
-                                       // '<' allegedly allowed per spec
-                                       // but breaks some tools if not escaped.
-                                       "<" => '&lt;',
-                                       "\n" => '&#10;',
-                                       "\r" => '&#13;',
-                                       "\t" => '&#9;'
-                               ];
-                               $ret .= " $key=$quote" . strtr( $value, $map ) . $quote;
+                               $ret .= " $key=$quote" . Sanitizer::encodeAttribute( $value ) . $quote;
                        }
                }
                return $ret;
index e4396ba..4c281b1 100644 (file)
@@ -37,8 +37,11 @@ if ( !defined( 'MEDIAWIKI' ) ) {
  * Pre-config setup: Before loading LocalSettings.php
  */
 
-// Grab profiling functions
-require_once "$IP/includes/profiler/ProfilerFunctions.php";
+// Get profiler configuraton
+$wgProfiler = [];
+if ( file_exists( "$IP/StartProfiler.php" ) ) {
+       require "$IP/StartProfiler.php";
+}
 
 // Start the autoloader, so that extensions can derive classes from core files
 require_once "$IP/includes/AutoLoader.php";
@@ -46,12 +49,6 @@ require_once "$IP/includes/AutoLoader.php";
 // Load up some global defines
 require_once "$IP/includes/Defines.php";
 
-// Start the profiler
-$wgProfiler = [];
-if ( file_exists( "$IP/StartProfiler.php" ) ) {
-       require "$IP/StartProfiler.php";
-}
-
 // Load default settings
 require_once "$IP/includes/DefaultSettings.php";
 
index d043b44..829be44 100644 (file)
@@ -4622,9 +4622,11 @@ class Title implements LinkTarget {
         * on the number of links. Typically called on create and delete.
         */
        public function touchLinks() {
-               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks' ) );
+               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'pagelinks', 'page-touch' ) );
                if ( $this->getNamespace() == NS_CATEGORY ) {
-                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this, 'categorylinks' ) );
+                       DeferredUpdates::addUpdate(
+                               new HTMLCacheUpdate( $this, 'categorylinks', 'category-touch' )
+                       );
                }
        }
 
diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php
deleted file mode 100644 (file)
index bfd1d61..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-<?php
-/**
- * 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 Watchlist
- */
-use MediaWiki\MediaWikiServices;
-use MediaWiki\Linker\LinkTarget;
-
-/**
- * Representation of a pair of user and title for watchlist entries.
- *
- * @author Tim Starling
- * @author Addshore
- *
- * @ingroup Watchlist
- */
-class WatchedItem {
-
-       /**
-        * @deprecated since 1.27, see User::IGNORE_USER_RIGHTS
-        */
-       const IGNORE_USER_RIGHTS = User::IGNORE_USER_RIGHTS;
-
-       /**
-        * @deprecated since 1.27, see User::CHECK_USER_RIGHTS
-        */
-       const CHECK_USER_RIGHTS = User::CHECK_USER_RIGHTS;
-
-       /**
-        * @deprecated Internal class use only
-        */
-       const DEPRECATED_USAGE_TIMESTAMP = -100;
-
-       /**
-        * @var bool
-        * @deprecated Internal class use only
-        */
-       public $checkRights = User::CHECK_USER_RIGHTS;
-
-       /**
-        * @var Title
-        * @deprecated Internal class use only
-        */
-       private $title;
-
-       /**
-        * @var LinkTarget
-        */
-       private $linkTarget;
-
-       /**
-        * @var User
-        */
-       private $user;
-
-       /**
-        * @var null|string the value of the wl_notificationtimestamp field
-        */
-       private $notificationTimestamp;
-
-       /**
-        * @param User $user
-        * @param LinkTarget $linkTarget
-        * @param null|string $notificationTimestamp the value of the wl_notificationtimestamp field
-        * @param bool|null $checkRights DO NOT USE - used internally for backward compatibility
-        */
-       public function __construct(
-               User $user,
-               LinkTarget $linkTarget,
-               $notificationTimestamp,
-               $checkRights = null
-       ) {
-               $this->user = $user;
-               $this->linkTarget = $linkTarget;
-               $this->notificationTimestamp = $notificationTimestamp;
-               if ( $checkRights !== null ) {
-                       $this->checkRights = $checkRights;
-               }
-       }
-
-       /**
-        * @return User
-        */
-       public function getUser() {
-               return $this->user;
-       }
-
-       /**
-        * @return LinkTarget
-        */
-       public function getLinkTarget() {
-               return $this->linkTarget;
-       }
-
-       /**
-        * Get the notification timestamp of this entry.
-        *
-        * @return bool|null|string
-        */
-       public function getNotificationTimestamp() {
-               // Back compat for objects constructed using self::fromUserTitle
-               if ( $this->notificationTimestamp === self::DEPRECATED_USAGE_TIMESTAMP ) {
-                       // wfDeprecated( __METHOD__, '1.27' );
-                       if ( $this->checkRights && !$this->user->isAllowed( 'viewmywatchlist' ) ) {
-                               return false;
-                       }
-                       $item = MediaWikiServices::getInstance()->getWatchedItemStore()
-                               ->loadWatchedItem( $this->user, $this->linkTarget );
-                       if ( $item ) {
-                               $this->notificationTimestamp = $item->getNotificationTimestamp();
-                       } else {
-                               $this->notificationTimestamp = false;
-                       }
-               }
-               return $this->notificationTimestamp;
-       }
-
-       /**
-        * Back compat pre 1.27 with the WatchedItemStore introduction
-        * @todo remove in 1.28/9
-        * -------------------------------------------------
-        */
-
-       /**
-        * @return Title
-        * @deprecated Internal class use only
-        */
-       public function getTitle() {
-               if ( !$this->title ) {
-                       $this->title = Title::newFromLinkTarget( $this->linkTarget );
-               }
-               return $this->title;
-       }
-
-       /**
-        * @deprecated since 1.27 Use the constructor, WatchedItemStore::getWatchedItem()
-        *             or WatchedItemStore::loadWatchedItem()
-        */
-       public static function fromUserTitle( $user, $title, $checkRights = User::CHECK_USER_RIGHTS ) {
-               wfDeprecated( __METHOD__, '1.27' );
-               return new self( $user, $title, self::DEPRECATED_USAGE_TIMESTAMP, (bool)$checkRights );
-       }
-
-       /**
-        * @deprecated since 1.27 Use User::addWatch()
-        * @return bool
-        */
-       public function addWatch() {
-               wfDeprecated( __METHOD__, '1.27' );
-               $this->user->addWatch( $this->getTitle(), $this->checkRights );
-               return true;
-       }
-
-       /**
-        * @deprecated since 1.27 Use User::removeWatch()
-        * @return bool
-        */
-       public function removeWatch() {
-               wfDeprecated( __METHOD__, '1.27' );
-               if ( $this->checkRights && !$this->user->isAllowed( 'editmywatchlist' ) ) {
-                       return false;
-               }
-               $this->user->removeWatch( $this->getTitle(), $this->checkRights );
-               return true;
-       }
-
-       /**
-        * @deprecated since 1.27 Use User::isWatched()
-        * @return bool
-        */
-       public function isWatched() {
-               wfDeprecated( __METHOD__, '1.27' );
-               return $this->user->isWatched( $this->getTitle(), $this->checkRights );
-       }
-
-       /**
-        * @deprecated since 1.27 Use WatchedItemStore::duplicateAllAssociatedEntries()
-        */
-       public static function duplicateEntries( Title $oldTitle, Title $newTitle ) {
-               wfDeprecated( __METHOD__, '1.27' );
-               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
-               $store->duplicateAllAssociatedEntries( $oldTitle, $newTitle );
-       }
-
-}
diff --git a/includes/WatchedItemQueryService.php b/includes/WatchedItemQueryService.php
deleted file mode 100644 (file)
index d0f45be..0000000
+++ /dev/null
@@ -1,684 +0,0 @@
-<?php
-
-use Wikimedia\Rdbms\IDatabase;
-use MediaWiki\Linker\LinkTarget;
-use Wikimedia\Assert\Assert;
-use Wikimedia\Rdbms\LoadBalancer;
-
-/**
- * Class performing complex database queries related to WatchedItems.
- *
- * @since 1.28
- *
- * @file
- * @ingroup Watchlist
- *
- * @license GNU GPL v2+
- */
-class WatchedItemQueryService {
-
-       const DIR_OLDER = 'older';
-       const DIR_NEWER = 'newer';
-
-       const INCLUDE_FLAGS = 'flags';
-       const INCLUDE_USER = 'user';
-       const INCLUDE_USER_ID = 'userid';
-       const INCLUDE_COMMENT = 'comment';
-       const INCLUDE_PATROL_INFO = 'patrol';
-       const INCLUDE_SIZES = 'sizes';
-       const INCLUDE_LOG_INFO = 'loginfo';
-
-       // FILTER_* constants are part of public API (are used in ApiQueryWatchlist and
-       // ApiQueryWatchlistRaw classes) and should not be changed.
-       // Changing values of those constants will result in a breaking change in the API
-       const FILTER_MINOR = 'minor';
-       const FILTER_NOT_MINOR = '!minor';
-       const FILTER_BOT = 'bot';
-       const FILTER_NOT_BOT = '!bot';
-       const FILTER_ANON = 'anon';
-       const FILTER_NOT_ANON = '!anon';
-       const FILTER_PATROLLED = 'patrolled';
-       const FILTER_NOT_PATROLLED = '!patrolled';
-       const FILTER_UNREAD = 'unread';
-       const FILTER_NOT_UNREAD = '!unread';
-       const FILTER_CHANGED = 'changed';
-       const FILTER_NOT_CHANGED = '!changed';
-
-       const SORT_ASC = 'ASC';
-       const SORT_DESC = 'DESC';
-
-       /**
-        * @var LoadBalancer
-        */
-       private $loadBalancer;
-
-       /** @var WatchedItemQueryServiceExtension[]|null */
-       private $extensions = null;
-
-       /**
-        * @var CommentStore|null */
-       private $commentStore = null;
-
-       public function __construct( LoadBalancer $loadBalancer ) {
-               $this->loadBalancer = $loadBalancer;
-       }
-
-       /**
-        * @return WatchedItemQueryServiceExtension[]
-        */
-       private function getExtensions() {
-               if ( $this->extensions === null ) {
-                       $this->extensions = [];
-                       Hooks::run( 'WatchedItemQueryServiceExtensions', [ &$this->extensions, $this ] );
-               }
-               return $this->extensions;
-       }
-
-       /**
-        * @return IDatabase
-        * @throws MWException
-        */
-       private function getConnection() {
-               return $this->loadBalancer->getConnectionRef( DB_REPLICA, [ 'watchlist' ] );
-       }
-
-       private function getCommentStore() {
-               if ( !$this->commentStore ) {
-                       $this->commentStore = new CommentStore( 'rc_comment' );
-               }
-               return $this->commentStore;
-       }
-
-       /**
-        * @param User $user
-        * @param array $options Allowed keys:
-        *        'includeFields'       => string[] RecentChange fields to be included in the result,
-        *                                 self::INCLUDE_* constants should be used
-        *        'filters'             => string[] optional filters to narrow down resulted items
-        *        'namespaceIds'        => int[] optional namespace IDs to filter by
-        *                                 (defaults to all namespaces)
-        *        'allRevisions'        => bool return multiple revisions of the same page if true,
-        *                                 only the most recent if false (default)
-        *        'rcTypes'             => int[] which types of RecentChanges to include
-        *                                 (defaults to all types), allowed values: RC_EDIT, RC_NEW,
-        *                                 RC_LOG, RC_EXTERNAL, RC_CATEGORIZE
-        *        'onlyByUser'          => string only list changes by a specified user
-        *        'notByUser'           => string do not incluide changes by a specified user
-        *        'dir'                 => string in which direction to enumerate, accepted values:
-        *                                 - DIR_OLDER list newest first
-        *                                 - DIR_NEWER list oldest first
-        *        'start'               => string (format accepted by wfTimestamp) requires 'dir' option,
-        *                                 timestamp to start enumerating from
-        *        'end'                 => string (format accepted by wfTimestamp) requires 'dir' option,
-        *                                 timestamp to end enumerating
-        *        'watchlistOwner'      => User user whose watchlist items should be listed if different
-        *                                 than the one specified with $user param,
-        *                                 requires 'watchlistOwnerToken' option
-        *        'watchlistOwnerToken' => string a watchlist token used to access another user's
-        *                                 watchlist, used with 'watchlistOwnerToken' option
-        *        'limit'               => int maximum numbers of items to return
-        *        'usedInGenerator'     => bool include only RecentChange id field required by the
-        *                                 generator ('rc_cur_id' or 'rc_this_oldid') if true, or all
-        *                                 id fields ('rc_cur_id', 'rc_this_oldid', 'rc_last_oldid')
-        *                                 if false (default)
-        * @param array|null &$startFrom Continuation value: [ string $rcTimestamp, int $rcId ]
-        * @return array of pairs ( WatchedItem $watchedItem, string[] $recentChangeInfo ),
-        *         where $recentChangeInfo contains the following keys:
-        *         - 'rc_id',
-        *         - 'rc_namespace',
-        *         - 'rc_title',
-        *         - 'rc_timestamp',
-        *         - 'rc_type',
-        *         - 'rc_deleted',
-        *         Additional keys could be added by specifying the 'includeFields' option
-        */
-       public function getWatchedItemsWithRecentChangeInfo(
-               User $user, array $options = [], &$startFrom = null
-       ) {
-               $options += [
-                       'includeFields' => [],
-                       'namespaceIds' => [],
-                       'filters' => [],
-                       'allRevisions' => false,
-                       'usedInGenerator' => false
-               ];
-
-               Assert::parameter(
-                       !isset( $options['rcTypes'] )
-                               || !array_diff( $options['rcTypes'], [ RC_EDIT, RC_NEW, RC_LOG, RC_EXTERNAL, RC_CATEGORIZE ] ),
-                       '$options[\'rcTypes\']',
-                       'must be an array containing only: RC_EDIT, RC_NEW, RC_LOG, RC_EXTERNAL and/or RC_CATEGORIZE'
-               );
-               Assert::parameter(
-                       !isset( $options['dir'] ) || in_array( $options['dir'], [ self::DIR_OLDER, self::DIR_NEWER ] ),
-                       '$options[\'dir\']',
-                       'must be DIR_OLDER or DIR_NEWER'
-               );
-               Assert::parameter(
-                       !isset( $options['start'] ) && !isset( $options['end'] ) && $startFrom === null
-                               || isset( $options['dir'] ),
-                       '$options[\'dir\']',
-                       'must be provided when providing the "start" or "end" options or the $startFrom parameter'
-               );
-               Assert::parameter(
-                       !isset( $options['startFrom'] ),
-                       '$options[\'startFrom\']',
-                       'must not be provided, use $startFrom instead'
-               );
-               Assert::parameter(
-                       !isset( $startFrom ) || ( is_array( $startFrom ) && count( $startFrom ) === 2 ),
-                       '$startFrom',
-                       'must be a two-element array'
-               );
-               if ( array_key_exists( 'watchlistOwner', $options ) ) {
-                       Assert::parameterType(
-                               User::class,
-                               $options['watchlistOwner'],
-                               '$options[\'watchlistOwner\']'
-                       );
-                       Assert::parameter(
-                               isset( $options['watchlistOwnerToken'] ),
-                               '$options[\'watchlistOwnerToken\']',
-                               'must be provided when providing watchlistOwner option'
-                       );
-               }
-
-               $db = $this->getConnection();
-
-               $tables = $this->getWatchedItemsWithRCInfoQueryTables( $options );
-               $fields = $this->getWatchedItemsWithRCInfoQueryFields( $options );
-               $conds = $this->getWatchedItemsWithRCInfoQueryConds( $db, $user, $options );
-               $dbOptions = $this->getWatchedItemsWithRCInfoQueryDbOptions( $options );
-               $joinConds = $this->getWatchedItemsWithRCInfoQueryJoinConds( $options );
-
-               if ( $startFrom !== null ) {
-                       $conds[] = $this->getStartFromConds( $db, $options, $startFrom );
-               }
-
-               foreach ( $this->getExtensions() as $extension ) {
-                       $extension->modifyWatchedItemsWithRCInfoQuery(
-                               $user, $options, $db,
-                               $tables,
-                               $fields,
-                               $conds,
-                               $dbOptions,
-                               $joinConds
-                       );
-               }
-
-               $res = $db->select(
-                       $tables,
-                       $fields,
-                       $conds,
-                       __METHOD__,
-                       $dbOptions,
-                       $joinConds
-               );
-
-               $limit = isset( $dbOptions['LIMIT'] ) ? $dbOptions['LIMIT'] : INF;
-               $items = [];
-               $startFrom = null;
-               foreach ( $res as $row ) {
-                       if ( --$limit <= 0 ) {
-                               $startFrom = [ $row->rc_timestamp, $row->rc_id ];
-                               break;
-                       }
-
-                       $items[] = [
-                               new WatchedItem(
-                                       $user,
-                                       new TitleValue( (int)$row->rc_namespace, $row->rc_title ),
-                                       $row->wl_notificationtimestamp
-                               ),
-                               $this->getRecentChangeFieldsFromRow( $row )
-                       ];
-               }
-
-               foreach ( $this->getExtensions() as $extension ) {
-                       $extension->modifyWatchedItemsWithRCInfo( $user, $options, $db, $items, $res, $startFrom );
-               }
-
-               return $items;
-       }
-
-       /**
-        * For simple listing of user's watchlist items, see WatchedItemStore::getWatchedItemsForUser
-        *
-        * @param User $user
-        * @param array $options Allowed keys:
-        *        'sort'         => string optional sorting by namespace ID and title
-        *                          one of the self::SORT_* constants
-        *        'namespaceIds' => int[] optional namespace IDs to filter by (defaults to all namespaces)
-        *        'limit'        => int maximum number of items to return
-        *        'filter'       => string optional filter, one of the self::FILTER_* contants
-        *        'from'         => LinkTarget requires 'sort' key, only return items starting from
-        *                          those related to the link target
-        *        'until'        => LinkTarget requires 'sort' key, only return items until
-        *                          those related to the link target
-        *        'startFrom'    => LinkTarget requires 'sort' key, only return items starting from
-        *                          those related to the link target, allows to skip some link targets
-        *                          specified using the form option
-        * @return WatchedItem[]
-        */
-       public function getWatchedItemsForUser( User $user, array $options = [] ) {
-               if ( $user->isAnon() ) {
-                       // TODO: should this just return an empty array or rather complain loud at this point
-                       // as e.g. ApiBase::getWatchlistUser does?
-                       return [];
-               }
-
-               $options += [ 'namespaceIds' => [] ];
-
-               Assert::parameter(
-                       !isset( $options['sort'] ) || in_array( $options['sort'], [ self::SORT_ASC, self::SORT_DESC ] ),
-                       '$options[\'sort\']',
-                       'must be SORT_ASC or SORT_DESC'
-               );
-               Assert::parameter(
-                       !isset( $options['filter'] ) || in_array(
-                               $options['filter'], [ self::FILTER_CHANGED, self::FILTER_NOT_CHANGED ]
-                       ),
-                       '$options[\'filter\']',
-                       'must be FILTER_CHANGED or FILTER_NOT_CHANGED'
-               );
-               Assert::parameter(
-                       !isset( $options['from'] ) && !isset( $options['until'] ) && !isset( $options['startFrom'] )
-                       || isset( $options['sort'] ),
-                       '$options[\'sort\']',
-                       'must be provided if any of "from", "until", "startFrom" options is provided'
-               );
-
-               $db = $this->getConnection();
-
-               $conds = $this->getWatchedItemsForUserQueryConds( $db, $user, $options );
-               $dbOptions = $this->getWatchedItemsForUserQueryDbOptions( $options );
-
-               $res = $db->select(
-                       'watchlist',
-                       [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                       $conds,
-                       __METHOD__,
-                       $dbOptions
-               );
-
-               $watchedItems = [];
-               foreach ( $res as $row ) {
-                       // todo these could all be cached at some point?
-                       $watchedItems[] = new WatchedItem(
-                               $user,
-                               new TitleValue( (int)$row->wl_namespace, $row->wl_title ),
-                               $row->wl_notificationtimestamp
-                       );
-               }
-
-               return $watchedItems;
-       }
-
-       private function getRecentChangeFieldsFromRow( stdClass $row ) {
-               // This can be simplified to single array_filter call filtering by key value,
-               // once we stop supporting PHP 5.5
-               $allFields = get_object_vars( $row );
-               $rcKeys = array_filter(
-                       array_keys( $allFields ),
-                       function ( $key ) {
-                               return substr( $key, 0, 3 ) === 'rc_';
-                       }
-               );
-               return array_intersect_key( $allFields, array_flip( $rcKeys ) );
-       }
-
-       private function getWatchedItemsWithRCInfoQueryTables( array $options ) {
-               $tables = [ 'recentchanges', 'watchlist' ];
-               if ( !$options['allRevisions'] ) {
-                       $tables[] = 'page';
-               }
-               if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) {
-                       $tables += $this->getCommentStore()->getJoin()['tables'];
-               }
-               return $tables;
-       }
-
-       private function getWatchedItemsWithRCInfoQueryFields( array $options ) {
-               $fields = [
-                       'rc_id',
-                       'rc_namespace',
-                       'rc_title',
-                       'rc_timestamp',
-                       'rc_type',
-                       'rc_deleted',
-                       'wl_notificationtimestamp'
-               ];
-
-               $rcIdFields = [
-                       'rc_cur_id',
-                       'rc_this_oldid',
-                       'rc_last_oldid',
-               ];
-               if ( $options['usedInGenerator'] ) {
-                       if ( $options['allRevisions'] ) {
-                               $rcIdFields = [ 'rc_this_oldid' ];
-                       } else {
-                               $rcIdFields = [ 'rc_cur_id' ];
-                       }
-               }
-               $fields = array_merge( $fields, $rcIdFields );
-
-               if ( in_array( self::INCLUDE_FLAGS, $options['includeFields'] ) ) {
-                       $fields = array_merge( $fields, [ 'rc_type', 'rc_minor', 'rc_bot' ] );
-               }
-               if ( in_array( self::INCLUDE_USER, $options['includeFields'] ) ) {
-                       $fields[] = 'rc_user_text';
-               }
-               if ( in_array( self::INCLUDE_USER_ID, $options['includeFields'] ) ) {
-                       $fields[] = 'rc_user';
-               }
-               if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) {
-                       $fields += $this->getCommentStore()->getJoin()['fields'];
-               }
-               if ( in_array( self::INCLUDE_PATROL_INFO, $options['includeFields'] ) ) {
-                       $fields = array_merge( $fields, [ 'rc_patrolled', 'rc_log_type' ] );
-               }
-               if ( in_array( self::INCLUDE_SIZES, $options['includeFields'] ) ) {
-                       $fields = array_merge( $fields, [ 'rc_old_len', 'rc_new_len' ] );
-               }
-               if ( in_array( self::INCLUDE_LOG_INFO, $options['includeFields'] ) ) {
-                       $fields = array_merge( $fields, [ 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ] );
-               }
-
-               return $fields;
-       }
-
-       private function getWatchedItemsWithRCInfoQueryConds(
-               IDatabase $db,
-               User $user,
-               array $options
-       ) {
-               $watchlistOwnerId = $this->getWatchlistOwnerId( $user, $options );
-               $conds = [ 'wl_user' => $watchlistOwnerId ];
-
-               if ( !$options['allRevisions'] ) {
-                       $conds[] = $db->makeList(
-                               [ 'rc_this_oldid=page_latest', 'rc_type=' . RC_LOG ],
-                               LIST_OR
-                       );
-               }
-
-               if ( $options['namespaceIds'] ) {
-                       $conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] );
-               }
-
-               if ( array_key_exists( 'rcTypes', $options ) ) {
-                       $conds['rc_type'] = array_map( 'intval', $options['rcTypes'] );
-               }
-
-               $conds = array_merge(
-                       $conds,
-                       $this->getWatchedItemsWithRCInfoQueryFilterConds( $user, $options )
-               );
-
-               $conds = array_merge( $conds, $this->getStartEndConds( $db, $options ) );
-
-               if ( !isset( $options['start'] ) && !isset( $options['end'] ) ) {
-                       if ( $db->getType() === 'mysql' ) {
-                               // This is an index optimization for mysql
-                               $conds[] = 'rc_timestamp > ' . $db->addQuotes( '' );
-                       }
-               }
-
-               $conds = array_merge( $conds, $this->getUserRelatedConds( $db, $user, $options ) );
-
-               $deletedPageLogCond = $this->getExtraDeletedPageLogEntryRelatedCond( $db, $user );
-               if ( $deletedPageLogCond ) {
-                       $conds[] = $deletedPageLogCond;
-               }
-
-               return $conds;
-       }
-
-       private function getWatchlistOwnerId( User $user, array $options ) {
-               if ( array_key_exists( 'watchlistOwner', $options ) ) {
-                       /** @var User $watchlistOwner */
-                       $watchlistOwner = $options['watchlistOwner'];
-                       $ownersToken = $watchlistOwner->getOption( 'watchlisttoken' );
-                       $token = $options['watchlistOwnerToken'];
-                       if ( $ownersToken == '' || !hash_equals( $ownersToken, $token ) ) {
-                               throw ApiUsageException::newWithMessage( null, 'apierror-bad-watchlist-token', 'bad_wltoken' );
-                       }
-                       return $watchlistOwner->getId();
-               }
-               return $user->getId();
-       }
-
-       private function getWatchedItemsWithRCInfoQueryFilterConds( User $user, array $options ) {
-               $conds = [];
-
-               if ( in_array( self::FILTER_MINOR, $options['filters'] ) ) {
-                       $conds[] = 'rc_minor != 0';
-               } elseif ( in_array( self::FILTER_NOT_MINOR, $options['filters'] ) ) {
-                       $conds[] = 'rc_minor = 0';
-               }
-
-               if ( in_array( self::FILTER_BOT, $options['filters'] ) ) {
-                       $conds[] = 'rc_bot != 0';
-               } elseif ( in_array( self::FILTER_NOT_BOT, $options['filters'] ) ) {
-                       $conds[] = 'rc_bot = 0';
-               }
-
-               if ( in_array( self::FILTER_ANON, $options['filters'] ) ) {
-                       $conds[] = 'rc_user = 0';
-               } elseif ( in_array( self::FILTER_NOT_ANON, $options['filters'] ) ) {
-                       $conds[] = 'rc_user != 0';
-               }
-
-               if ( $user->useRCPatrol() || $user->useNPPatrol() ) {
-                       // TODO: not sure if this should simply ignore patrolled filters if user does not have the patrol
-                       // right, or maybe rather fail loud at this point, same as e.g. ApiQueryWatchlist does?
-                       if ( in_array( self::FILTER_PATROLLED, $options['filters'] ) ) {
-                               $conds[] = 'rc_patrolled != 0';
-                       } elseif ( in_array( self::FILTER_NOT_PATROLLED, $options['filters'] ) ) {
-                               $conds[] = 'rc_patrolled = 0';
-                       }
-               }
-
-               if ( in_array( self::FILTER_UNREAD, $options['filters'] ) ) {
-                       $conds[] = 'rc_timestamp >= wl_notificationtimestamp';
-               } elseif ( in_array( self::FILTER_NOT_UNREAD, $options['filters'] ) ) {
-                       // TODO: should this be changed to use Database::makeList?
-                       $conds[] = 'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp';
-               }
-
-               return $conds;
-       }
-
-       private function getStartEndConds( IDatabase $db, array $options ) {
-               if ( !isset( $options['start'] ) && !isset( $options['end'] ) ) {
-                       return [];
-               }
-
-               $conds = [];
-
-               if ( isset( $options['start'] ) ) {
-                       $after = $options['dir'] === self::DIR_OLDER ? '<=' : '>=';
-                       $conds[] = 'rc_timestamp ' . $after . ' ' .
-                               $db->addQuotes( $db->timestamp( $options['start'] ) );
-               }
-               if ( isset( $options['end'] ) ) {
-                       $before = $options['dir'] === self::DIR_OLDER ? '>=' : '<=';
-                       $conds[] = 'rc_timestamp ' . $before . ' ' .
-                               $db->addQuotes( $db->timestamp( $options['end'] ) );
-               }
-
-               return $conds;
-       }
-
-       private function getUserRelatedConds( IDatabase $db, User $user, array $options ) {
-               if ( !array_key_exists( 'onlyByUser', $options ) && !array_key_exists( 'notByUser', $options ) ) {
-                       return [];
-               }
-
-               $conds = [];
-
-               if ( array_key_exists( 'onlyByUser', $options ) ) {
-                       $conds['rc_user_text'] = $options['onlyByUser'];
-               } elseif ( array_key_exists( 'notByUser', $options ) ) {
-                       $conds[] = 'rc_user_text != ' . $db->addQuotes( $options['notByUser'] );
-               }
-
-               // Avoid brute force searches (T19342)
-               $bitmask = 0;
-               if ( !$user->isAllowed( 'deletedhistory' ) ) {
-                       $bitmask = Revision::DELETED_USER;
-               } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
-                       $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
-               }
-               if ( $bitmask ) {
-                       $conds[] = $db->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask";
-               }
-
-               return $conds;
-       }
-
-       private function getExtraDeletedPageLogEntryRelatedCond( IDatabase $db, User $user ) {
-               // LogPage::DELETED_ACTION hides the affected page, too. So hide those
-               // entirely from the watchlist, or someone could guess the title.
-               $bitmask = 0;
-               if ( !$user->isAllowed( 'deletedhistory' ) ) {
-                       $bitmask = LogPage::DELETED_ACTION;
-               } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
-                       $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
-               }
-               if ( $bitmask ) {
-                       return $db->makeList( [
-                               'rc_type != ' . RC_LOG,
-                               $db->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
-                       ], LIST_OR );
-               }
-               return '';
-       }
-
-       private function getStartFromConds( IDatabase $db, array $options, array $startFrom ) {
-               $op = $options['dir'] === self::DIR_OLDER ? '<' : '>';
-               list( $rcTimestamp, $rcId ) = $startFrom;
-               $rcTimestamp = $db->addQuotes( $db->timestamp( $rcTimestamp ) );
-               $rcId = (int)$rcId;
-               return $db->makeList(
-                       [
-                               "rc_timestamp $op $rcTimestamp",
-                               $db->makeList(
-                                       [
-                                               "rc_timestamp = $rcTimestamp",
-                                               "rc_id $op= $rcId"
-                                       ],
-                                       LIST_AND
-                               )
-                       ],
-                       LIST_OR
-               );
-       }
-
-       private function getWatchedItemsForUserQueryConds( IDatabase $db, User $user, array $options ) {
-               $conds = [ 'wl_user' => $user->getId() ];
-               if ( $options['namespaceIds'] ) {
-                       $conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] );
-               }
-               if ( isset( $options['filter'] ) ) {
-                       $filter = $options['filter'];
-                       if ( $filter === self::FILTER_CHANGED ) {
-                               $conds[] = 'wl_notificationtimestamp IS NOT NULL';
-                       } else {
-                               $conds[] = 'wl_notificationtimestamp IS NULL';
-                       }
-               }
-
-               if ( isset( $options['from'] ) ) {
-                       $op = $options['sort'] === self::SORT_ASC ? '>' : '<';
-                       $conds[] = $this->getFromUntilTargetConds( $db, $options['from'], $op );
-               }
-               if ( isset( $options['until'] ) ) {
-                       $op = $options['sort'] === self::SORT_ASC ? '<' : '>';
-                       $conds[] = $this->getFromUntilTargetConds( $db, $options['until'], $op );
-               }
-               if ( isset( $options['startFrom'] ) ) {
-                       $op = $options['sort'] === self::SORT_ASC ? '>' : '<';
-                       $conds[] = $this->getFromUntilTargetConds( $db, $options['startFrom'], $op );
-               }
-
-               return $conds;
-       }
-
-       /**
-        * Creates a query condition part for getting only items before or after the given link target
-        * (while ordering using $sort mode)
-        *
-        * @param IDatabase $db
-        * @param LinkTarget $target
-        * @param string $op comparison operator to use in the conditions
-        * @return string
-        */
-       private function getFromUntilTargetConds( IDatabase $db, LinkTarget $target, $op ) {
-               return $db->makeList(
-                       [
-                               "wl_namespace $op " . $target->getNamespace(),
-                               $db->makeList(
-                                       [
-                                               'wl_namespace = ' . $target->getNamespace(),
-                                               "wl_title $op= " . $db->addQuotes( $target->getDBkey() )
-                                       ],
-                                       LIST_AND
-                               )
-                       ],
-                       LIST_OR
-               );
-       }
-
-       private function getWatchedItemsWithRCInfoQueryDbOptions( array $options ) {
-               $dbOptions = [];
-
-               if ( array_key_exists( 'dir', $options ) ) {
-                       $sort = $options['dir'] === self::DIR_OLDER ? ' DESC' : '';
-                       $dbOptions['ORDER BY'] = [ 'rc_timestamp' . $sort, 'rc_id' . $sort ];
-               }
-
-               if ( array_key_exists( 'limit', $options ) ) {
-                       $dbOptions['LIMIT'] = (int)$options['limit'] + 1;
-               }
-
-               return $dbOptions;
-       }
-
-       private function getWatchedItemsForUserQueryDbOptions( array $options ) {
-               $dbOptions = [];
-               if ( array_key_exists( 'sort', $options ) ) {
-                       $dbOptions['ORDER BY'] = [
-                               "wl_namespace {$options['sort']}",
-                               "wl_title {$options['sort']}"
-                       ];
-                       if ( count( $options['namespaceIds'] ) === 1 ) {
-                               $dbOptions['ORDER BY'] = "wl_title {$options['sort']}";
-                       }
-               }
-               if ( array_key_exists( 'limit', $options ) ) {
-                       $dbOptions['LIMIT'] = (int)$options['limit'];
-               }
-               return $dbOptions;
-       }
-
-       private function getWatchedItemsWithRCInfoQueryJoinConds( array $options ) {
-               $joinConds = [
-                       'watchlist' => [ 'INNER JOIN',
-                               [
-                                       'wl_namespace=rc_namespace',
-                                       'wl_title=rc_title'
-                               ]
-                       ]
-               ];
-               if ( !$options['allRevisions'] ) {
-                       $joinConds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
-               }
-               if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) {
-                       $joinConds += $this->getCommentStore()->getJoin()['joins'];
-               }
-               return $joinConds;
-       }
-
-}
diff --git a/includes/WatchedItemQueryServiceExtension.php b/includes/WatchedItemQueryServiceExtension.php
deleted file mode 100644 (file)
index 93d5033..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-use Wikimedia\Rdbms\ResultWrapper;
-use Wikimedia\Rdbms\IDatabase;
-
-/**
- * Extension mechanism for WatchedItemQueryService
- *
- * @since 1.29
- *
- * @file
- * @ingroup Watchlist
- *
- * @license GNU GPL v2+
- */
-interface WatchedItemQueryServiceExtension {
-
-       /**
-        * Modify the WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
-        * query before it's made.
-        *
-        * @warning Any joins added *must* join on a unique key of the target table
-        *  unless you really know what you're doing.
-        * @param User $user
-        * @param array $options Options from
-        *  WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
-        * @param IDatabase $db Database connection being used for the query
-        * @param array &$tables Tables for Database::select()
-        * @param array &$fields Fields for Database::select()
-        * @param array &$conds Conditions for Database::select()
-        * @param array &$dbOptions Options for Database::select()
-        * @param array &$joinConds Join conditions for Database::select()
-        */
-       public function modifyWatchedItemsWithRCInfoQuery( User $user, array $options, IDatabase $db,
-               array &$tables, array &$fields, array &$conds, array &$dbOptions, array &$joinConds
-       );
-
-       /**
-        * Modify the results from WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
-        * before they're returned.
-        *
-        * @param User $user
-        * @param array $options Options from
-        *  WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
-        * @param IDatabase $db Database connection being used for the query
-        * @param array &$items array of pairs ( WatchedItem $watchedItem, string[] $recentChangeInfo ).
-        *  May be truncated if necessary, in which case $startFrom must be updated.
-        * @param ResultWrapper|bool $res Database query result
-        * @param array|null &$startFrom Continuation value. If you truncate $items, set this to
-        *  [ $recentChangeInfo['rc_timestamp'], $recentChangeInfo['rc_id'] ] from the first item
-        *  removed.
-        */
-       public function modifyWatchedItemsWithRCInfo( User $user, array $options, IDatabase $db,
-               array &$items, $res, &$startFrom
-       );
-
-}
diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php
deleted file mode 100644 (file)
index 60d8b76..0000000
+++ /dev/null
@@ -1,986 +0,0 @@
-<?php
-
-use Wikimedia\Rdbms\IDatabase;
-use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
-use MediaWiki\Linker\LinkTarget;
-use MediaWiki\MediaWikiServices;
-use Wikimedia\Assert\Assert;
-use Wikimedia\ScopedCallback;
-use Wikimedia\Rdbms\LoadBalancer;
-use Wikimedia\Rdbms\DBUnexpectedError;
-
-/**
- * Storage layer class for WatchedItems.
- * Database interaction.
- *
- * Uses database because this uses User::isAnon
- *
- * @group Database
- *
- * @author Addshore
- * @since 1.27
- */
-class WatchedItemStore implements StatsdAwareInterface {
-
-       const SORT_DESC = 'DESC';
-       const SORT_ASC = 'ASC';
-
-       /**
-        * @var LoadBalancer
-        */
-       private $loadBalancer;
-
-       /**
-        * @var ReadOnlyMode
-        */
-       private $readOnlyMode;
-
-       /**
-        * @var HashBagOStuff
-        */
-       private $cache;
-
-       /**
-        * @var array[] Looks like $cacheIndex[Namespace ID][Target DB Key][User Id] => 'key'
-        * The index is needed so that on mass changes all relevant items can be un-cached.
-        * For example: Clearing a users watchlist of all items or updating notification timestamps
-        *              for all users watching a single target.
-        */
-       private $cacheIndex = [];
-
-       /**
-        * @var callable|null
-        */
-       private $deferredUpdatesAddCallableUpdateCallback;
-
-       /**
-        * @var callable|null
-        */
-       private $revisionGetTimestampFromIdCallback;
-
-       /**
-        * @var StatsdDataFactoryInterface
-        */
-       private $stats;
-
-       /**
-        * @param LoadBalancer $loadBalancer
-        * @param HashBagOStuff $cache
-        * @param ReadOnlyMode $readOnlyMode
-        */
-       public function __construct(
-               LoadBalancer $loadBalancer,
-               HashBagOStuff $cache,
-               ReadOnlyMode $readOnlyMode
-       ) {
-               $this->loadBalancer = $loadBalancer;
-               $this->cache = $cache;
-               $this->readOnlyMode = $readOnlyMode;
-               $this->stats = new NullStatsdDataFactory();
-               $this->deferredUpdatesAddCallableUpdateCallback = [ 'DeferredUpdates', 'addCallableUpdate' ];
-               $this->revisionGetTimestampFromIdCallback = [ 'Revision', 'getTimestampFromId' ];
-       }
-
-       public function setStatsdDataFactory( StatsdDataFactoryInterface $stats ) {
-               $this->stats = $stats;
-       }
-
-       /**
-        * Overrides the DeferredUpdates::addCallableUpdate callback
-        * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
-        *
-        * @param callable $callback
-        *
-        * @see DeferredUpdates::addCallableUpdate for callback signiture
-        *
-        * @return ScopedCallback to reset the overridden value
-        * @throws MWException
-        */
-       public function overrideDeferredUpdatesAddCallableUpdateCallback( callable $callback ) {
-               if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
-                       throw new MWException(
-                               'Cannot override DeferredUpdates::addCallableUpdate callback in operation.'
-                       );
-               }
-               $previousValue = $this->deferredUpdatesAddCallableUpdateCallback;
-               $this->deferredUpdatesAddCallableUpdateCallback = $callback;
-               return new ScopedCallback( function () use ( $previousValue ) {
-                       $this->deferredUpdatesAddCallableUpdateCallback = $previousValue;
-               } );
-       }
-
-       /**
-        * Overrides the Revision::getTimestampFromId callback
-        * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
-        *
-        * @param callable $callback
-        * @see Revision::getTimestampFromId for callback signiture
-        *
-        * @return ScopedCallback to reset the overridden value
-        * @throws MWException
-        */
-       public function overrideRevisionGetTimestampFromIdCallback( callable $callback ) {
-               if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
-                       throw new MWException(
-                               'Cannot override Revision::getTimestampFromId callback in operation.'
-                       );
-               }
-               $previousValue = $this->revisionGetTimestampFromIdCallback;
-               $this->revisionGetTimestampFromIdCallback = $callback;
-               return new ScopedCallback( function () use ( $previousValue ) {
-                       $this->revisionGetTimestampFromIdCallback = $previousValue;
-               } );
-       }
-
-       private function getCacheKey( User $user, LinkTarget $target ) {
-               return $this->cache->makeKey(
-                       (string)$target->getNamespace(),
-                       $target->getDBkey(),
-                       (string)$user->getId()
-               );
-       }
-
-       private function cache( WatchedItem $item ) {
-               $user = $item->getUser();
-               $target = $item->getLinkTarget();
-               $key = $this->getCacheKey( $user, $target );
-               $this->cache->set( $key, $item );
-               $this->cacheIndex[$target->getNamespace()][$target->getDBkey()][$user->getId()] = $key;
-               $this->stats->increment( 'WatchedItemStore.cache' );
-       }
-
-       private function uncache( User $user, LinkTarget $target ) {
-               $this->cache->delete( $this->getCacheKey( $user, $target ) );
-               unset( $this->cacheIndex[$target->getNamespace()][$target->getDBkey()][$user->getId()] );
-               $this->stats->increment( 'WatchedItemStore.uncache' );
-       }
-
-       private function uncacheLinkTarget( LinkTarget $target ) {
-               $this->stats->increment( 'WatchedItemStore.uncacheLinkTarget' );
-               if ( !isset( $this->cacheIndex[$target->getNamespace()][$target->getDBkey()] ) ) {
-                       return;
-               }
-               foreach ( $this->cacheIndex[$target->getNamespace()][$target->getDBkey()] as $key ) {
-                       $this->stats->increment( 'WatchedItemStore.uncacheLinkTarget.items' );
-                       $this->cache->delete( $key );
-               }
-       }
-
-       private function uncacheUser( User $user ) {
-               $this->stats->increment( 'WatchedItemStore.uncacheUser' );
-               foreach ( $this->cacheIndex as $ns => $dbKeyArray ) {
-                       foreach ( $dbKeyArray as $dbKey => $userArray ) {
-                               if ( isset( $userArray[$user->getId()] ) ) {
-                                       $this->stats->increment( 'WatchedItemStore.uncacheUser.items' );
-                                       $this->cache->delete( $userArray[$user->getId()] );
-                               }
-                       }
-               }
-       }
-
-       /**
-        * @param User $user
-        * @param LinkTarget $target
-        *
-        * @return WatchedItem|false
-        */
-       private function getCached( User $user, LinkTarget $target ) {
-               return $this->cache->get( $this->getCacheKey( $user, $target ) );
-       }
-
-       /**
-        * Return an array of conditions to select or update the appropriate database
-        * row.
-        *
-        * @param User $user
-        * @param LinkTarget $target
-        *
-        * @return array
-        */
-       private function dbCond( User $user, LinkTarget $target ) {
-               return [
-                       'wl_user' => $user->getId(),
-                       'wl_namespace' => $target->getNamespace(),
-                       'wl_title' => $target->getDBkey(),
-               ];
-       }
-
-       /**
-        * @param int $dbIndex DB_MASTER or DB_REPLICA
-        *
-        * @return IDatabase
-        * @throws MWException
-        */
-       private function getConnectionRef( $dbIndex ) {
-               return $this->loadBalancer->getConnectionRef( $dbIndex, [ 'watchlist' ] );
-       }
-
-       /**
-        * Count the number of individual items that are watched by the user.
-        * If a subject and corresponding talk page are watched this will return 2.
-        *
-        * @param User $user
-        *
-        * @return int
-        */
-       public function countWatchedItems( User $user ) {
-               $dbr = $this->getConnectionRef( DB_REPLICA );
-               $return = (int)$dbr->selectField(
-                       'watchlist',
-                       'COUNT(*)',
-                       [
-                               'wl_user' => $user->getId()
-                       ],
-                       __METHOD__
-               );
-
-               return $return;
-       }
-
-       /**
-        * @param LinkTarget $target
-        *
-        * @return int
-        */
-       public function countWatchers( LinkTarget $target ) {
-               $dbr = $this->getConnectionRef( DB_REPLICA );
-               $return = (int)$dbr->selectField(
-                       'watchlist',
-                       'COUNT(*)',
-                       [
-                               'wl_namespace' => $target->getNamespace(),
-                               'wl_title' => $target->getDBkey(),
-                       ],
-                       __METHOD__
-               );
-
-               return $return;
-       }
-
-       /**
-        * Number of page watchers who also visited a "recent" edit
-        *
-        * @param LinkTarget $target
-        * @param mixed $threshold timestamp accepted by wfTimestamp
-        *
-        * @return int
-        * @throws DBUnexpectedError
-        * @throws MWException
-        */
-       public function countVisitingWatchers( LinkTarget $target, $threshold ) {
-               $dbr = $this->getConnectionRef( DB_REPLICA );
-               $visitingWatchers = (int)$dbr->selectField(
-                       'watchlist',
-                       'COUNT(*)',
-                       [
-                               'wl_namespace' => $target->getNamespace(),
-                               'wl_title' => $target->getDBkey(),
-                               'wl_notificationtimestamp >= ' .
-                               $dbr->addQuotes( $dbr->timestamp( $threshold ) ) .
-                               ' OR wl_notificationtimestamp IS NULL'
-                       ],
-                       __METHOD__
-               );
-
-               return $visitingWatchers;
-       }
-
-       /**
-        * @param LinkTarget[] $targets
-        * @param array $options Allowed keys:
-        *        'minimumWatchers' => int
-        *
-        * @return array multi dimensional like $return[$namespaceId][$titleString] = int $watchers
-        *         All targets will be present in the result. 0 either means no watchers or the number
-        *         of watchers was below the minimumWatchers option if passed.
-        */
-       public function countWatchersMultiple( array $targets, array $options = [] ) {
-               $dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ];
-
-               $dbr = $this->getConnectionRef( DB_REPLICA );
-
-               if ( array_key_exists( 'minimumWatchers', $options ) ) {
-                       $dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$options['minimumWatchers'];
-               }
-
-               $lb = new LinkBatch( $targets );
-               $res = $dbr->select(
-                       'watchlist',
-                       [ 'wl_title', 'wl_namespace', 'watchers' => 'COUNT(*)' ],
-                       [ $lb->constructSet( 'wl', $dbr ) ],
-                       __METHOD__,
-                       $dbOptions
-               );
-
-               $watchCounts = [];
-               foreach ( $targets as $linkTarget ) {
-                       $watchCounts[$linkTarget->getNamespace()][$linkTarget->getDBkey()] = 0;
-               }
-
-               foreach ( $res as $row ) {
-                       $watchCounts[$row->wl_namespace][$row->wl_title] = (int)$row->watchers;
-               }
-
-               return $watchCounts;
-       }
-
-       /**
-        * Number of watchers of each page who have visited recent edits to that page
-        *
-        * @param array $targetsWithVisitThresholds array of pairs (LinkTarget $target, mixed $threshold),
-        *        $threshold is:
-        *        - a timestamp of the recent edit if $target exists (format accepted by wfTimestamp)
-        *        - null if $target doesn't exist
-        * @param int|null $minimumWatchers
-        * @return array multi-dimensional like $return[$namespaceId][$titleString] = $watchers,
-        *         where $watchers is an int:
-        *         - if the page exists, number of users watching who have visited the page recently
-        *         - if the page doesn't exist, number of users that have the page on their watchlist
-        *         - 0 means there are no visiting watchers or their number is below the minimumWatchers
-        *         option (if passed).
-        */
-       public function countVisitingWatchersMultiple(
-               array $targetsWithVisitThresholds,
-               $minimumWatchers = null
-       ) {
-               $dbr = $this->getConnectionRef( DB_REPLICA );
-
-               $conds = $this->getVisitingWatchersCondition( $dbr, $targetsWithVisitThresholds );
-
-               $dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ];
-               if ( $minimumWatchers !== null ) {
-                       $dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$minimumWatchers;
-               }
-               $res = $dbr->select(
-                       'watchlist',
-                       [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
-                       $conds,
-                       __METHOD__,
-                       $dbOptions
-               );
-
-               $watcherCounts = [];
-               foreach ( $targetsWithVisitThresholds as list( $target ) ) {
-                       /* @var LinkTarget $target */
-                       $watcherCounts[$target->getNamespace()][$target->getDBkey()] = 0;
-               }
-
-               foreach ( $res as $row ) {
-                       $watcherCounts[$row->wl_namespace][$row->wl_title] = (int)$row->watchers;
-               }
-
-               return $watcherCounts;
-       }
-
-       /**
-        * Generates condition for the query used in a batch count visiting watchers.
-        *
-        * @param IDatabase $db
-        * @param array $targetsWithVisitThresholds array of pairs (LinkTarget, last visit threshold)
-        * @return string
-        */
-       private function getVisitingWatchersCondition(
-               IDatabase $db,
-               array $targetsWithVisitThresholds
-       ) {
-               $missingTargets = [];
-               $namespaceConds = [];
-               foreach ( $targetsWithVisitThresholds as list( $target, $threshold ) ) {
-                       if ( $threshold === null ) {
-                               $missingTargets[] = $target;
-                               continue;
-                       }
-                       /* @var LinkTarget $target */
-                       $namespaceConds[$target->getNamespace()][] = $db->makeList( [
-                               'wl_title = ' . $db->addQuotes( $target->getDBkey() ),
-                               $db->makeList( [
-                                       'wl_notificationtimestamp >= ' . $db->addQuotes( $db->timestamp( $threshold ) ),
-                                       'wl_notificationtimestamp IS NULL'
-                               ], LIST_OR )
-                       ], LIST_AND );
-               }
-
-               $conds = [];
-               foreach ( $namespaceConds as $namespace => $pageConds ) {
-                       $conds[] = $db->makeList( [
-                               'wl_namespace = ' . $namespace,
-                               '(' . $db->makeList( $pageConds, LIST_OR ) . ')'
-                       ], LIST_AND );
-               }
-
-               if ( $missingTargets ) {
-                       $lb = new LinkBatch( $missingTargets );
-                       $conds[] = $lb->constructSet( 'wl', $db );
-               }
-
-               return $db->makeList( $conds, LIST_OR );
-       }
-
-       /**
-        * Get an item (may be cached)
-        *
-        * @param User $user
-        * @param LinkTarget $target
-        *
-        * @return WatchedItem|false
-        */
-       public function getWatchedItem( User $user, LinkTarget $target ) {
-               if ( $user->isAnon() ) {
-                       return false;
-               }
-
-               $cached = $this->getCached( $user, $target );
-               if ( $cached ) {
-                       $this->stats->increment( 'WatchedItemStore.getWatchedItem.cached' );
-                       return $cached;
-               }
-               $this->stats->increment( 'WatchedItemStore.getWatchedItem.load' );
-               return $this->loadWatchedItem( $user, $target );
-       }
-
-       /**
-        * Loads an item from the db
-        *
-        * @param User $user
-        * @param LinkTarget $target
-        *
-        * @return WatchedItem|false
-        */
-       public function loadWatchedItem( User $user, LinkTarget $target ) {
-               // Only loggedin user can have a watchlist
-               if ( $user->isAnon() ) {
-                       return false;
-               }
-
-               $dbr = $this->getConnectionRef( DB_REPLICA );
-               $row = $dbr->selectRow(
-                       'watchlist',
-                       'wl_notificationtimestamp',
-                       $this->dbCond( $user, $target ),
-                       __METHOD__
-               );
-
-               if ( !$row ) {
-                       return false;
-               }
-
-               $item = new WatchedItem(
-                       $user,
-                       $target,
-                       wfTimestampOrNull( TS_MW, $row->wl_notificationtimestamp )
-               );
-               $this->cache( $item );
-
-               return $item;
-       }
-
-       /**
-        * @param User $user
-        * @param array $options Allowed keys:
-        *        'forWrite' => bool defaults to false
-        *        'sort' => string optional sorting by namespace ID and title
-        *                     one of the self::SORT_* constants
-        *
-        * @return WatchedItem[]
-        */
-       public function getWatchedItemsForUser( User $user, array $options = [] ) {
-               $options += [ 'forWrite' => false ];
-
-               $dbOptions = [];
-               if ( array_key_exists( 'sort', $options ) ) {
-                       Assert::parameter(
-                               ( in_array( $options['sort'], [ self::SORT_ASC, self::SORT_DESC ] ) ),
-                               '$options[\'sort\']',
-                               'must be SORT_ASC or SORT_DESC'
-                       );
-                       $dbOptions['ORDER BY'] = [
-                               "wl_namespace {$options['sort']}",
-                               "wl_title {$options['sort']}"
-                       ];
-               }
-               $db = $this->getConnectionRef( $options['forWrite'] ? DB_MASTER : DB_REPLICA );
-
-               $res = $db->select(
-                       'watchlist',
-                       [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                       [ 'wl_user' => $user->getId() ],
-                       __METHOD__,
-                       $dbOptions
-               );
-
-               $watchedItems = [];
-               foreach ( $res as $row ) {
-                       // @todo: Should we add these to the process cache?
-                       $watchedItems[] = new WatchedItem(
-                               $user,
-                               new TitleValue( (int)$row->wl_namespace, $row->wl_title ),
-                               $row->wl_notificationtimestamp
-                       );
-               }
-
-               return $watchedItems;
-       }
-
-       /**
-        * Must be called separately for Subject & Talk namespaces
-        *
-        * @param User $user
-        * @param LinkTarget $target
-        *
-        * @return bool
-        */
-       public function isWatched( User $user, LinkTarget $target ) {
-               return (bool)$this->getWatchedItem( $user, $target );
-       }
-
-       /**
-        * @param User $user
-        * @param LinkTarget[] $targets
-        *
-        * @return array multi-dimensional like $return[$namespaceId][$titleString] = $timestamp,
-        *         where $timestamp is:
-        *         - string|null value of wl_notificationtimestamp,
-        *         - false if $target is not watched by $user.
-        */
-       public function getNotificationTimestampsBatch( User $user, array $targets ) {
-               $timestamps = [];
-               foreach ( $targets as $target ) {
-                       $timestamps[$target->getNamespace()][$target->getDBkey()] = false;
-               }
-
-               if ( $user->isAnon() ) {
-                       return $timestamps;
-               }
-
-               $targetsToLoad = [];
-               foreach ( $targets as $target ) {
-                       $cachedItem = $this->getCached( $user, $target );
-                       if ( $cachedItem ) {
-                               $timestamps[$target->getNamespace()][$target->getDBkey()] =
-                                       $cachedItem->getNotificationTimestamp();
-                       } else {
-                               $targetsToLoad[] = $target;
-                       }
-               }
-
-               if ( !$targetsToLoad ) {
-                       return $timestamps;
-               }
-
-               $dbr = $this->getConnectionRef( DB_REPLICA );
-
-               $lb = new LinkBatch( $targetsToLoad );
-               $res = $dbr->select(
-                       'watchlist',
-                       [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                       [
-                               $lb->constructSet( 'wl', $dbr ),
-                               'wl_user' => $user->getId(),
-                       ],
-                       __METHOD__
-               );
-
-               foreach ( $res as $row ) {
-                       $timestamps[$row->wl_namespace][$row->wl_title] =
-                               wfTimestampOrNull( TS_MW, $row->wl_notificationtimestamp );
-               }
-
-               return $timestamps;
-       }
-
-       /**
-        * Must be called separately for Subject & Talk namespaces
-        *
-        * @param User $user
-        * @param LinkTarget $target
-        */
-       public function addWatch( User $user, LinkTarget $target ) {
-               $this->addWatchBatchForUser( $user, [ $target ] );
-       }
-
-       /**
-        * @param User $user
-        * @param LinkTarget[] $targets
-        *
-        * @return bool success
-        */
-       public function addWatchBatchForUser( User $user, array $targets ) {
-               if ( $this->readOnlyMode->isReadOnly() ) {
-                       return false;
-               }
-               // Only loggedin user can have a watchlist
-               if ( $user->isAnon() ) {
-                       return false;
-               }
-
-               if ( !$targets ) {
-                       return true;
-               }
-
-               $rows = [];
-               $items = [];
-               foreach ( $targets as $target ) {
-                       $rows[] = [
-                               'wl_user' => $user->getId(),
-                               'wl_namespace' => $target->getNamespace(),
-                               'wl_title' => $target->getDBkey(),
-                               'wl_notificationtimestamp' => null,
-                       ];
-                       $items[] = new WatchedItem(
-                               $user,
-                               $target,
-                               null
-                       );
-                       $this->uncache( $user, $target );
-               }
-
-               $dbw = $this->getConnectionRef( DB_MASTER );
-               foreach ( array_chunk( $rows, 100 ) as $toInsert ) {
-                       // Use INSERT IGNORE to avoid overwriting the notification timestamp
-                       // if there's already an entry for this page
-                       $dbw->insert( 'watchlist', $toInsert, __METHOD__, 'IGNORE' );
-               }
-               // Update process cache to ensure skin doesn't claim that the current
-               // page is unwatched in the response of action=watch itself (T28292).
-               // This would otherwise be re-queried from a slave by isWatched().
-               foreach ( $items as $item ) {
-                       $this->cache( $item );
-               }
-
-               return true;
-       }
-
-       /**
-        * Removes the an entry for the User watching the LinkTarget
-        * Must be called separately for Subject & Talk namespaces
-        *
-        * @param User $user
-        * @param LinkTarget $target
-        *
-        * @return bool success
-        * @throws DBUnexpectedError
-        * @throws MWException
-        */
-       public function removeWatch( User $user, LinkTarget $target ) {
-               // Only logged in user can have a watchlist
-               if ( $this->readOnlyMode->isReadOnly() || $user->isAnon() ) {
-                       return false;
-               }
-
-               $this->uncache( $user, $target );
-
-               $dbw = $this->getConnectionRef( DB_MASTER );
-               $dbw->delete( 'watchlist',
-                       [
-                               'wl_user' => $user->getId(),
-                               'wl_namespace' => $target->getNamespace(),
-                               'wl_title' => $target->getDBkey(),
-                       ], __METHOD__
-               );
-               $success = (bool)$dbw->affectedRows();
-
-               return $success;
-       }
-
-       /**
-        * @param User $user The user to set the timestamp for
-        * @param string|null $timestamp Set the update timestamp to this value
-        * @param LinkTarget[] $targets List of targets to update. Default to all targets
-        *
-        * @return bool success
-        */
-       public function setNotificationTimestampsForUser( User $user, $timestamp, array $targets = [] ) {
-               // Only loggedin user can have a watchlist
-               if ( $user->isAnon() ) {
-                       return false;
-               }
-
-               $dbw = $this->getConnectionRef( DB_MASTER );
-
-               $conds = [ 'wl_user' => $user->getId() ];
-               if ( $targets ) {
-                       $batch = new LinkBatch( $targets );
-                       $conds[] = $batch->constructSet( 'wl', $dbw );
-               }
-
-               if ( $timestamp !== null ) {
-                       $timestamp = $dbw->timestamp( $timestamp );
-               }
-
-               $success = $dbw->update(
-                       'watchlist',
-                       [ 'wl_notificationtimestamp' => $timestamp ],
-                       $conds,
-                       __METHOD__
-               );
-
-               $this->uncacheUser( $user );
-
-               return $success;
-       }
-
-       /**
-        * @param User $editor The editor that triggered the update. Their notification
-        *  timestamp will not be updated(they have already seen it)
-        * @param LinkTarget $target The target to update timestamps for
-        * @param string $timestamp Set the update timestamp to this value
-        *
-        * @return int[] Array of user IDs the timestamp has been updated for
-        */
-       public function updateNotificationTimestamp( User $editor, LinkTarget $target, $timestamp ) {
-               $dbw = $this->getConnectionRef( DB_MASTER );
-               $uids = $dbw->selectFieldValues(
-                       'watchlist',
-                       'wl_user',
-                       [
-                               'wl_user != ' . intval( $editor->getId() ),
-                               'wl_namespace' => $target->getNamespace(),
-                               'wl_title' => $target->getDBkey(),
-                               'wl_notificationtimestamp IS NULL',
-                       ],
-                       __METHOD__
-               );
-
-               $watchers = array_map( 'intval', $uids );
-               if ( $watchers ) {
-                       // Update wl_notificationtimestamp for all watching users except the editor
-                       $fname = __METHOD__;
-                       DeferredUpdates::addCallableUpdate(
-                               function () use ( $timestamp, $watchers, $target, $fname ) {
-                                       global $wgUpdateRowsPerQuery;
-
-                                       $dbw = $this->getConnectionRef( DB_MASTER );
-                                       $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
-                                       $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
-
-                                       $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery );
-                                       foreach ( $watchersChunks as $watchersChunk ) {
-                                               $dbw->update( 'watchlist',
-                                                       [ /* SET */
-                                                               'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
-                                                       ], [ /* WHERE - TODO Use wl_id T130067 */
-                                                               'wl_user' => $watchersChunk,
-                                                               'wl_namespace' => $target->getNamespace(),
-                                                               'wl_title' => $target->getDBkey(),
-                                                       ], $fname
-                                               );
-                                               if ( count( $watchersChunks ) > 1 ) {
-                                                       $factory->commitAndWaitForReplication(
-                                                               __METHOD__, $ticket, [ 'domain' => $dbw->getDomainID() ]
-                                                       );
-                                               }
-                                       }
-                                       $this->uncacheLinkTarget( $target );
-                               },
-                               DeferredUpdates::POSTSEND,
-                               $dbw
-                       );
-               }
-
-               return $watchers;
-       }
-
-       /**
-        * Reset the notification timestamp of this entry
-        *
-        * @param User $user
-        * @param Title $title
-        * @param string $force Whether to force the write query to be executed even if the
-        *    page is not watched or the notification timestamp is already NULL.
-        *    'force' in order to force
-        * @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed.
-        *
-        * @return bool success
-        */
-       public function resetNotificationTimestamp( User $user, Title $title, $force = '', $oldid = 0 ) {
-               // Only loggedin user can have a watchlist
-               if ( $this->readOnlyMode->isReadOnly() || $user->isAnon() ) {
-                       return false;
-               }
-
-               $item = null;
-               if ( $force != 'force' ) {
-                       $item = $this->loadWatchedItem( $user, $title );
-                       if ( !$item || $item->getNotificationTimestamp() === null ) {
-                               return false;
-                       }
-               }
-
-               // If the page is watched by the user (or may be watched), update the timestamp
-               $job = new ActivityUpdateJob(
-                       $title,
-                       [
-                               'type'      => 'updateWatchlistNotification',
-                               'userid'    => $user->getId(),
-                               'notifTime' => $this->getNotificationTimestamp( $user, $title, $item, $force, $oldid ),
-                               'curTime'   => time()
-                       ]
-               );
-
-               // Try to run this post-send
-               // Calls DeferredUpdates::addCallableUpdate in normal operation
-               call_user_func(
-                       $this->deferredUpdatesAddCallableUpdateCallback,
-                       function () use ( $job ) {
-                               $job->run();
-                       }
-               );
-
-               $this->uncache( $user, $title );
-
-               return true;
-       }
-
-       private function getNotificationTimestamp( User $user, Title $title, $item, $force, $oldid ) {
-               if ( !$oldid ) {
-                       // No oldid given, assuming latest revision; clear the timestamp.
-                       return null;
-               }
-
-               if ( !$title->getNextRevisionID( $oldid ) ) {
-                       // Oldid given and is the latest revision for this title; clear the timestamp.
-                       return null;
-               }
-
-               if ( $item === null ) {
-                       $item = $this->loadWatchedItem( $user, $title );
-               }
-
-               if ( !$item ) {
-                       // This can only happen if $force is enabled.
-                       return null;
-               }
-
-               // Oldid given and isn't the latest; update the timestamp.
-               // This will result in no further notification emails being sent!
-               // Calls Revision::getTimestampFromId in normal operation
-               $notificationTimestamp = call_user_func(
-                       $this->revisionGetTimestampFromIdCallback,
-                       $title,
-                       $oldid
-               );
-
-               // We need to go one second to the future because of various strict comparisons
-               // throughout the codebase
-               $ts = new MWTimestamp( $notificationTimestamp );
-               $ts->timestamp->add( new DateInterval( 'PT1S' ) );
-               $notificationTimestamp = $ts->getTimestamp( TS_MW );
-
-               if ( $notificationTimestamp < $item->getNotificationTimestamp() ) {
-                       if ( $force != 'force' ) {
-                               return false;
-                       } else {
-                               // This is a little silly…
-                               return $item->getNotificationTimestamp();
-                       }
-               }
-
-               return $notificationTimestamp;
-       }
-
-       /**
-        * @param User $user
-        * @param int $unreadLimit
-        *
-        * @return int|bool The number of unread notifications
-        *                  true if greater than or equal to $unreadLimit
-        */
-       public function countUnreadNotifications( User $user, $unreadLimit = null ) {
-               $queryOptions = [];
-               if ( $unreadLimit !== null ) {
-                       $unreadLimit = (int)$unreadLimit;
-                       $queryOptions['LIMIT'] = $unreadLimit;
-               }
-
-               $dbr = $this->getConnectionRef( DB_REPLICA );
-               $rowCount = $dbr->selectRowCount(
-                       'watchlist',
-                       '1',
-                       [
-                               'wl_user' => $user->getId(),
-                               'wl_notificationtimestamp IS NOT NULL',
-                       ],
-                       __METHOD__,
-                       $queryOptions
-               );
-
-               if ( !isset( $unreadLimit ) ) {
-                       return $rowCount;
-               }
-
-               if ( $rowCount >= $unreadLimit ) {
-                       return true;
-               }
-
-               return $rowCount;
-       }
-
-       /**
-        * Check if the given title already is watched by the user, and if so
-        * add a watch for the new title.
-        *
-        * To be used for page renames and such.
-        *
-        * @param LinkTarget $oldTarget
-        * @param LinkTarget $newTarget
-        */
-       public function duplicateAllAssociatedEntries( LinkTarget $oldTarget, LinkTarget $newTarget ) {
-               $oldTarget = Title::newFromLinkTarget( $oldTarget );
-               $newTarget = Title::newFromLinkTarget( $newTarget );
-
-               $this->duplicateEntry( $oldTarget->getSubjectPage(), $newTarget->getSubjectPage() );
-               $this->duplicateEntry( $oldTarget->getTalkPage(), $newTarget->getTalkPage() );
-       }
-
-       /**
-        * Check if the given title already is watched by the user, and if so
-        * add a watch for the new title.
-        *
-        * To be used for page renames and such.
-        * This must be called separately for Subject and Talk pages
-        *
-        * @param LinkTarget $oldTarget
-        * @param LinkTarget $newTarget
-        */
-       public function duplicateEntry( LinkTarget $oldTarget, LinkTarget $newTarget ) {
-               $dbw = $this->getConnectionRef( DB_MASTER );
-
-               $result = $dbw->select(
-                       'watchlist',
-                       [ 'wl_user', 'wl_notificationtimestamp' ],
-                       [
-                               'wl_namespace' => $oldTarget->getNamespace(),
-                               'wl_title' => $oldTarget->getDBkey(),
-                       ],
-                       __METHOD__,
-                       [ 'FOR UPDATE' ]
-               );
-
-               $newNamespace = $newTarget->getNamespace();
-               $newDBkey = $newTarget->getDBkey();
-
-               # Construct array to replace into the watchlist
-               $values = [];
-               foreach ( $result as $row ) {
-                       $values[] = [
-                               'wl_user' => $row->wl_user,
-                               'wl_namespace' => $newNamespace,
-                               'wl_title' => $newDBkey,
-                               'wl_notificationtimestamp' => $row->wl_notificationtimestamp,
-                       ];
-               }
-
-               if ( !empty( $values ) ) {
-                       # Perform replace
-                       # Note that multi-row replace is very efficient for MySQL but may be inefficient for
-                       # some other DBMSes, mostly due to poor simulation by us
-                       $dbw->replace(
-                               'watchlist',
-                               [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
-                               $values,
-                               __METHOD__
-                       );
-               }
-       }
-
-}
index 0410ddf..a2dc344 100644 (file)
        "apihelp-import-param-xml": "업로드한 XML 파일.",
        "apihelp-linkaccount-summary": "서드파티 제공자의 계정을 현재 사용자와 연결합니다.",
        "apihelp-login-summary": "로그인한 다음 인증 쿠키를 가져옵니다.",
+       "apihelp-login-extended-description": "이 동작은 [[Special:BotPasswords|특수:BotPasswords]]와 함께 사용해야만 합니다. 주 계정 로그인을 위해 사용하는 것은 권장되지 않으며 경고 없이 실패할 수 있습니다. 주 계정에 안전하게 로그인하려면 <kbd>[[Special:ApiHelp/clientlogin|action=clientlogin]]</kbd>을 사용하십시오.",
        "apihelp-login-param-name": "사용자 이름.",
        "apihelp-login-param-password": "비밀번호.",
        "apihelp-login-param-domain": "도메인 (선택).",
index 1c8877c..2e89ea3 100644 (file)
        "apihelp-options-example-complex": "Tilbakestill alle innstillinger, og sett så <kbd>skin</kbd> og <kbd>nickname</kbd>.",
        "apihelp-paraminfo-summary": "Hent informasjon om API-moduler.",
        "apihelp-paraminfo-param-helpformat": "Format for hjelpestrenger.",
+       "apihelp-parse-param-prop": "Hvilke informasjonsdeler som skal hentes:",
+       "apihelp-parse-paramvalue-prop-categorieshtml": "Gir HTML-versjonen av kategoriene.",
+       "apihelp-parse-paramvalue-prop-headitems": "Gir elementer som skal puttes i <code>&lt;head&gt;</code>-taggen til siden.",
+       "apihelp-patrol-summary": "Patruljer en side eller revisjon.",
        "apihelp-query+allfileusages-paramvalue-prop-title": "Legger til filens tittel.",
        "apihelp-query+allfileusages-param-limit": "Hvor mange elementer som skal returneres totalt.",
        "apihelp-query+allfileusages-param-dir": "Retningen det skal listes opp i.",
index 5196ac2..aa1918d 100644 (file)
@@ -142,16 +142,18 @@ abstract class MWLBFactory {
                        }
                }
 
+               $services = MediaWikiServices::getInstance();
+
                // Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
-               $sCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
+               $sCache = $services->getLocalServerObjectCache();
                if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
                        $lbConf['srvCache'] = $sCache;
                }
-               $cCache = ObjectCache::getLocalClusterInstance();
-               if ( $cCache->getQoS( $cCache::ATTR_EMULATION ) > $cCache::QOS_EMULATION_SQL ) {
-                       $lbConf['memStash'] = $cCache;
+               $mStash = $services->getMainObjectStash();
+               if ( $mStash->getQoS( $mStash::ATTR_EMULATION ) > $mStash::QOS_EMULATION_SQL ) {
+                       $lbConf['memStash'] = $mStash;
                }
-               $wCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+               $wCache = $services->getMainWANObjectCache();
                if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
                        $lbConf['wanCache'] = $wCache;
                }
index db3790f..29846bf 100644 (file)
@@ -26,7 +26,7 @@
  *
  * @ingroup Cache
  */
-class HTMLCacheUpdate implements DeferrableUpdate {
+class HTMLCacheUpdate extends DataUpdate {
        /** @var Title */
        public $mTitle;
 
@@ -36,14 +36,24 @@ class HTMLCacheUpdate implements DeferrableUpdate {
        /**
         * @param Title $titleTo
         * @param string $table
+        * @param string $causeAction Triggering action
+        * @param string $causeAgent Triggering user
         */
-       function __construct( Title $titleTo, $table ) {
+       function __construct(
+               Title $titleTo, $table, $causeAction = 'unknown', $causeAgent = 'unknown'
+       ) {
                $this->mTitle = $titleTo;
                $this->mTable = $table;
+               $this->causeAction = $causeAction;
+               $this->causeAgent = $causeAgent;
        }
 
        public function doUpdate() {
-               $job = HTMLCacheUpdateJob::newForBacklinks( $this->mTitle, $this->mTable );
+               $job = HTMLCacheUpdateJob::newForBacklinks(
+                       $this->mTitle,
+                       $this->mTable,
+                       [ 'causeAction' => $this->getCauseAction(), 'causeAgent' => $this->getCauseAgent() ]
+               );
 
                JobQueueGroup::singleton()->lazyPush( $job );
        }
index c27826d..8913642 100644 (file)
@@ -1055,7 +1055,9 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
                                        $inv = [ $inv ];
                                }
                                foreach ( $inv as $table ) {
-                                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, $table ) );
+                                       DeferredUpdates::addUpdate(
+                                               new HTMLCacheUpdate( $this->mTitle, $table, 'page-props' )
+                                       );
                                }
                        }
                }
index 32f4504..54bd0a5 100644 (file)
@@ -1445,7 +1445,9 @@ abstract class File implements IDBAccessObject {
                // Purge cache of all pages using this file
                $title = $this->getTitle();
                if ( $title ) {
-                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
+                       DeferredUpdates::addUpdate(
+                               new HTMLCacheUpdate( $title, 'imagelinks', 'file-purge' )
+                       );
                }
        }
 
index 44c90af..bb12515 100644 (file)
@@ -1740,7 +1740,9 @@ class LocalFile extends File {
                }
 
                # Invalidate cache for all pages using this file
-               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->getTitle(), 'imagelinks' ) );
+               DeferredUpdates::addUpdate(
+                       new HTMLCacheUpdate( $this->getTitle(), 'imagelinks', 'file-upload' )
+               );
 
                return Status::newGood();
        }
index 4d6095c..0925091 100644 (file)
        "config-missing-db-host": "\"{{int:config-db-host}}\"-rentzako balioa sartu behar duzu.",
        "config-missing-db-server-oracle": "\"{{int:config-db-host-oracle}}\"-rentzako balioa sartu behar duzu.",
        "config-invalid-db-server-oracle": "\"$1\" TNS datu basea baliogabea.\nErabili \"TNS izena\" edo \"Konektagarritasun erraza\" katea ([http://docs.oracle.com/cd/E11882_01/network.112/e10836/naming.htm Oracle Naming Methods]).",
+       "config-invalid-db-name": "Datu-basearen izen okerra \"$1\"\nErabil ezazu ASCII letrak bakarrik (a-z, A-Z), zenbakiak (09), behe-gidoiak (_) eta gidoiak (-)",
+       "config-invalid-db-prefix": "Datu-basearen aurrizki okerra \"$1\"\nErabil ezazu ASCII letrak bakarrik (a-z, A-Z) behe-gidoiak (_) eta gidoiak (-)",
        "config-connection-error": "$1\n\nHost-a, erabiltzaile izena eta pasahitza egiaztatu eta saiatu berriro.",
+       "config-invalid-schema": "MediaWikiko eskema okerra \"$1\"\nErabil ezazu ASCII letrak bakarrik (a-z, A-Z) behe-gidoiak (_).",
        "config-db-sys-create-oracle": "Instalatzaileak bakarrik jasaten du SYSBDA kontu bat erabiltzaile kontu berri bat sortzeko.",
        "config-db-sys-user-exists-oracle": "$1 erabiltzaile kontua dagoeneko existitzen da. SYSDBA kontu berri bat sortzeko erabili daiteke soilik!",
        "config-postgres-old": "PostgreSQL $1 edo berriagoa behar da. Zuk $2 badaukazu.",
index 4d75cb3..34028df 100644 (file)
@@ -47,14 +47,16 @@ class HTMLCacheUpdateJob extends Job {
                        // Multiple pages per job make matches unlikely
                        !( isset( $params['pages'] ) && count( $params['pages'] ) != 1 )
                );
+               $this->params += [ 'causeAction' => 'unknown', 'causeAgent' => 'unknown' ];
        }
 
        /**
         * @param Title $title Title to purge backlink pages from
         * @param string $table Backlink table name
+        * @param array $params Additional job parameters
         * @return HTMLCacheUpdateJob
         */
-       public static function newForBacklinks( Title $title, $table ) {
+       public static function newForBacklinks( Title $title, $table, $params = [] ) {
                return new self(
                        $title,
                        [
@@ -62,7 +64,7 @@ class HTMLCacheUpdateJob extends Job {
                                'recursive' => true
                        ] + Job::newRootJobParams( // "overall" refresh links job info
                                "htmlCacheUpdate:{$table}:{$title->getPrefixedText()}"
-                       )
+                       ) + $params
                );
        }
 
@@ -75,6 +77,11 @@ class HTMLCacheUpdateJob extends Job {
 
                // Job to purge all (or a range of) backlink pages for a page
                if ( !empty( $this->params['recursive'] ) ) {
+                       // Carry over information for de-duplication
+                       $extraParams = $this->getRootJobParams();
+                       // Carry over cause information for logging
+                       $extraParams['causeAction'] = $this->params['causeAction'];
+                       $extraParams['causeAgent'] = $this->params['causeAgent'];
                        // Convert this into no more than $wgUpdateRowsPerJob HTMLCacheUpdateJob per-title
                        // jobs and possibly a recursive HTMLCacheUpdateJob job for the rest of the backlinks
                        $jobs = BacklinkJobUtils::partitionBacklinkJob(
@@ -82,7 +89,7 @@ class HTMLCacheUpdateJob extends Job {
                                $wgUpdateRowsPerJob,
                                $wgUpdateRowsPerQuery, // jobs-per-title
                                // Carry over information for de-duplication
-                               [ 'params' => $this->getRootJobParams() ]
+                               [ 'params' => $extraParams ]
                        );
                        JobQueueGroup::singleton()->push( $jobs );
                // Job to purge pages for a set of titles
index f61c139..21558f7 100644 (file)
  * @since 1.22
  */
 class HashRing {
-       /** @var Array (location => weight) */
+       /** @var array (location => weight) */
        protected $sourceMap = [];
-       /** @var Array (location => (start, end)) */
+       /** @var array (location => (start, end)) */
        protected $ring = [];
 
        /** @var HashRing|null */
        protected $liveRing;
-       /** @var Array (location => UNIX timestamp) */
+       /** @var array (location => UNIX timestamp) */
        protected $ejectionExpiries = [];
        /** @var int UNIX timestamp */
        protected $ejectionNextExpiry = INF;
index 209551b..c03d6b2 100644 (file)
@@ -764,7 +764,9 @@ class PageArchive {
                        Hooks::run( 'ArticleUndelete',
                                [ &$this->title, $created, $comment, $oldPageId, $restoredPages ] );
                        if ( $this->title->getNamespace() == NS_FILE ) {
-                               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->title, 'imagelinks' ) );
+                               DeferredUpdates::addUpdate(
+                                       new HTMLCacheUpdate( $this->title, 'imagelinks', 'file-restore' )
+                               );
                        }
                }
 
index 972a397..4c2ebdc 100644 (file)
@@ -173,7 +173,9 @@ class WikiFilePage extends WikiPage {
 
                if ( $this->mFile->exists() ) {
                        wfDebug( 'ImagePage::doPurge purging ' . $this->mFile->getName() . "\n" );
-                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $this->mTitle, 'imagelinks' ) );
+                       DeferredUpdates::addUpdate(
+                               new HTMLCacheUpdate( $this->mTitle, 'imagelinks', 'file-purge' )
+                       );
                } else {
                        wfDebug( 'ImagePage::doPurge no image for '
                                . $this->mFile->getName() . "; limiting purge to cache only\n" );
index 95b7be2..8b34928 100644 (file)
@@ -3317,7 +3317,9 @@ class WikiPage implements Page, IDBAccessObject {
                MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );
 
                // Invalidate caches of articles which include this page
-               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'templatelinks' ) );
+               DeferredUpdates::addUpdate(
+                       new HTMLCacheUpdate( $title, 'templatelinks', 'page-create' )
+               );
 
                if ( $title->getNamespace() == NS_CATEGORY ) {
                        // Load the Category object, which will schedule a job to create
@@ -3355,7 +3357,9 @@ class WikiPage implements Page, IDBAccessObject {
 
                // Images
                if ( $title->getNamespace() == NS_FILE ) {
-                       DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'imagelinks' ) );
+                       DeferredUpdates::addUpdate(
+                               new HTMLCacheUpdate( $title, 'imagelinks', 'page-delete' )
+                       );
                }
 
                // User talk pages
@@ -3378,10 +3382,14 @@ class WikiPage implements Page, IDBAccessObject {
         */
        public static function onArticleEdit( Title $title, Revision $revision = null ) {
                // Invalidate caches of articles which include this page
-               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'templatelinks' ) );
+               DeferredUpdates::addUpdate(
+                       new HTMLCacheUpdate( $title, 'templatelinks', 'page-edit' )
+               );
 
                // Invalidate the caches of all pages which redirect here
-               DeferredUpdates::addUpdate( new HTMLCacheUpdate( $title, 'redirect' ) );
+               DeferredUpdates::addUpdate(
+                       new HTMLCacheUpdate( $title, 'redirect', 'page-edit' )
+               );
 
                MediaWikiServices::getInstance()->getLinkCache()->invalidateTitle( $title );
 
diff --git a/includes/profiler/ProfilerFunctions.php b/includes/profiler/ProfilerFunctions.php
deleted file mode 100644 (file)
index cc71630..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * Core profiling functions. Have to exist before basically anything.
- *
- * 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 Profiler
- */
-
-/**
- * Get system resource usage of current request context.
- * Invokes the getrusage(2) system call, requesting RUSAGE_SELF if on PHP5
- * or RUSAGE_THREAD if on HHVM. Returns false if getrusage is not available.
- *
- * @since 1.24
- * @return array|bool Resource usage data or false if no data available.
- */
-function wfGetRusage() {
-       if ( !function_exists( 'getrusage' ) ) {
-               return false;
-       } elseif ( defined( 'HHVM_VERSION' ) && PHP_OS === 'Linux' ) {
-               return getrusage( 2 /* RUSAGE_THREAD */ );
-       } else {
-               return getrusage( 0 /* RUSAGE_SELF */ );
-       }
-}
-
-/**
- * Begin profiling of a function
- * @param string $functionname Name of the function we will profile
- * @deprecated since 1.25
- */
-function wfProfileIn( $functionname ) {
-}
-
-/**
- * Stop profiling of a function
- * @param string $functionname Name of the function we have profiled
- * @deprecated since 1.25
- */
-function wfProfileOut( $functionname = 'missing' ) {
-}
diff --git a/includes/watcheditem/WatchedItem.php b/includes/watcheditem/WatchedItem.php
new file mode 100644 (file)
index 0000000..bfd1d61
--- /dev/null
@@ -0,0 +1,200 @@
+<?php
+/**
+ * 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 Watchlist
+ */
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Linker\LinkTarget;
+
+/**
+ * Representation of a pair of user and title for watchlist entries.
+ *
+ * @author Tim Starling
+ * @author Addshore
+ *
+ * @ingroup Watchlist
+ */
+class WatchedItem {
+
+       /**
+        * @deprecated since 1.27, see User::IGNORE_USER_RIGHTS
+        */
+       const IGNORE_USER_RIGHTS = User::IGNORE_USER_RIGHTS;
+
+       /**
+        * @deprecated since 1.27, see User::CHECK_USER_RIGHTS
+        */
+       const CHECK_USER_RIGHTS = User::CHECK_USER_RIGHTS;
+
+       /**
+        * @deprecated Internal class use only
+        */
+       const DEPRECATED_USAGE_TIMESTAMP = -100;
+
+       /**
+        * @var bool
+        * @deprecated Internal class use only
+        */
+       public $checkRights = User::CHECK_USER_RIGHTS;
+
+       /**
+        * @var Title
+        * @deprecated Internal class use only
+        */
+       private $title;
+
+       /**
+        * @var LinkTarget
+        */
+       private $linkTarget;
+
+       /**
+        * @var User
+        */
+       private $user;
+
+       /**
+        * @var null|string the value of the wl_notificationtimestamp field
+        */
+       private $notificationTimestamp;
+
+       /**
+        * @param User $user
+        * @param LinkTarget $linkTarget
+        * @param null|string $notificationTimestamp the value of the wl_notificationtimestamp field
+        * @param bool|null $checkRights DO NOT USE - used internally for backward compatibility
+        */
+       public function __construct(
+               User $user,
+               LinkTarget $linkTarget,
+               $notificationTimestamp,
+               $checkRights = null
+       ) {
+               $this->user = $user;
+               $this->linkTarget = $linkTarget;
+               $this->notificationTimestamp = $notificationTimestamp;
+               if ( $checkRights !== null ) {
+                       $this->checkRights = $checkRights;
+               }
+       }
+
+       /**
+        * @return User
+        */
+       public function getUser() {
+               return $this->user;
+       }
+
+       /**
+        * @return LinkTarget
+        */
+       public function getLinkTarget() {
+               return $this->linkTarget;
+       }
+
+       /**
+        * Get the notification timestamp of this entry.
+        *
+        * @return bool|null|string
+        */
+       public function getNotificationTimestamp() {
+               // Back compat for objects constructed using self::fromUserTitle
+               if ( $this->notificationTimestamp === self::DEPRECATED_USAGE_TIMESTAMP ) {
+                       // wfDeprecated( __METHOD__, '1.27' );
+                       if ( $this->checkRights && !$this->user->isAllowed( 'viewmywatchlist' ) ) {
+                               return false;
+                       }
+                       $item = MediaWikiServices::getInstance()->getWatchedItemStore()
+                               ->loadWatchedItem( $this->user, $this->linkTarget );
+                       if ( $item ) {
+                               $this->notificationTimestamp = $item->getNotificationTimestamp();
+                       } else {
+                               $this->notificationTimestamp = false;
+                       }
+               }
+               return $this->notificationTimestamp;
+       }
+
+       /**
+        * Back compat pre 1.27 with the WatchedItemStore introduction
+        * @todo remove in 1.28/9
+        * -------------------------------------------------
+        */
+
+       /**
+        * @return Title
+        * @deprecated Internal class use only
+        */
+       public function getTitle() {
+               if ( !$this->title ) {
+                       $this->title = Title::newFromLinkTarget( $this->linkTarget );
+               }
+               return $this->title;
+       }
+
+       /**
+        * @deprecated since 1.27 Use the constructor, WatchedItemStore::getWatchedItem()
+        *             or WatchedItemStore::loadWatchedItem()
+        */
+       public static function fromUserTitle( $user, $title, $checkRights = User::CHECK_USER_RIGHTS ) {
+               wfDeprecated( __METHOD__, '1.27' );
+               return new self( $user, $title, self::DEPRECATED_USAGE_TIMESTAMP, (bool)$checkRights );
+       }
+
+       /**
+        * @deprecated since 1.27 Use User::addWatch()
+        * @return bool
+        */
+       public function addWatch() {
+               wfDeprecated( __METHOD__, '1.27' );
+               $this->user->addWatch( $this->getTitle(), $this->checkRights );
+               return true;
+       }
+
+       /**
+        * @deprecated since 1.27 Use User::removeWatch()
+        * @return bool
+        */
+       public function removeWatch() {
+               wfDeprecated( __METHOD__, '1.27' );
+               if ( $this->checkRights && !$this->user->isAllowed( 'editmywatchlist' ) ) {
+                       return false;
+               }
+               $this->user->removeWatch( $this->getTitle(), $this->checkRights );
+               return true;
+       }
+
+       /**
+        * @deprecated since 1.27 Use User::isWatched()
+        * @return bool
+        */
+       public function isWatched() {
+               wfDeprecated( __METHOD__, '1.27' );
+               return $this->user->isWatched( $this->getTitle(), $this->checkRights );
+       }
+
+       /**
+        * @deprecated since 1.27 Use WatchedItemStore::duplicateAllAssociatedEntries()
+        */
+       public static function duplicateEntries( Title $oldTitle, Title $newTitle ) {
+               wfDeprecated( __METHOD__, '1.27' );
+               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+               $store->duplicateAllAssociatedEntries( $oldTitle, $newTitle );
+       }
+
+}
diff --git a/includes/watcheditem/WatchedItemQueryService.php b/includes/watcheditem/WatchedItemQueryService.php
new file mode 100644 (file)
index 0000000..d0f45be
--- /dev/null
@@ -0,0 +1,684 @@
+<?php
+
+use Wikimedia\Rdbms\IDatabase;
+use MediaWiki\Linker\LinkTarget;
+use Wikimedia\Assert\Assert;
+use Wikimedia\Rdbms\LoadBalancer;
+
+/**
+ * Class performing complex database queries related to WatchedItems.
+ *
+ * @since 1.28
+ *
+ * @file
+ * @ingroup Watchlist
+ *
+ * @license GNU GPL v2+
+ */
+class WatchedItemQueryService {
+
+       const DIR_OLDER = 'older';
+       const DIR_NEWER = 'newer';
+
+       const INCLUDE_FLAGS = 'flags';
+       const INCLUDE_USER = 'user';
+       const INCLUDE_USER_ID = 'userid';
+       const INCLUDE_COMMENT = 'comment';
+       const INCLUDE_PATROL_INFO = 'patrol';
+       const INCLUDE_SIZES = 'sizes';
+       const INCLUDE_LOG_INFO = 'loginfo';
+
+       // FILTER_* constants are part of public API (are used in ApiQueryWatchlist and
+       // ApiQueryWatchlistRaw classes) and should not be changed.
+       // Changing values of those constants will result in a breaking change in the API
+       const FILTER_MINOR = 'minor';
+       const FILTER_NOT_MINOR = '!minor';
+       const FILTER_BOT = 'bot';
+       const FILTER_NOT_BOT = '!bot';
+       const FILTER_ANON = 'anon';
+       const FILTER_NOT_ANON = '!anon';
+       const FILTER_PATROLLED = 'patrolled';
+       const FILTER_NOT_PATROLLED = '!patrolled';
+       const FILTER_UNREAD = 'unread';
+       const FILTER_NOT_UNREAD = '!unread';
+       const FILTER_CHANGED = 'changed';
+       const FILTER_NOT_CHANGED = '!changed';
+
+       const SORT_ASC = 'ASC';
+       const SORT_DESC = 'DESC';
+
+       /**
+        * @var LoadBalancer
+        */
+       private $loadBalancer;
+
+       /** @var WatchedItemQueryServiceExtension[]|null */
+       private $extensions = null;
+
+       /**
+        * @var CommentStore|null */
+       private $commentStore = null;
+
+       public function __construct( LoadBalancer $loadBalancer ) {
+               $this->loadBalancer = $loadBalancer;
+       }
+
+       /**
+        * @return WatchedItemQueryServiceExtension[]
+        */
+       private function getExtensions() {
+               if ( $this->extensions === null ) {
+                       $this->extensions = [];
+                       Hooks::run( 'WatchedItemQueryServiceExtensions', [ &$this->extensions, $this ] );
+               }
+               return $this->extensions;
+       }
+
+       /**
+        * @return IDatabase
+        * @throws MWException
+        */
+       private function getConnection() {
+               return $this->loadBalancer->getConnectionRef( DB_REPLICA, [ 'watchlist' ] );
+       }
+
+       private function getCommentStore() {
+               if ( !$this->commentStore ) {
+                       $this->commentStore = new CommentStore( 'rc_comment' );
+               }
+               return $this->commentStore;
+       }
+
+       /**
+        * @param User $user
+        * @param array $options Allowed keys:
+        *        'includeFields'       => string[] RecentChange fields to be included in the result,
+        *                                 self::INCLUDE_* constants should be used
+        *        'filters'             => string[] optional filters to narrow down resulted items
+        *        'namespaceIds'        => int[] optional namespace IDs to filter by
+        *                                 (defaults to all namespaces)
+        *        'allRevisions'        => bool return multiple revisions of the same page if true,
+        *                                 only the most recent if false (default)
+        *        'rcTypes'             => int[] which types of RecentChanges to include
+        *                                 (defaults to all types), allowed values: RC_EDIT, RC_NEW,
+        *                                 RC_LOG, RC_EXTERNAL, RC_CATEGORIZE
+        *        'onlyByUser'          => string only list changes by a specified user
+        *        'notByUser'           => string do not incluide changes by a specified user
+        *        'dir'                 => string in which direction to enumerate, accepted values:
+        *                                 - DIR_OLDER list newest first
+        *                                 - DIR_NEWER list oldest first
+        *        'start'               => string (format accepted by wfTimestamp) requires 'dir' option,
+        *                                 timestamp to start enumerating from
+        *        'end'                 => string (format accepted by wfTimestamp) requires 'dir' option,
+        *                                 timestamp to end enumerating
+        *        'watchlistOwner'      => User user whose watchlist items should be listed if different
+        *                                 than the one specified with $user param,
+        *                                 requires 'watchlistOwnerToken' option
+        *        'watchlistOwnerToken' => string a watchlist token used to access another user's
+        *                                 watchlist, used with 'watchlistOwnerToken' option
+        *        'limit'               => int maximum numbers of items to return
+        *        'usedInGenerator'     => bool include only RecentChange id field required by the
+        *                                 generator ('rc_cur_id' or 'rc_this_oldid') if true, or all
+        *                                 id fields ('rc_cur_id', 'rc_this_oldid', 'rc_last_oldid')
+        *                                 if false (default)
+        * @param array|null &$startFrom Continuation value: [ string $rcTimestamp, int $rcId ]
+        * @return array of pairs ( WatchedItem $watchedItem, string[] $recentChangeInfo ),
+        *         where $recentChangeInfo contains the following keys:
+        *         - 'rc_id',
+        *         - 'rc_namespace',
+        *         - 'rc_title',
+        *         - 'rc_timestamp',
+        *         - 'rc_type',
+        *         - 'rc_deleted',
+        *         Additional keys could be added by specifying the 'includeFields' option
+        */
+       public function getWatchedItemsWithRecentChangeInfo(
+               User $user, array $options = [], &$startFrom = null
+       ) {
+               $options += [
+                       'includeFields' => [],
+                       'namespaceIds' => [],
+                       'filters' => [],
+                       'allRevisions' => false,
+                       'usedInGenerator' => false
+               ];
+
+               Assert::parameter(
+                       !isset( $options['rcTypes'] )
+                               || !array_diff( $options['rcTypes'], [ RC_EDIT, RC_NEW, RC_LOG, RC_EXTERNAL, RC_CATEGORIZE ] ),
+                       '$options[\'rcTypes\']',
+                       'must be an array containing only: RC_EDIT, RC_NEW, RC_LOG, RC_EXTERNAL and/or RC_CATEGORIZE'
+               );
+               Assert::parameter(
+                       !isset( $options['dir'] ) || in_array( $options['dir'], [ self::DIR_OLDER, self::DIR_NEWER ] ),
+                       '$options[\'dir\']',
+                       'must be DIR_OLDER or DIR_NEWER'
+               );
+               Assert::parameter(
+                       !isset( $options['start'] ) && !isset( $options['end'] ) && $startFrom === null
+                               || isset( $options['dir'] ),
+                       '$options[\'dir\']',
+                       'must be provided when providing the "start" or "end" options or the $startFrom parameter'
+               );
+               Assert::parameter(
+                       !isset( $options['startFrom'] ),
+                       '$options[\'startFrom\']',
+                       'must not be provided, use $startFrom instead'
+               );
+               Assert::parameter(
+                       !isset( $startFrom ) || ( is_array( $startFrom ) && count( $startFrom ) === 2 ),
+                       '$startFrom',
+                       'must be a two-element array'
+               );
+               if ( array_key_exists( 'watchlistOwner', $options ) ) {
+                       Assert::parameterType(
+                               User::class,
+                               $options['watchlistOwner'],
+                               '$options[\'watchlistOwner\']'
+                       );
+                       Assert::parameter(
+                               isset( $options['watchlistOwnerToken'] ),
+                               '$options[\'watchlistOwnerToken\']',
+                               'must be provided when providing watchlistOwner option'
+                       );
+               }
+
+               $db = $this->getConnection();
+
+               $tables = $this->getWatchedItemsWithRCInfoQueryTables( $options );
+               $fields = $this->getWatchedItemsWithRCInfoQueryFields( $options );
+               $conds = $this->getWatchedItemsWithRCInfoQueryConds( $db, $user, $options );
+               $dbOptions = $this->getWatchedItemsWithRCInfoQueryDbOptions( $options );
+               $joinConds = $this->getWatchedItemsWithRCInfoQueryJoinConds( $options );
+
+               if ( $startFrom !== null ) {
+                       $conds[] = $this->getStartFromConds( $db, $options, $startFrom );
+               }
+
+               foreach ( $this->getExtensions() as $extension ) {
+                       $extension->modifyWatchedItemsWithRCInfoQuery(
+                               $user, $options, $db,
+                               $tables,
+                               $fields,
+                               $conds,
+                               $dbOptions,
+                               $joinConds
+                       );
+               }
+
+               $res = $db->select(
+                       $tables,
+                       $fields,
+                       $conds,
+                       __METHOD__,
+                       $dbOptions,
+                       $joinConds
+               );
+
+               $limit = isset( $dbOptions['LIMIT'] ) ? $dbOptions['LIMIT'] : INF;
+               $items = [];
+               $startFrom = null;
+               foreach ( $res as $row ) {
+                       if ( --$limit <= 0 ) {
+                               $startFrom = [ $row->rc_timestamp, $row->rc_id ];
+                               break;
+                       }
+
+                       $items[] = [
+                               new WatchedItem(
+                                       $user,
+                                       new TitleValue( (int)$row->rc_namespace, $row->rc_title ),
+                                       $row->wl_notificationtimestamp
+                               ),
+                               $this->getRecentChangeFieldsFromRow( $row )
+                       ];
+               }
+
+               foreach ( $this->getExtensions() as $extension ) {
+                       $extension->modifyWatchedItemsWithRCInfo( $user, $options, $db, $items, $res, $startFrom );
+               }
+
+               return $items;
+       }
+
+       /**
+        * For simple listing of user's watchlist items, see WatchedItemStore::getWatchedItemsForUser
+        *
+        * @param User $user
+        * @param array $options Allowed keys:
+        *        'sort'         => string optional sorting by namespace ID and title
+        *                          one of the self::SORT_* constants
+        *        'namespaceIds' => int[] optional namespace IDs to filter by (defaults to all namespaces)
+        *        'limit'        => int maximum number of items to return
+        *        'filter'       => string optional filter, one of the self::FILTER_* contants
+        *        'from'         => LinkTarget requires 'sort' key, only return items starting from
+        *                          those related to the link target
+        *        'until'        => LinkTarget requires 'sort' key, only return items until
+        *                          those related to the link target
+        *        'startFrom'    => LinkTarget requires 'sort' key, only return items starting from
+        *                          those related to the link target, allows to skip some link targets
+        *                          specified using the form option
+        * @return WatchedItem[]
+        */
+       public function getWatchedItemsForUser( User $user, array $options = [] ) {
+               if ( $user->isAnon() ) {
+                       // TODO: should this just return an empty array or rather complain loud at this point
+                       // as e.g. ApiBase::getWatchlistUser does?
+                       return [];
+               }
+
+               $options += [ 'namespaceIds' => [] ];
+
+               Assert::parameter(
+                       !isset( $options['sort'] ) || in_array( $options['sort'], [ self::SORT_ASC, self::SORT_DESC ] ),
+                       '$options[\'sort\']',
+                       'must be SORT_ASC or SORT_DESC'
+               );
+               Assert::parameter(
+                       !isset( $options['filter'] ) || in_array(
+                               $options['filter'], [ self::FILTER_CHANGED, self::FILTER_NOT_CHANGED ]
+                       ),
+                       '$options[\'filter\']',
+                       'must be FILTER_CHANGED or FILTER_NOT_CHANGED'
+               );
+               Assert::parameter(
+                       !isset( $options['from'] ) && !isset( $options['until'] ) && !isset( $options['startFrom'] )
+                       || isset( $options['sort'] ),
+                       '$options[\'sort\']',
+                       'must be provided if any of "from", "until", "startFrom" options is provided'
+               );
+
+               $db = $this->getConnection();
+
+               $conds = $this->getWatchedItemsForUserQueryConds( $db, $user, $options );
+               $dbOptions = $this->getWatchedItemsForUserQueryDbOptions( $options );
+
+               $res = $db->select(
+                       'watchlist',
+                       [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                       $conds,
+                       __METHOD__,
+                       $dbOptions
+               );
+
+               $watchedItems = [];
+               foreach ( $res as $row ) {
+                       // todo these could all be cached at some point?
+                       $watchedItems[] = new WatchedItem(
+                               $user,
+                               new TitleValue( (int)$row->wl_namespace, $row->wl_title ),
+                               $row->wl_notificationtimestamp
+                       );
+               }
+
+               return $watchedItems;
+       }
+
+       private function getRecentChangeFieldsFromRow( stdClass $row ) {
+               // This can be simplified to single array_filter call filtering by key value,
+               // once we stop supporting PHP 5.5
+               $allFields = get_object_vars( $row );
+               $rcKeys = array_filter(
+                       array_keys( $allFields ),
+                       function ( $key ) {
+                               return substr( $key, 0, 3 ) === 'rc_';
+                       }
+               );
+               return array_intersect_key( $allFields, array_flip( $rcKeys ) );
+       }
+
+       private function getWatchedItemsWithRCInfoQueryTables( array $options ) {
+               $tables = [ 'recentchanges', 'watchlist' ];
+               if ( !$options['allRevisions'] ) {
+                       $tables[] = 'page';
+               }
+               if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) {
+                       $tables += $this->getCommentStore()->getJoin()['tables'];
+               }
+               return $tables;
+       }
+
+       private function getWatchedItemsWithRCInfoQueryFields( array $options ) {
+               $fields = [
+                       'rc_id',
+                       'rc_namespace',
+                       'rc_title',
+                       'rc_timestamp',
+                       'rc_type',
+                       'rc_deleted',
+                       'wl_notificationtimestamp'
+               ];
+
+               $rcIdFields = [
+                       'rc_cur_id',
+                       'rc_this_oldid',
+                       'rc_last_oldid',
+               ];
+               if ( $options['usedInGenerator'] ) {
+                       if ( $options['allRevisions'] ) {
+                               $rcIdFields = [ 'rc_this_oldid' ];
+                       } else {
+                               $rcIdFields = [ 'rc_cur_id' ];
+                       }
+               }
+               $fields = array_merge( $fields, $rcIdFields );
+
+               if ( in_array( self::INCLUDE_FLAGS, $options['includeFields'] ) ) {
+                       $fields = array_merge( $fields, [ 'rc_type', 'rc_minor', 'rc_bot' ] );
+               }
+               if ( in_array( self::INCLUDE_USER, $options['includeFields'] ) ) {
+                       $fields[] = 'rc_user_text';
+               }
+               if ( in_array( self::INCLUDE_USER_ID, $options['includeFields'] ) ) {
+                       $fields[] = 'rc_user';
+               }
+               if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) {
+                       $fields += $this->getCommentStore()->getJoin()['fields'];
+               }
+               if ( in_array( self::INCLUDE_PATROL_INFO, $options['includeFields'] ) ) {
+                       $fields = array_merge( $fields, [ 'rc_patrolled', 'rc_log_type' ] );
+               }
+               if ( in_array( self::INCLUDE_SIZES, $options['includeFields'] ) ) {
+                       $fields = array_merge( $fields, [ 'rc_old_len', 'rc_new_len' ] );
+               }
+               if ( in_array( self::INCLUDE_LOG_INFO, $options['includeFields'] ) ) {
+                       $fields = array_merge( $fields, [ 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ] );
+               }
+
+               return $fields;
+       }
+
+       private function getWatchedItemsWithRCInfoQueryConds(
+               IDatabase $db,
+               User $user,
+               array $options
+       ) {
+               $watchlistOwnerId = $this->getWatchlistOwnerId( $user, $options );
+               $conds = [ 'wl_user' => $watchlistOwnerId ];
+
+               if ( !$options['allRevisions'] ) {
+                       $conds[] = $db->makeList(
+                               [ 'rc_this_oldid=page_latest', 'rc_type=' . RC_LOG ],
+                               LIST_OR
+                       );
+               }
+
+               if ( $options['namespaceIds'] ) {
+                       $conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] );
+               }
+
+               if ( array_key_exists( 'rcTypes', $options ) ) {
+                       $conds['rc_type'] = array_map( 'intval', $options['rcTypes'] );
+               }
+
+               $conds = array_merge(
+                       $conds,
+                       $this->getWatchedItemsWithRCInfoQueryFilterConds( $user, $options )
+               );
+
+               $conds = array_merge( $conds, $this->getStartEndConds( $db, $options ) );
+
+               if ( !isset( $options['start'] ) && !isset( $options['end'] ) ) {
+                       if ( $db->getType() === 'mysql' ) {
+                               // This is an index optimization for mysql
+                               $conds[] = 'rc_timestamp > ' . $db->addQuotes( '' );
+                       }
+               }
+
+               $conds = array_merge( $conds, $this->getUserRelatedConds( $db, $user, $options ) );
+
+               $deletedPageLogCond = $this->getExtraDeletedPageLogEntryRelatedCond( $db, $user );
+               if ( $deletedPageLogCond ) {
+                       $conds[] = $deletedPageLogCond;
+               }
+
+               return $conds;
+       }
+
+       private function getWatchlistOwnerId( User $user, array $options ) {
+               if ( array_key_exists( 'watchlistOwner', $options ) ) {
+                       /** @var User $watchlistOwner */
+                       $watchlistOwner = $options['watchlistOwner'];
+                       $ownersToken = $watchlistOwner->getOption( 'watchlisttoken' );
+                       $token = $options['watchlistOwnerToken'];
+                       if ( $ownersToken == '' || !hash_equals( $ownersToken, $token ) ) {
+                               throw ApiUsageException::newWithMessage( null, 'apierror-bad-watchlist-token', 'bad_wltoken' );
+                       }
+                       return $watchlistOwner->getId();
+               }
+               return $user->getId();
+       }
+
+       private function getWatchedItemsWithRCInfoQueryFilterConds( User $user, array $options ) {
+               $conds = [];
+
+               if ( in_array( self::FILTER_MINOR, $options['filters'] ) ) {
+                       $conds[] = 'rc_minor != 0';
+               } elseif ( in_array( self::FILTER_NOT_MINOR, $options['filters'] ) ) {
+                       $conds[] = 'rc_minor = 0';
+               }
+
+               if ( in_array( self::FILTER_BOT, $options['filters'] ) ) {
+                       $conds[] = 'rc_bot != 0';
+               } elseif ( in_array( self::FILTER_NOT_BOT, $options['filters'] ) ) {
+                       $conds[] = 'rc_bot = 0';
+               }
+
+               if ( in_array( self::FILTER_ANON, $options['filters'] ) ) {
+                       $conds[] = 'rc_user = 0';
+               } elseif ( in_array( self::FILTER_NOT_ANON, $options['filters'] ) ) {
+                       $conds[] = 'rc_user != 0';
+               }
+
+               if ( $user->useRCPatrol() || $user->useNPPatrol() ) {
+                       // TODO: not sure if this should simply ignore patrolled filters if user does not have the patrol
+                       // right, or maybe rather fail loud at this point, same as e.g. ApiQueryWatchlist does?
+                       if ( in_array( self::FILTER_PATROLLED, $options['filters'] ) ) {
+                               $conds[] = 'rc_patrolled != 0';
+                       } elseif ( in_array( self::FILTER_NOT_PATROLLED, $options['filters'] ) ) {
+                               $conds[] = 'rc_patrolled = 0';
+                       }
+               }
+
+               if ( in_array( self::FILTER_UNREAD, $options['filters'] ) ) {
+                       $conds[] = 'rc_timestamp >= wl_notificationtimestamp';
+               } elseif ( in_array( self::FILTER_NOT_UNREAD, $options['filters'] ) ) {
+                       // TODO: should this be changed to use Database::makeList?
+                       $conds[] = 'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp';
+               }
+
+               return $conds;
+       }
+
+       private function getStartEndConds( IDatabase $db, array $options ) {
+               if ( !isset( $options['start'] ) && !isset( $options['end'] ) ) {
+                       return [];
+               }
+
+               $conds = [];
+
+               if ( isset( $options['start'] ) ) {
+                       $after = $options['dir'] === self::DIR_OLDER ? '<=' : '>=';
+                       $conds[] = 'rc_timestamp ' . $after . ' ' .
+                               $db->addQuotes( $db->timestamp( $options['start'] ) );
+               }
+               if ( isset( $options['end'] ) ) {
+                       $before = $options['dir'] === self::DIR_OLDER ? '>=' : '<=';
+                       $conds[] = 'rc_timestamp ' . $before . ' ' .
+                               $db->addQuotes( $db->timestamp( $options['end'] ) );
+               }
+
+               return $conds;
+       }
+
+       private function getUserRelatedConds( IDatabase $db, User $user, array $options ) {
+               if ( !array_key_exists( 'onlyByUser', $options ) && !array_key_exists( 'notByUser', $options ) ) {
+                       return [];
+               }
+
+               $conds = [];
+
+               if ( array_key_exists( 'onlyByUser', $options ) ) {
+                       $conds['rc_user_text'] = $options['onlyByUser'];
+               } elseif ( array_key_exists( 'notByUser', $options ) ) {
+                       $conds[] = 'rc_user_text != ' . $db->addQuotes( $options['notByUser'] );
+               }
+
+               // Avoid brute force searches (T19342)
+               $bitmask = 0;
+               if ( !$user->isAllowed( 'deletedhistory' ) ) {
+                       $bitmask = Revision::DELETED_USER;
+               } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
+                       $bitmask = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
+               }
+               if ( $bitmask ) {
+                       $conds[] = $db->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask";
+               }
+
+               return $conds;
+       }
+
+       private function getExtraDeletedPageLogEntryRelatedCond( IDatabase $db, User $user ) {
+               // LogPage::DELETED_ACTION hides the affected page, too. So hide those
+               // entirely from the watchlist, or someone could guess the title.
+               $bitmask = 0;
+               if ( !$user->isAllowed( 'deletedhistory' ) ) {
+                       $bitmask = LogPage::DELETED_ACTION;
+               } elseif ( !$user->isAllowedAny( 'suppressrevision', 'viewsuppressed' ) ) {
+                       $bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
+               }
+               if ( $bitmask ) {
+                       return $db->makeList( [
+                               'rc_type != ' . RC_LOG,
+                               $db->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
+                       ], LIST_OR );
+               }
+               return '';
+       }
+
+       private function getStartFromConds( IDatabase $db, array $options, array $startFrom ) {
+               $op = $options['dir'] === self::DIR_OLDER ? '<' : '>';
+               list( $rcTimestamp, $rcId ) = $startFrom;
+               $rcTimestamp = $db->addQuotes( $db->timestamp( $rcTimestamp ) );
+               $rcId = (int)$rcId;
+               return $db->makeList(
+                       [
+                               "rc_timestamp $op $rcTimestamp",
+                               $db->makeList(
+                                       [
+                                               "rc_timestamp = $rcTimestamp",
+                                               "rc_id $op= $rcId"
+                                       ],
+                                       LIST_AND
+                               )
+                       ],
+                       LIST_OR
+               );
+       }
+
+       private function getWatchedItemsForUserQueryConds( IDatabase $db, User $user, array $options ) {
+               $conds = [ 'wl_user' => $user->getId() ];
+               if ( $options['namespaceIds'] ) {
+                       $conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] );
+               }
+               if ( isset( $options['filter'] ) ) {
+                       $filter = $options['filter'];
+                       if ( $filter === self::FILTER_CHANGED ) {
+                               $conds[] = 'wl_notificationtimestamp IS NOT NULL';
+                       } else {
+                               $conds[] = 'wl_notificationtimestamp IS NULL';
+                       }
+               }
+
+               if ( isset( $options['from'] ) ) {
+                       $op = $options['sort'] === self::SORT_ASC ? '>' : '<';
+                       $conds[] = $this->getFromUntilTargetConds( $db, $options['from'], $op );
+               }
+               if ( isset( $options['until'] ) ) {
+                       $op = $options['sort'] === self::SORT_ASC ? '<' : '>';
+                       $conds[] = $this->getFromUntilTargetConds( $db, $options['until'], $op );
+               }
+               if ( isset( $options['startFrom'] ) ) {
+                       $op = $options['sort'] === self::SORT_ASC ? '>' : '<';
+                       $conds[] = $this->getFromUntilTargetConds( $db, $options['startFrom'], $op );
+               }
+
+               return $conds;
+       }
+
+       /**
+        * Creates a query condition part for getting only items before or after the given link target
+        * (while ordering using $sort mode)
+        *
+        * @param IDatabase $db
+        * @param LinkTarget $target
+        * @param string $op comparison operator to use in the conditions
+        * @return string
+        */
+       private function getFromUntilTargetConds( IDatabase $db, LinkTarget $target, $op ) {
+               return $db->makeList(
+                       [
+                               "wl_namespace $op " . $target->getNamespace(),
+                               $db->makeList(
+                                       [
+                                               'wl_namespace = ' . $target->getNamespace(),
+                                               "wl_title $op= " . $db->addQuotes( $target->getDBkey() )
+                                       ],
+                                       LIST_AND
+                               )
+                       ],
+                       LIST_OR
+               );
+       }
+
+       private function getWatchedItemsWithRCInfoQueryDbOptions( array $options ) {
+               $dbOptions = [];
+
+               if ( array_key_exists( 'dir', $options ) ) {
+                       $sort = $options['dir'] === self::DIR_OLDER ? ' DESC' : '';
+                       $dbOptions['ORDER BY'] = [ 'rc_timestamp' . $sort, 'rc_id' . $sort ];
+               }
+
+               if ( array_key_exists( 'limit', $options ) ) {
+                       $dbOptions['LIMIT'] = (int)$options['limit'] + 1;
+               }
+
+               return $dbOptions;
+       }
+
+       private function getWatchedItemsForUserQueryDbOptions( array $options ) {
+               $dbOptions = [];
+               if ( array_key_exists( 'sort', $options ) ) {
+                       $dbOptions['ORDER BY'] = [
+                               "wl_namespace {$options['sort']}",
+                               "wl_title {$options['sort']}"
+                       ];
+                       if ( count( $options['namespaceIds'] ) === 1 ) {
+                               $dbOptions['ORDER BY'] = "wl_title {$options['sort']}";
+                       }
+               }
+               if ( array_key_exists( 'limit', $options ) ) {
+                       $dbOptions['LIMIT'] = (int)$options['limit'];
+               }
+               return $dbOptions;
+       }
+
+       private function getWatchedItemsWithRCInfoQueryJoinConds( array $options ) {
+               $joinConds = [
+                       'watchlist' => [ 'INNER JOIN',
+                               [
+                                       'wl_namespace=rc_namespace',
+                                       'wl_title=rc_title'
+                               ]
+                       ]
+               ];
+               if ( !$options['allRevisions'] ) {
+                       $joinConds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
+               }
+               if ( in_array( self::INCLUDE_COMMENT, $options['includeFields'] ) ) {
+                       $joinConds += $this->getCommentStore()->getJoin()['joins'];
+               }
+               return $joinConds;
+       }
+
+}
diff --git a/includes/watcheditem/WatchedItemQueryServiceExtension.php b/includes/watcheditem/WatchedItemQueryServiceExtension.php
new file mode 100644 (file)
index 0000000..93d5033
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+use Wikimedia\Rdbms\ResultWrapper;
+use Wikimedia\Rdbms\IDatabase;
+
+/**
+ * Extension mechanism for WatchedItemQueryService
+ *
+ * @since 1.29
+ *
+ * @file
+ * @ingroup Watchlist
+ *
+ * @license GNU GPL v2+
+ */
+interface WatchedItemQueryServiceExtension {
+
+       /**
+        * Modify the WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
+        * query before it's made.
+        *
+        * @warning Any joins added *must* join on a unique key of the target table
+        *  unless you really know what you're doing.
+        * @param User $user
+        * @param array $options Options from
+        *  WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
+        * @param IDatabase $db Database connection being used for the query
+        * @param array &$tables Tables for Database::select()
+        * @param array &$fields Fields for Database::select()
+        * @param array &$conds Conditions for Database::select()
+        * @param array &$dbOptions Options for Database::select()
+        * @param array &$joinConds Join conditions for Database::select()
+        */
+       public function modifyWatchedItemsWithRCInfoQuery( User $user, array $options, IDatabase $db,
+               array &$tables, array &$fields, array &$conds, array &$dbOptions, array &$joinConds
+       );
+
+       /**
+        * Modify the results from WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
+        * before they're returned.
+        *
+        * @param User $user
+        * @param array $options Options from
+        *  WatchedItemQueryService::getWatchedItemsWithRecentChangeInfo()
+        * @param IDatabase $db Database connection being used for the query
+        * @param array &$items array of pairs ( WatchedItem $watchedItem, string[] $recentChangeInfo ).
+        *  May be truncated if necessary, in which case $startFrom must be updated.
+        * @param ResultWrapper|bool $res Database query result
+        * @param array|null &$startFrom Continuation value. If you truncate $items, set this to
+        *  [ $recentChangeInfo['rc_timestamp'], $recentChangeInfo['rc_id'] ] from the first item
+        *  removed.
+        */
+       public function modifyWatchedItemsWithRCInfo( User $user, array $options, IDatabase $db,
+               array &$items, $res, &$startFrom
+       );
+
+}
diff --git a/includes/watcheditem/WatchedItemStore.php b/includes/watcheditem/WatchedItemStore.php
new file mode 100644 (file)
index 0000000..60d8b76
--- /dev/null
@@ -0,0 +1,986 @@
+<?php
+
+use Wikimedia\Rdbms\IDatabase;
+use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
+use MediaWiki\Linker\LinkTarget;
+use MediaWiki\MediaWikiServices;
+use Wikimedia\Assert\Assert;
+use Wikimedia\ScopedCallback;
+use Wikimedia\Rdbms\LoadBalancer;
+use Wikimedia\Rdbms\DBUnexpectedError;
+
+/**
+ * Storage layer class for WatchedItems.
+ * Database interaction.
+ *
+ * Uses database because this uses User::isAnon
+ *
+ * @group Database
+ *
+ * @author Addshore
+ * @since 1.27
+ */
+class WatchedItemStore implements StatsdAwareInterface {
+
+       const SORT_DESC = 'DESC';
+       const SORT_ASC = 'ASC';
+
+       /**
+        * @var LoadBalancer
+        */
+       private $loadBalancer;
+
+       /**
+        * @var ReadOnlyMode
+        */
+       private $readOnlyMode;
+
+       /**
+        * @var HashBagOStuff
+        */
+       private $cache;
+
+       /**
+        * @var array[] Looks like $cacheIndex[Namespace ID][Target DB Key][User Id] => 'key'
+        * The index is needed so that on mass changes all relevant items can be un-cached.
+        * For example: Clearing a users watchlist of all items or updating notification timestamps
+        *              for all users watching a single target.
+        */
+       private $cacheIndex = [];
+
+       /**
+        * @var callable|null
+        */
+       private $deferredUpdatesAddCallableUpdateCallback;
+
+       /**
+        * @var callable|null
+        */
+       private $revisionGetTimestampFromIdCallback;
+
+       /**
+        * @var StatsdDataFactoryInterface
+        */
+       private $stats;
+
+       /**
+        * @param LoadBalancer $loadBalancer
+        * @param HashBagOStuff $cache
+        * @param ReadOnlyMode $readOnlyMode
+        */
+       public function __construct(
+               LoadBalancer $loadBalancer,
+               HashBagOStuff $cache,
+               ReadOnlyMode $readOnlyMode
+       ) {
+               $this->loadBalancer = $loadBalancer;
+               $this->cache = $cache;
+               $this->readOnlyMode = $readOnlyMode;
+               $this->stats = new NullStatsdDataFactory();
+               $this->deferredUpdatesAddCallableUpdateCallback = [ 'DeferredUpdates', 'addCallableUpdate' ];
+               $this->revisionGetTimestampFromIdCallback = [ 'Revision', 'getTimestampFromId' ];
+       }
+
+       public function setStatsdDataFactory( StatsdDataFactoryInterface $stats ) {
+               $this->stats = $stats;
+       }
+
+       /**
+        * Overrides the DeferredUpdates::addCallableUpdate callback
+        * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
+        *
+        * @param callable $callback
+        *
+        * @see DeferredUpdates::addCallableUpdate for callback signiture
+        *
+        * @return ScopedCallback to reset the overridden value
+        * @throws MWException
+        */
+       public function overrideDeferredUpdatesAddCallableUpdateCallback( callable $callback ) {
+               if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
+                       throw new MWException(
+                               'Cannot override DeferredUpdates::addCallableUpdate callback in operation.'
+                       );
+               }
+               $previousValue = $this->deferredUpdatesAddCallableUpdateCallback;
+               $this->deferredUpdatesAddCallableUpdateCallback = $callback;
+               return new ScopedCallback( function () use ( $previousValue ) {
+                       $this->deferredUpdatesAddCallableUpdateCallback = $previousValue;
+               } );
+       }
+
+       /**
+        * Overrides the Revision::getTimestampFromId callback
+        * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
+        *
+        * @param callable $callback
+        * @see Revision::getTimestampFromId for callback signiture
+        *
+        * @return ScopedCallback to reset the overridden value
+        * @throws MWException
+        */
+       public function overrideRevisionGetTimestampFromIdCallback( callable $callback ) {
+               if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
+                       throw new MWException(
+                               'Cannot override Revision::getTimestampFromId callback in operation.'
+                       );
+               }
+               $previousValue = $this->revisionGetTimestampFromIdCallback;
+               $this->revisionGetTimestampFromIdCallback = $callback;
+               return new ScopedCallback( function () use ( $previousValue ) {
+                       $this->revisionGetTimestampFromIdCallback = $previousValue;
+               } );
+       }
+
+       private function getCacheKey( User $user, LinkTarget $target ) {
+               return $this->cache->makeKey(
+                       (string)$target->getNamespace(),
+                       $target->getDBkey(),
+                       (string)$user->getId()
+               );
+       }
+
+       private function cache( WatchedItem $item ) {
+               $user = $item->getUser();
+               $target = $item->getLinkTarget();
+               $key = $this->getCacheKey( $user, $target );
+               $this->cache->set( $key, $item );
+               $this->cacheIndex[$target->getNamespace()][$target->getDBkey()][$user->getId()] = $key;
+               $this->stats->increment( 'WatchedItemStore.cache' );
+       }
+
+       private function uncache( User $user, LinkTarget $target ) {
+               $this->cache->delete( $this->getCacheKey( $user, $target ) );
+               unset( $this->cacheIndex[$target->getNamespace()][$target->getDBkey()][$user->getId()] );
+               $this->stats->increment( 'WatchedItemStore.uncache' );
+       }
+
+       private function uncacheLinkTarget( LinkTarget $target ) {
+               $this->stats->increment( 'WatchedItemStore.uncacheLinkTarget' );
+               if ( !isset( $this->cacheIndex[$target->getNamespace()][$target->getDBkey()] ) ) {
+                       return;
+               }
+               foreach ( $this->cacheIndex[$target->getNamespace()][$target->getDBkey()] as $key ) {
+                       $this->stats->increment( 'WatchedItemStore.uncacheLinkTarget.items' );
+                       $this->cache->delete( $key );
+               }
+       }
+
+       private function uncacheUser( User $user ) {
+               $this->stats->increment( 'WatchedItemStore.uncacheUser' );
+               foreach ( $this->cacheIndex as $ns => $dbKeyArray ) {
+                       foreach ( $dbKeyArray as $dbKey => $userArray ) {
+                               if ( isset( $userArray[$user->getId()] ) ) {
+                                       $this->stats->increment( 'WatchedItemStore.uncacheUser.items' );
+                                       $this->cache->delete( $userArray[$user->getId()] );
+                               }
+                       }
+               }
+       }
+
+       /**
+        * @param User $user
+        * @param LinkTarget $target
+        *
+        * @return WatchedItem|false
+        */
+       private function getCached( User $user, LinkTarget $target ) {
+               return $this->cache->get( $this->getCacheKey( $user, $target ) );
+       }
+
+       /**
+        * Return an array of conditions to select or update the appropriate database
+        * row.
+        *
+        * @param User $user
+        * @param LinkTarget $target
+        *
+        * @return array
+        */
+       private function dbCond( User $user, LinkTarget $target ) {
+               return [
+                       'wl_user' => $user->getId(),
+                       'wl_namespace' => $target->getNamespace(),
+                       'wl_title' => $target->getDBkey(),
+               ];
+       }
+
+       /**
+        * @param int $dbIndex DB_MASTER or DB_REPLICA
+        *
+        * @return IDatabase
+        * @throws MWException
+        */
+       private function getConnectionRef( $dbIndex ) {
+               return $this->loadBalancer->getConnectionRef( $dbIndex, [ 'watchlist' ] );
+       }
+
+       /**
+        * Count the number of individual items that are watched by the user.
+        * If a subject and corresponding talk page are watched this will return 2.
+        *
+        * @param User $user
+        *
+        * @return int
+        */
+       public function countWatchedItems( User $user ) {
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+               $return = (int)$dbr->selectField(
+                       'watchlist',
+                       'COUNT(*)',
+                       [
+                               'wl_user' => $user->getId()
+                       ],
+                       __METHOD__
+               );
+
+               return $return;
+       }
+
+       /**
+        * @param LinkTarget $target
+        *
+        * @return int
+        */
+       public function countWatchers( LinkTarget $target ) {
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+               $return = (int)$dbr->selectField(
+                       'watchlist',
+                       'COUNT(*)',
+                       [
+                               'wl_namespace' => $target->getNamespace(),
+                               'wl_title' => $target->getDBkey(),
+                       ],
+                       __METHOD__
+               );
+
+               return $return;
+       }
+
+       /**
+        * Number of page watchers who also visited a "recent" edit
+        *
+        * @param LinkTarget $target
+        * @param mixed $threshold timestamp accepted by wfTimestamp
+        *
+        * @return int
+        * @throws DBUnexpectedError
+        * @throws MWException
+        */
+       public function countVisitingWatchers( LinkTarget $target, $threshold ) {
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+               $visitingWatchers = (int)$dbr->selectField(
+                       'watchlist',
+                       'COUNT(*)',
+                       [
+                               'wl_namespace' => $target->getNamespace(),
+                               'wl_title' => $target->getDBkey(),
+                               'wl_notificationtimestamp >= ' .
+                               $dbr->addQuotes( $dbr->timestamp( $threshold ) ) .
+                               ' OR wl_notificationtimestamp IS NULL'
+                       ],
+                       __METHOD__
+               );
+
+               return $visitingWatchers;
+       }
+
+       /**
+        * @param LinkTarget[] $targets
+        * @param array $options Allowed keys:
+        *        'minimumWatchers' => int
+        *
+        * @return array multi dimensional like $return[$namespaceId][$titleString] = int $watchers
+        *         All targets will be present in the result. 0 either means no watchers or the number
+        *         of watchers was below the minimumWatchers option if passed.
+        */
+       public function countWatchersMultiple( array $targets, array $options = [] ) {
+               $dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ];
+
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+
+               if ( array_key_exists( 'minimumWatchers', $options ) ) {
+                       $dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$options['minimumWatchers'];
+               }
+
+               $lb = new LinkBatch( $targets );
+               $res = $dbr->select(
+                       'watchlist',
+                       [ 'wl_title', 'wl_namespace', 'watchers' => 'COUNT(*)' ],
+                       [ $lb->constructSet( 'wl', $dbr ) ],
+                       __METHOD__,
+                       $dbOptions
+               );
+
+               $watchCounts = [];
+               foreach ( $targets as $linkTarget ) {
+                       $watchCounts[$linkTarget->getNamespace()][$linkTarget->getDBkey()] = 0;
+               }
+
+               foreach ( $res as $row ) {
+                       $watchCounts[$row->wl_namespace][$row->wl_title] = (int)$row->watchers;
+               }
+
+               return $watchCounts;
+       }
+
+       /**
+        * Number of watchers of each page who have visited recent edits to that page
+        *
+        * @param array $targetsWithVisitThresholds array of pairs (LinkTarget $target, mixed $threshold),
+        *        $threshold is:
+        *        - a timestamp of the recent edit if $target exists (format accepted by wfTimestamp)
+        *        - null if $target doesn't exist
+        * @param int|null $minimumWatchers
+        * @return array multi-dimensional like $return[$namespaceId][$titleString] = $watchers,
+        *         where $watchers is an int:
+        *         - if the page exists, number of users watching who have visited the page recently
+        *         - if the page doesn't exist, number of users that have the page on their watchlist
+        *         - 0 means there are no visiting watchers or their number is below the minimumWatchers
+        *         option (if passed).
+        */
+       public function countVisitingWatchersMultiple(
+               array $targetsWithVisitThresholds,
+               $minimumWatchers = null
+       ) {
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+
+               $conds = $this->getVisitingWatchersCondition( $dbr, $targetsWithVisitThresholds );
+
+               $dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ];
+               if ( $minimumWatchers !== null ) {
+                       $dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$minimumWatchers;
+               }
+               $res = $dbr->select(
+                       'watchlist',
+                       [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
+                       $conds,
+                       __METHOD__,
+                       $dbOptions
+               );
+
+               $watcherCounts = [];
+               foreach ( $targetsWithVisitThresholds as list( $target ) ) {
+                       /* @var LinkTarget $target */
+                       $watcherCounts[$target->getNamespace()][$target->getDBkey()] = 0;
+               }
+
+               foreach ( $res as $row ) {
+                       $watcherCounts[$row->wl_namespace][$row->wl_title] = (int)$row->watchers;
+               }
+
+               return $watcherCounts;
+       }
+
+       /**
+        * Generates condition for the query used in a batch count visiting watchers.
+        *
+        * @param IDatabase $db
+        * @param array $targetsWithVisitThresholds array of pairs (LinkTarget, last visit threshold)
+        * @return string
+        */
+       private function getVisitingWatchersCondition(
+               IDatabase $db,
+               array $targetsWithVisitThresholds
+       ) {
+               $missingTargets = [];
+               $namespaceConds = [];
+               foreach ( $targetsWithVisitThresholds as list( $target, $threshold ) ) {
+                       if ( $threshold === null ) {
+                               $missingTargets[] = $target;
+                               continue;
+                       }
+                       /* @var LinkTarget $target */
+                       $namespaceConds[$target->getNamespace()][] = $db->makeList( [
+                               'wl_title = ' . $db->addQuotes( $target->getDBkey() ),
+                               $db->makeList( [
+                                       'wl_notificationtimestamp >= ' . $db->addQuotes( $db->timestamp( $threshold ) ),
+                                       'wl_notificationtimestamp IS NULL'
+                               ], LIST_OR )
+                       ], LIST_AND );
+               }
+
+               $conds = [];
+               foreach ( $namespaceConds as $namespace => $pageConds ) {
+                       $conds[] = $db->makeList( [
+                               'wl_namespace = ' . $namespace,
+                               '(' . $db->makeList( $pageConds, LIST_OR ) . ')'
+                       ], LIST_AND );
+               }
+
+               if ( $missingTargets ) {
+                       $lb = new LinkBatch( $missingTargets );
+                       $conds[] = $lb->constructSet( 'wl', $db );
+               }
+
+               return $db->makeList( $conds, LIST_OR );
+       }
+
+       /**
+        * Get an item (may be cached)
+        *
+        * @param User $user
+        * @param LinkTarget $target
+        *
+        * @return WatchedItem|false
+        */
+       public function getWatchedItem( User $user, LinkTarget $target ) {
+               if ( $user->isAnon() ) {
+                       return false;
+               }
+
+               $cached = $this->getCached( $user, $target );
+               if ( $cached ) {
+                       $this->stats->increment( 'WatchedItemStore.getWatchedItem.cached' );
+                       return $cached;
+               }
+               $this->stats->increment( 'WatchedItemStore.getWatchedItem.load' );
+               return $this->loadWatchedItem( $user, $target );
+       }
+
+       /**
+        * Loads an item from the db
+        *
+        * @param User $user
+        * @param LinkTarget $target
+        *
+        * @return WatchedItem|false
+        */
+       public function loadWatchedItem( User $user, LinkTarget $target ) {
+               // Only loggedin user can have a watchlist
+               if ( $user->isAnon() ) {
+                       return false;
+               }
+
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+               $row = $dbr->selectRow(
+                       'watchlist',
+                       'wl_notificationtimestamp',
+                       $this->dbCond( $user, $target ),
+                       __METHOD__
+               );
+
+               if ( !$row ) {
+                       return false;
+               }
+
+               $item = new WatchedItem(
+                       $user,
+                       $target,
+                       wfTimestampOrNull( TS_MW, $row->wl_notificationtimestamp )
+               );
+               $this->cache( $item );
+
+               return $item;
+       }
+
+       /**
+        * @param User $user
+        * @param array $options Allowed keys:
+        *        'forWrite' => bool defaults to false
+        *        'sort' => string optional sorting by namespace ID and title
+        *                     one of the self::SORT_* constants
+        *
+        * @return WatchedItem[]
+        */
+       public function getWatchedItemsForUser( User $user, array $options = [] ) {
+               $options += [ 'forWrite' => false ];
+
+               $dbOptions = [];
+               if ( array_key_exists( 'sort', $options ) ) {
+                       Assert::parameter(
+                               ( in_array( $options['sort'], [ self::SORT_ASC, self::SORT_DESC ] ) ),
+                               '$options[\'sort\']',
+                               'must be SORT_ASC or SORT_DESC'
+                       );
+                       $dbOptions['ORDER BY'] = [
+                               "wl_namespace {$options['sort']}",
+                               "wl_title {$options['sort']}"
+                       ];
+               }
+               $db = $this->getConnectionRef( $options['forWrite'] ? DB_MASTER : DB_REPLICA );
+
+               $res = $db->select(
+                       'watchlist',
+                       [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                       [ 'wl_user' => $user->getId() ],
+                       __METHOD__,
+                       $dbOptions
+               );
+
+               $watchedItems = [];
+               foreach ( $res as $row ) {
+                       // @todo: Should we add these to the process cache?
+                       $watchedItems[] = new WatchedItem(
+                               $user,
+                               new TitleValue( (int)$row->wl_namespace, $row->wl_title ),
+                               $row->wl_notificationtimestamp
+                       );
+               }
+
+               return $watchedItems;
+       }
+
+       /**
+        * Must be called separately for Subject & Talk namespaces
+        *
+        * @param User $user
+        * @param LinkTarget $target
+        *
+        * @return bool
+        */
+       public function isWatched( User $user, LinkTarget $target ) {
+               return (bool)$this->getWatchedItem( $user, $target );
+       }
+
+       /**
+        * @param User $user
+        * @param LinkTarget[] $targets
+        *
+        * @return array multi-dimensional like $return[$namespaceId][$titleString] = $timestamp,
+        *         where $timestamp is:
+        *         - string|null value of wl_notificationtimestamp,
+        *         - false if $target is not watched by $user.
+        */
+       public function getNotificationTimestampsBatch( User $user, array $targets ) {
+               $timestamps = [];
+               foreach ( $targets as $target ) {
+                       $timestamps[$target->getNamespace()][$target->getDBkey()] = false;
+               }
+
+               if ( $user->isAnon() ) {
+                       return $timestamps;
+               }
+
+               $targetsToLoad = [];
+               foreach ( $targets as $target ) {
+                       $cachedItem = $this->getCached( $user, $target );
+                       if ( $cachedItem ) {
+                               $timestamps[$target->getNamespace()][$target->getDBkey()] =
+                                       $cachedItem->getNotificationTimestamp();
+                       } else {
+                               $targetsToLoad[] = $target;
+                       }
+               }
+
+               if ( !$targetsToLoad ) {
+                       return $timestamps;
+               }
+
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+
+               $lb = new LinkBatch( $targetsToLoad );
+               $res = $dbr->select(
+                       'watchlist',
+                       [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                       [
+                               $lb->constructSet( 'wl', $dbr ),
+                               'wl_user' => $user->getId(),
+                       ],
+                       __METHOD__
+               );
+
+               foreach ( $res as $row ) {
+                       $timestamps[$row->wl_namespace][$row->wl_title] =
+                               wfTimestampOrNull( TS_MW, $row->wl_notificationtimestamp );
+               }
+
+               return $timestamps;
+       }
+
+       /**
+        * Must be called separately for Subject & Talk namespaces
+        *
+        * @param User $user
+        * @param LinkTarget $target
+        */
+       public function addWatch( User $user, LinkTarget $target ) {
+               $this->addWatchBatchForUser( $user, [ $target ] );
+       }
+
+       /**
+        * @param User $user
+        * @param LinkTarget[] $targets
+        *
+        * @return bool success
+        */
+       public function addWatchBatchForUser( User $user, array $targets ) {
+               if ( $this->readOnlyMode->isReadOnly() ) {
+                       return false;
+               }
+               // Only loggedin user can have a watchlist
+               if ( $user->isAnon() ) {
+                       return false;
+               }
+
+               if ( !$targets ) {
+                       return true;
+               }
+
+               $rows = [];
+               $items = [];
+               foreach ( $targets as $target ) {
+                       $rows[] = [
+                               'wl_user' => $user->getId(),
+                               'wl_namespace' => $target->getNamespace(),
+                               'wl_title' => $target->getDBkey(),
+                               'wl_notificationtimestamp' => null,
+                       ];
+                       $items[] = new WatchedItem(
+                               $user,
+                               $target,
+                               null
+                       );
+                       $this->uncache( $user, $target );
+               }
+
+               $dbw = $this->getConnectionRef( DB_MASTER );
+               foreach ( array_chunk( $rows, 100 ) as $toInsert ) {
+                       // Use INSERT IGNORE to avoid overwriting the notification timestamp
+                       // if there's already an entry for this page
+                       $dbw->insert( 'watchlist', $toInsert, __METHOD__, 'IGNORE' );
+               }
+               // Update process cache to ensure skin doesn't claim that the current
+               // page is unwatched in the response of action=watch itself (T28292).
+               // This would otherwise be re-queried from a slave by isWatched().
+               foreach ( $items as $item ) {
+                       $this->cache( $item );
+               }
+
+               return true;
+       }
+
+       /**
+        * Removes the an entry for the User watching the LinkTarget
+        * Must be called separately for Subject & Talk namespaces
+        *
+        * @param User $user
+        * @param LinkTarget $target
+        *
+        * @return bool success
+        * @throws DBUnexpectedError
+        * @throws MWException
+        */
+       public function removeWatch( User $user, LinkTarget $target ) {
+               // Only logged in user can have a watchlist
+               if ( $this->readOnlyMode->isReadOnly() || $user->isAnon() ) {
+                       return false;
+               }
+
+               $this->uncache( $user, $target );
+
+               $dbw = $this->getConnectionRef( DB_MASTER );
+               $dbw->delete( 'watchlist',
+                       [
+                               'wl_user' => $user->getId(),
+                               'wl_namespace' => $target->getNamespace(),
+                               'wl_title' => $target->getDBkey(),
+                       ], __METHOD__
+               );
+               $success = (bool)$dbw->affectedRows();
+
+               return $success;
+       }
+
+       /**
+        * @param User $user The user to set the timestamp for
+        * @param string|null $timestamp Set the update timestamp to this value
+        * @param LinkTarget[] $targets List of targets to update. Default to all targets
+        *
+        * @return bool success
+        */
+       public function setNotificationTimestampsForUser( User $user, $timestamp, array $targets = [] ) {
+               // Only loggedin user can have a watchlist
+               if ( $user->isAnon() ) {
+                       return false;
+               }
+
+               $dbw = $this->getConnectionRef( DB_MASTER );
+
+               $conds = [ 'wl_user' => $user->getId() ];
+               if ( $targets ) {
+                       $batch = new LinkBatch( $targets );
+                       $conds[] = $batch->constructSet( 'wl', $dbw );
+               }
+
+               if ( $timestamp !== null ) {
+                       $timestamp = $dbw->timestamp( $timestamp );
+               }
+
+               $success = $dbw->update(
+                       'watchlist',
+                       [ 'wl_notificationtimestamp' => $timestamp ],
+                       $conds,
+                       __METHOD__
+               );
+
+               $this->uncacheUser( $user );
+
+               return $success;
+       }
+
+       /**
+        * @param User $editor The editor that triggered the update. Their notification
+        *  timestamp will not be updated(they have already seen it)
+        * @param LinkTarget $target The target to update timestamps for
+        * @param string $timestamp Set the update timestamp to this value
+        *
+        * @return int[] Array of user IDs the timestamp has been updated for
+        */
+       public function updateNotificationTimestamp( User $editor, LinkTarget $target, $timestamp ) {
+               $dbw = $this->getConnectionRef( DB_MASTER );
+               $uids = $dbw->selectFieldValues(
+                       'watchlist',
+                       'wl_user',
+                       [
+                               'wl_user != ' . intval( $editor->getId() ),
+                               'wl_namespace' => $target->getNamespace(),
+                               'wl_title' => $target->getDBkey(),
+                               'wl_notificationtimestamp IS NULL',
+                       ],
+                       __METHOD__
+               );
+
+               $watchers = array_map( 'intval', $uids );
+               if ( $watchers ) {
+                       // Update wl_notificationtimestamp for all watching users except the editor
+                       $fname = __METHOD__;
+                       DeferredUpdates::addCallableUpdate(
+                               function () use ( $timestamp, $watchers, $target, $fname ) {
+                                       global $wgUpdateRowsPerQuery;
+
+                                       $dbw = $this->getConnectionRef( DB_MASTER );
+                                       $factory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                                       $ticket = $factory->getEmptyTransactionTicket( __METHOD__ );
+
+                                       $watchersChunks = array_chunk( $watchers, $wgUpdateRowsPerQuery );
+                                       foreach ( $watchersChunks as $watchersChunk ) {
+                                               $dbw->update( 'watchlist',
+                                                       [ /* SET */
+                                                               'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
+                                                       ], [ /* WHERE - TODO Use wl_id T130067 */
+                                                               'wl_user' => $watchersChunk,
+                                                               'wl_namespace' => $target->getNamespace(),
+                                                               'wl_title' => $target->getDBkey(),
+                                                       ], $fname
+                                               );
+                                               if ( count( $watchersChunks ) > 1 ) {
+                                                       $factory->commitAndWaitForReplication(
+                                                               __METHOD__, $ticket, [ 'domain' => $dbw->getDomainID() ]
+                                                       );
+                                               }
+                                       }
+                                       $this->uncacheLinkTarget( $target );
+                               },
+                               DeferredUpdates::POSTSEND,
+                               $dbw
+                       );
+               }
+
+               return $watchers;
+       }
+
+       /**
+        * Reset the notification timestamp of this entry
+        *
+        * @param User $user
+        * @param Title $title
+        * @param string $force Whether to force the write query to be executed even if the
+        *    page is not watched or the notification timestamp is already NULL.
+        *    'force' in order to force
+        * @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed.
+        *
+        * @return bool success
+        */
+       public function resetNotificationTimestamp( User $user, Title $title, $force = '', $oldid = 0 ) {
+               // Only loggedin user can have a watchlist
+               if ( $this->readOnlyMode->isReadOnly() || $user->isAnon() ) {
+                       return false;
+               }
+
+               $item = null;
+               if ( $force != 'force' ) {
+                       $item = $this->loadWatchedItem( $user, $title );
+                       if ( !$item || $item->getNotificationTimestamp() === null ) {
+                               return false;
+                       }
+               }
+
+               // If the page is watched by the user (or may be watched), update the timestamp
+               $job = new ActivityUpdateJob(
+                       $title,
+                       [
+                               'type'      => 'updateWatchlistNotification',
+                               'userid'    => $user->getId(),
+                               'notifTime' => $this->getNotificationTimestamp( $user, $title, $item, $force, $oldid ),
+                               'curTime'   => time()
+                       ]
+               );
+
+               // Try to run this post-send
+               // Calls DeferredUpdates::addCallableUpdate in normal operation
+               call_user_func(
+                       $this->deferredUpdatesAddCallableUpdateCallback,
+                       function () use ( $job ) {
+                               $job->run();
+                       }
+               );
+
+               $this->uncache( $user, $title );
+
+               return true;
+       }
+
+       private function getNotificationTimestamp( User $user, Title $title, $item, $force, $oldid ) {
+               if ( !$oldid ) {
+                       // No oldid given, assuming latest revision; clear the timestamp.
+                       return null;
+               }
+
+               if ( !$title->getNextRevisionID( $oldid ) ) {
+                       // Oldid given and is the latest revision for this title; clear the timestamp.
+                       return null;
+               }
+
+               if ( $item === null ) {
+                       $item = $this->loadWatchedItem( $user, $title );
+               }
+
+               if ( !$item ) {
+                       // This can only happen if $force is enabled.
+                       return null;
+               }
+
+               // Oldid given and isn't the latest; update the timestamp.
+               // This will result in no further notification emails being sent!
+               // Calls Revision::getTimestampFromId in normal operation
+               $notificationTimestamp = call_user_func(
+                       $this->revisionGetTimestampFromIdCallback,
+                       $title,
+                       $oldid
+               );
+
+               // We need to go one second to the future because of various strict comparisons
+               // throughout the codebase
+               $ts = new MWTimestamp( $notificationTimestamp );
+               $ts->timestamp->add( new DateInterval( 'PT1S' ) );
+               $notificationTimestamp = $ts->getTimestamp( TS_MW );
+
+               if ( $notificationTimestamp < $item->getNotificationTimestamp() ) {
+                       if ( $force != 'force' ) {
+                               return false;
+                       } else {
+                               // This is a little silly…
+                               return $item->getNotificationTimestamp();
+                       }
+               }
+
+               return $notificationTimestamp;
+       }
+
+       /**
+        * @param User $user
+        * @param int $unreadLimit
+        *
+        * @return int|bool The number of unread notifications
+        *                  true if greater than or equal to $unreadLimit
+        */
+       public function countUnreadNotifications( User $user, $unreadLimit = null ) {
+               $queryOptions = [];
+               if ( $unreadLimit !== null ) {
+                       $unreadLimit = (int)$unreadLimit;
+                       $queryOptions['LIMIT'] = $unreadLimit;
+               }
+
+               $dbr = $this->getConnectionRef( DB_REPLICA );
+               $rowCount = $dbr->selectRowCount(
+                       'watchlist',
+                       '1',
+                       [
+                               'wl_user' => $user->getId(),
+                               'wl_notificationtimestamp IS NOT NULL',
+                       ],
+                       __METHOD__,
+                       $queryOptions
+               );
+
+               if ( !isset( $unreadLimit ) ) {
+                       return $rowCount;
+               }
+
+               if ( $rowCount >= $unreadLimit ) {
+                       return true;
+               }
+
+               return $rowCount;
+       }
+
+       /**
+        * Check if the given title already is watched by the user, and if so
+        * add a watch for the new title.
+        *
+        * To be used for page renames and such.
+        *
+        * @param LinkTarget $oldTarget
+        * @param LinkTarget $newTarget
+        */
+       public function duplicateAllAssociatedEntries( LinkTarget $oldTarget, LinkTarget $newTarget ) {
+               $oldTarget = Title::newFromLinkTarget( $oldTarget );
+               $newTarget = Title::newFromLinkTarget( $newTarget );
+
+               $this->duplicateEntry( $oldTarget->getSubjectPage(), $newTarget->getSubjectPage() );
+               $this->duplicateEntry( $oldTarget->getTalkPage(), $newTarget->getTalkPage() );
+       }
+
+       /**
+        * Check if the given title already is watched by the user, and if so
+        * add a watch for the new title.
+        *
+        * To be used for page renames and such.
+        * This must be called separately for Subject and Talk pages
+        *
+        * @param LinkTarget $oldTarget
+        * @param LinkTarget $newTarget
+        */
+       public function duplicateEntry( LinkTarget $oldTarget, LinkTarget $newTarget ) {
+               $dbw = $this->getConnectionRef( DB_MASTER );
+
+               $result = $dbw->select(
+                       'watchlist',
+                       [ 'wl_user', 'wl_notificationtimestamp' ],
+                       [
+                               'wl_namespace' => $oldTarget->getNamespace(),
+                               'wl_title' => $oldTarget->getDBkey(),
+                       ],
+                       __METHOD__,
+                       [ 'FOR UPDATE' ]
+               );
+
+               $newNamespace = $newTarget->getNamespace();
+               $newDBkey = $newTarget->getDBkey();
+
+               # Construct array to replace into the watchlist
+               $values = [];
+               foreach ( $result as $row ) {
+                       $values[] = [
+                               'wl_user' => $row->wl_user,
+                               'wl_namespace' => $newNamespace,
+                               'wl_title' => $newDBkey,
+                               'wl_notificationtimestamp' => $row->wl_notificationtimestamp,
+                       ];
+               }
+
+               if ( !empty( $values ) ) {
+                       # Perform replace
+                       # Note that multi-row replace is very efficient for MySQL but may be inefficient for
+                       # some other DBMSes, mostly due to poor simulation by us
+                       $dbw->replace(
+                               'watchlist',
+                               [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
+                               $values,
+                               __METHOD__
+                       );
+               }
+       }
+
+}
index e3bd03b..46ea545 100644 (file)
        "uploadstash-file-not-found-no-thumb": "Nun pudo llograse la miniatura.",
        "uploadstash-file-not-found-no-local-path": "Nun hai una ruta llocal pal elementu redimensionáu.",
        "uploadstash-file-not-found-no-object": "Nun pudo crease l'oxetu de ficheru llocal pa la miniatura.",
-       "uploadstash-file-not-found-no-remote-thumb": "Falló la descarga de la miniatura: $1\nurl = $2",
+       "uploadstash-file-not-found-no-remote-thumb": "Fallu al llograr la miniatura: $1\nurl = $2",
        "uploadstash-file-not-found-missing-content-type": "Falta la cabecera de triba de conteníu.",
        "uploadstash-file-not-found-not-exists": "Nun pudo alcontrase la ruta, o nun ye un ficheru.",
        "uploadstash-file-too-large": "Nun puede sirvise un ficheru mayor de $1 bytes.",
index d9fa9b0..9abf0be 100644 (file)
        "recentchanges-label-plusminus": "صفحه‌نین اؤلچوسو بایت میقداری ایله تعیین ائدیلیر",
        "recentchanges-legend-heading": "<strong>قیسالتمالار:</strong>",
        "recentchanges-legend-newpage": "{{int:recentchanges-label-newpage}} (بیرده [[Special:NewPages|یئنی صفحه‌لرین لیستینه]] باخین)",
+       "rcfilters-other-review-tools": "داها یوخلاما آلتلری",
+       "rcfilters-savedqueries-defaultlabel": "ذخیره اوْلونموش فیلترلر",
        "rcnotefrom": "آشاغی داکی دَییشیک لرده <strong>$3, $4</strong> (دن <strong>$1</strong> {{PLURAL:$5|چان گوستریلیب|چان گوستریلیب دیر}}).",
        "rclistfrom": "$3 $2 واختیندان باشلایاراق یئنی دییشیکلری گؤستر",
        "rcshowhideminor": "کیچیک دَییشیکلری $1",
index d8fd47c..a7aac85 100644 (file)
        "uploadstash-thumbnail": "прагляд мініятуры",
        "uploadstash-exception": "Не магу захаваць загрузку ў сховішчы ($1): «$2».",
        "uploadstash-bad-path": "Шлях не існуе.",
+       "uploadstash-bad-path-invalid": "Шлях не зьяўляецца слушным.",
+       "uploadstash-bad-path-unknown-type": "Невядомы тып «$1».",
+       "uploadstash-bad-path-unrecognized-thumb-name": "Невядомая назва мініятуры.",
+       "uploadstash-bad-path-no-handler": "Ня знойдзены апрацоўнік для mime-тыпу $1 файлу $2.",
        "invalid-chunk-offset": "Няслушнае зрушэньне фрагмэнту",
        "img-auth-accessdenied": "Доступ забаронены",
        "img-auth-nopathinfo": "Адсутнічае PATH_INFO.\nВаш сэрвэр не ўстаноўлены на пропуск гэтай інфармацыі.\nМагчма, ён працуе праз CGI і не падтрымлівае img_auth.\nГлядзіце https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization.",
index 99f31db..ffd8161 100644 (file)
        "timezoneregion-indian": "Oceà Índic",
        "timezoneregion-pacific": "Oceà Pacífic",
        "allowemail": "Permet que altres usuaris m'enviïn missatges per correu electrònic",
+       "email-blacklist-label": "Prohibeix a aquests usuaris que m'enviïn correus electrònics:",
        "prefs-searchoptions": "Cerca",
        "prefs-namespaces": "Espais de noms",
        "default": "per defecte",
        "listfiles_size": "Mida (octets)",
        "listfiles_description": "Descripció",
        "listfiles_count": "Versions",
-       "listfiles-show-all": "Inclou versions antigues de les imatges",
+       "listfiles-show-all": "Inclou versions antigues dels fitxers",
        "listfiles-latestversion": "Versió actual",
        "listfiles-latestversion-yes": "Sí",
        "listfiles-latestversion-no": "No",
        "pageswithprop-text": "Aquesta pàgina llista les pàgines que utilitzen una propietat de pàgina en particular.",
        "pageswithprop-prop": "Nom de la propietat:",
        "pageswithprop-reverse": "Ordena en invers",
+       "pageswithprop-sortbyvalue": "Ordena pel valor de la propietat",
        "pageswithprop-submit": "Vés",
        "pageswithprop-prophidden-long": "valor de propietat text llarg ocult ($1)",
        "pageswithprop-prophidden-binary": "valor de propietat binària oculta ($1)",
        "enotif_lastdiff": "Per a visualitzar aquest canvi, consulteu $1",
        "enotif_anon_editor": "usuari anònim $1",
        "enotif_body": "Benvolgut/uda $WATCHINGUSERNAME,\n\n$PAGEINTRO $NEWPAGE\n\nResum de l'editor: $PAGESUMMARY $PAGEMINOREDIT\n\nContacteu amb l'editor:\ncorreu: $PAGEEDITOR_EMAIL\nwiki: $PAGEEDITOR_WIKI\n\nNo rebreu més notificacions en cas de més activitat a menys que visiteu aquesta pàgina havent iniciat sessió.\nTambé podeu canviar el mode de notificació de les pàgines que vigileu en la vostra llista de seguiment.\n\nEl servei de notificacions del projecte {{SITENAME}}\n\n--\nPer a canviar les opcions de notificació per correu electrònic aneu a\n{{canonicalurl:{{#special:Preferences}}}}\n\nPer a canviar les opcions de la vostra llista de seguiment aneu a\n{{canonicalurl:{{#special:EditWatchlist}}}}\n\nPer eliminar la pàgina de la vostra llista de seguiment aneu a\n$UNWATCHURL\n\nSuggeriments i ajuda:\n$HELPPAGE",
+       "enotif_minoredit": "Aquesta és una modificació menor",
        "created": "creada",
        "changed": "modificada",
        "deletepage": "Elimina la pàgina",
        "undelete-search-title": "Cerca de pàgines esborrades",
        "undelete-search-box": "Cerca pàgines esborrades",
        "undelete-search-prefix": "Mostra pàgines que comencin:",
+       "undelete-search-full": "Mostra títols de pàgines que continguin:",
        "undelete-search-submit": "Cerca",
        "undelete-no-results": "Amb aquest criteri de cerca, no s'ha trobat cap pàgina a l'arxiu de supressions",
        "undelete-filename-mismatch": "No es pot revertir l'eliminació de la revisió de fitxer amb marca horària $1: no coincideix el nom de fitxer",
        "compare-title-not-exists": "El títol que heu especificat no existeix.",
        "compare-revision-not-exists": "La revisió que heu especificat no existeix.",
        "diff-form": "Diferències",
+       "permanentlink-revid": "ID de la revisó",
+       "permanentlink-submit": "Vés a la revisió",
        "dberr-problems": "Ho sentim. Aquest lloc web està experimentant dificultats tècniques.",
        "dberr-again": "Intenteu esperar uns minuts i tornar a carregar.",
        "dberr-info": "(No es pot accedir a la base de dades: $1)",
index cddd35e..8b9746e 100644 (file)
        "rcfilters-savedqueries-apply-and-setdefault-label": "Vytvořit výchozí filtr",
        "rcfilters-savedqueries-cancel-label": "Zrušit",
        "rcfilters-savedqueries-add-new-title": "Uložit současné nastavení filtrů",
+       "rcfilters-savedqueries-already-saved": "Tyto filtry jsou již uloženy.",
        "rcfilters-restore-default-filters": "Obnovit výchozí filtry",
        "rcfilters-clear-all-filters": "Zrušit všechny filtry",
        "rcfilters-show-new-changes": "Zobrazit nejnovější změny",
        "uploadstash-refresh": "Aktualizovat seznam souborů",
        "uploadstash-thumbnail": "zobrazit náhled",
        "uploadstash-exception": "Načtený soubor se nepodařilo uložit do skrýše ($1): „$2“.",
+       "uploadstash-bad-path": "Cesta neexistuje.",
+       "uploadstash-bad-path-invalid": "Cesta není platná.",
+       "uploadstash-bad-path-unknown-type": "Neznámý typ „$1“.",
+       "uploadstash-file-not-found-no-thumb": "Nepodařilo se získat náhled.",
+       "uploadstash-file-not-found-no-remote-thumb": "Načtení náhledu se nepodařilo: $1\nURL = $2",
+       "uploadstash-file-too-large": "Nelze poskytnout soubor větší než $1 bajtů.",
+       "uploadstash-not-logged-in": "Není přihlášen žádný uživatel, soubory musí patřit uživatelům.",
+       "uploadstash-wrong-owner": "Tento soubor ($1) nepatří aktuálnímu uživateli.",
+       "uploadstash-no-such-key": "Uvedený klíč ($1) neexistuje, nelze odebrat.",
+       "uploadstash-zero-length": "Soubor má nulovou délku.",
        "invalid-chunk-offset": "Neplatný posun bloku",
        "img-auth-accessdenied": "Přístup odepřen",
        "img-auth-nopathinfo": "Chybí PATH_INFO.\nVáš server není nastaven tak, aby tuto informaci poskytoval.\nMožná funguje pomocí CGI a img_auth na něm nemůže fungovat.\nVizte https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization.",
index 8275d2c..227d2bb 100644 (file)
        "tog-numberheadings": "Überschriften automatisch nummerieren",
        "tog-showtoolbar": "Bearbeiten-Werkzeugleiste anzeigen",
        "tog-editondblclick": "Seiten mit Doppelklick bearbeiten",
-       "tog-editsectiononrightclick": "Einzelne Abschnitte per Rechtsklick bearbeiten",
+       "tog-editsectiononrightclick": "Einzelne Abschnitte per Rechtsklick auf die Überschrift bearbeiten",
        "tog-watchcreations": "Selbst erstellte Seiten und hochgeladene Dateien automatisch beobachten",
        "tog-watchdefault": "Selbst geänderte Seiten und Dateien automatisch beobachten",
        "tog-watchmoves": "Selbst verschobene Seiten und Dateien automatisch beobachten",
index 5386927..dc5d97d 100644 (file)
        "magiclink-tracking-pmid-desc": "This page uses PMID magic links. See [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links mediawiki.org] on how to migrate.",
        "magiclink-tracking-isbn": "Pages using ISBN magic links",
        "magiclink-tracking-isbn-desc": "This page uses ISBN magic links. See [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Magic_links mediawiki.org] on how to migrate.",
-       "rfcurl": "//tools.ietf.org/html/rfc$1",
+       "rfcurl": "https://tools.ietf.org/html/rfc$1",
        "pubmedurl": "//www.ncbi.nlm.nih.gov/pubmed/$1?dopt=Abstract",
        "specialloguserlabel": "Performer:",
        "speciallogtitlelabel": "Target (title or {{ns:user}}:username for user):",
index ce275c8..d275c7a 100644 (file)
        "readonly": "Andmebaas lukustatud",
        "enterlockreason": "Sisesta lukustamise põhjus ning juurdepääsu taastamise ligikaudne aeg",
        "readonlytext": "Andmebaas on praegu lukustatud. Uusi sissekandeid ja muid muudatusi ei saa teha. Tõenäoliselt toimub andmebaasi plaanipärane hooldus, mille järel tavaline olukord taastub.\nSüsteemiadministraator, kes andmebaasi lukustas, andis järgmise selgituse: $1",
-       "missing-article": "Andmebaas ei leidnud küsitud lehekülje \"$1\" $2 teksti.\n\nPõhjuseks võib olla võrdlus- või ajaloolink kustutatud leheküljele.\n\nKui tegemist ei ole nimetatud olukorraga, võib tegu olla ka süsteemi veaga.\nSellisel juhul tuleks teavitada [[Special:ListUsers/sysop|administraatorit]], edastades talle ka käesoleva lehe internetiaadressi.",
+       "missing-article": "Andmebaasist ei leidnud päritud lehekülje \"$1\" $2 teksti.\n\nPõhjuseks võib olla võrdlus- või ajaloolink kustutatud leheküljele.\n\nKui asi ei ole selles, võib tegu olla süsteemi veaga.\nPalun teata sellest [[Special:ListUsers/sysop|administraatorile]], edastades ka lehekülje internetiaadressi.",
        "missingarticle-rev": "(redaktsioon: $1)",
        "missingarticle-diff": "(redaktsioonid: $1, $2)",
        "readonly_lag": "Andmebaas on automaatselt lukustatud, seniks kuni sekundaarsed andmebaasiserverid on primaarserveriga samal järjel.",
        "password-login-forbidden": "Selle kasutajanime ja parooli kasutamine on keelatud.",
        "mailmypassword": "Lähtesta parool",
        "passwordremindertitle": "{{SITENAME}} – ajutine parool",
-       "passwordremindertext": "Keegi IP-aadressiga $1, tõenäoliselt sa ise, palus, et talle saadetaks {{GRAMMAR:elative|{{SITENAME}}}} uus parool ($4). Kasutaja \"$2\" ajutiseks paroolis seati \"$3\". Kui soovid tõepoolest uut parooli, pead sisse logima ja uue parooli valima. Ajutine parool aegub {{PLURAL:$5|ühe päeva|$5 päeva}} pärast.\n\nKui uut parooli palus keegi teine või sulle meenus vana parool ja sa ei soovi seda enam muuta, võid käesolevat teadet eirata ning jätkata endise parooli kasutamist.",
+       "passwordremindertext": "Keegi IP-aadressiga $1, tõenäoliselt sa ise, palus, et talle\nsaadetaks {{GRAMMAR:elative|{{SITENAME}}}} uus parool ($4).\nKasutaja \"$2\" ajutiseks paroolis seati \"$3\". Kui soovid tõepoolest\nuut parooli, pead sisse logima ja uue parooli valima.\nAjutine parool aegub {{PLURAL:$5|ühe|$5}} päeva pärast.\n\nKui uut parooli palus keegi teine või sulle meenus vana parool\nja sa ei soovi seda enam muuta, võid seda teadet eirata ning\njätkata senise parooli kasutamist.",
        "noemail": "Kasutaja $1 e-posti aadressi meil kahjuks pole.",
        "noemailcreate": "Pead sisestama korrektse e-posti aadressi",
        "passwordsent": "Uus parool on saadetud kasutaja $1 registreeritud e-postiaadressil.\nPärast parooli saamist logige palun sisse.",
        "accountcreated": "Konto loodud",
        "accountcreatedtext": "Kasutaja [[{{ns:User}}:$1|$1]] ([[{{ns:User talk}}:$1|talk]]) konto on loodud.",
        "createaccount-title": "{{GRAMMAR:illative|{{SITENAME}}}} konto loomine",
-       "createaccount-text": "Keegi on loonud {{GRAMMAR:illative|{{SITENAME}}}} ($4) sinu e-posti aadressile vastava kasutajatunnuse \"$2\". Parooliks seati \"$3\". Logi sisse ja muuda oma parool.\n\nKui kasutajakonto loomine on eksitus, võid käesolevat sõnumit lihtsalt eirata.",
+       "createaccount-text": "Keegi on loonud {{GRAMMAR:illative|{{SITENAME}}}} ($4) sinu e-posti aadressile vastava kasutajatunnuse \"$2\". Parooliks seati \"$3\". Peaksid sisse logima ja parooli muutma.\n\nKui kasutajakonto loomine oli eksitus, võid seda sõnumit lihtsalt eirata.",
        "login-throttled": "Oled lühikese aja jooksul proovinud liiga palju kordi sisse logida.\nPalun oota $1, enne kui uuesti proovid.",
        "login-abort-generic": "Sisselogimine ebaõnnestus – Katkestatud",
        "login-migrated-generic": "Sinu konto on migreeritud ja sinu kasutajanime pole enam selles vikis.",
        "anonpreviewwarning": "''Sa pole sisse logitud. Selle lehe redigeerimislogisse salvestatakse su IP-aadress.''",
        "missingsummary": "'''Meeldetuletus:''' Sa ei ole lisanud muudatuse resümeed.\nKui vajutad uuesti salvestamise nupule, salvestatakse muudatus ilma resümeeta.",
        "selfredirect": "<strong>Hoiatus:</strong> Suunad selle lehekülje iseeneda juurde.\nVõimalik, et oled määranud ümbersuunamise jaoks vale sihtleheküljeks või redigeerid vale lehekülge.\nÜmbersuunamine luuakse sellest hoolimata, kui klõpsad uuesti \"$1\".",
-       "missingcommenttext": "Palun sisesta siit allapoole kommentaar.",
+       "missingcommenttext": "Palun sisesta kommentaar.",
        "missingcommentheader": "<strong>Meeldetuletus:</strong> Sa pole kirjutanud kommentaarile teemat.\nKui klõpsad uuesti \"$1\", salvestatakse su kommentaar ilma teemata.",
        "summary-preview": "Resümee eelvaade:",
        "subject-preview": "Resümee eelvaade:",
        "newarticle": "(Uus)",
        "newarticletext": "Lehekülge, kuhu link sind suunas, pole veel.\nEt lehekülg luua, alusta allolevas kastis kirjutamist (lisateave [$1 juhendist]).\nKui sattusid siia kogemata, klõpsa brauseri ''tagasi''-nupule.",
        "anontalkpagetext": "----''See on anonüümse kasutaja arutelulehekülg. See kasutaja pole kontot loonud või ei kasuta seda. Sellepärast tuleb meil kasutaja tuvastamiseks kasutada tema IP-aadressi. Sellist IP-aadressi võib kasutada mitu kasutajat. Kui oled osutatud IP-aadressi kasutaja ning leiad, et siinsed kommentaarid ei puutu kuidagi sinusse, [[Special:CreateAccount|loo palun kasutajakonto]] või [[Special:UserLogin|logi sisse]], et sind edaspidi teiste anonüümsete kasutajatega segi ei aetaks.''",
-       "noarticletext": "Käesoleval leheküljel hetkel teksti ei ole.\nVõid [[Special:Search/{{PAGENAME}}|otsida pealkirjaks olevat fraasi]] teistelt lehtedelt,\n<span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} uurida asjassepuutuvaid logisid] või [{{fullurl:{{FULLPAGENAME}}|action=edit}} puuduva lehekülje ise luua]</span>.",
+       "noarticletext": "Siin leheküljel puudub praegu tekst.\nSaad [[Special:Search/{{PAGENAME}}|otsida pealkirjateksti]] teistelt lehekülgedelt,\n<span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} uurida asjassepuutuvaid logisid]\nvõi [{{fullurl:{{FULLPAGENAME}}|action=edit}} puuduva lehekülje luua]</span>.",
        "noarticletext-nopermission": "Sellel leheküljel pole praegu teksti.\nSaad [[Special:Search/{{PAGENAME}}|otsida selle lehekülje pealkirja]] teistelt lehekülgedelt või <span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} otsida seonduvatest logidest]</span>, aga sul pole õigust seda lehekülge alustada.",
        "missing-revision": "Lehekülje \"{{FULLPAGENAME}}\" redaktsiooni $1 pole.\n\nHarilikult tähendab see seda, et sind siia juhatanud link on vananenud ja siin asunud lehekülg on kustutatud.\nÜksikasjad leiad [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} kustutamislogist].",
        "userpage-userdoesnotexist": "Kasutajakontot \"<nowiki>$1</nowiki>\" pole olemas.\nPalun mõtle järele, kas soovid seda lehte luua või muuta.",
        "recentchanges-legend": "Viimaste muudatuste seaded",
        "recentchanges-summary": "Jälgi sellel leheküljel viimaseid muudatusi.",
        "recentchanges-noresult": "Selles ajavahemikus pole tehtud neile kriteeriumitele vastavaid muudatusi.",
+       "recentchanges-timeout": "See otsing aegus. Võid proovida teisi otsiparameetreid.",
+       "recentchanges-network": "Tehnilise tõrke tõttu ei õnnestunud tulemusi laadida. Palun proovi lehekülge värskendada.",
        "recentchanges-feed-description": "Jälgi vikisse tehtud viimaseid muudatusi.",
        "recentchanges-label-newpage": "Uus lehekülg",
        "recentchanges-label-minor": "Pisiparandus",
        "rcfilters-days-show-hours": "$1 {{PLURAL:$1|tund|tundi}}",
        "rcfilters-highlighted-filters-list": "Esile tõstetud: $1",
        "rcfilters-quickfilters": "Salvestatud filtrid",
-       "rcfilters-quickfilters-placeholder-title": "Linke pole veel salvestatud",
+       "rcfilters-quickfilters-placeholder-title": "Filtreid pole veel salvestatud",
        "rcfilters-quickfilters-placeholder-description": "Et filtri sätted salvestada ja et neid hiljem uuesti kasutada, klõpsa alloleva aktiivsete filtrite loendi juures järjehoidjaikooni.",
        "rcfilters-savedqueries-defaultlabel": "Salvestatud filtrid",
        "rcfilters-savedqueries-rename": "Nimeta ümber",
        "rcfilters-savedqueries-apply-and-setdefault-label": "Koosta vaikefilter",
        "rcfilters-savedqueries-cancel-label": "Loobu",
        "rcfilters-savedqueries-add-new-title": "Salvesta filtri praegused sätted",
+       "rcfilters-savedqueries-already-saved": "Need filtrid on juba salvestatud",
        "rcfilters-restore-default-filters": "Taasta vaikefiltrid",
        "rcfilters-clear-all-filters": "Eemalda kõik filtrid",
        "rcfilters-show-new-changes": "Vaata uusimaid muudatusi",
-       "rcfilters-search-placeholder": "Filtri viimaseid muudatusi (sirvi või alusta tippimist)",
+       "rcfilters-search-placeholder": "Filtri muudatusi (kasuta menüüd või otsi filtri nime)",
        "rcfilters-invalid-filter": "Vigane filter",
        "rcfilters-empty-filter": "Aktiivsed filtrid puuduvad. Näidatakse kogu kaastööd.",
        "rcfilters-filterlist-title": "Filtrid",
        "rcfilters-tag-prefix-namespace-inverted": "<strong>:mitte</strong> $1",
        "rcfilters-exclude-button-off": "Jäta valitud välja",
        "rcfilters-exclude-button-on": "Valitud välja jäetud",
-       "rcfilters-view-advanced-filters-label": "Täpsemad filtrid",
        "rcfilters-view-tags": "Märgistatud muudatused",
        "rcfilters-view-namespaces-tooltip": "Filtri tulemusi nimeruumide lõikes",
        "rcfilters-view-tags-tooltip": "Filtri tulemusi muudatusmärgiste lõikes",
        "rcfilters-view-return-to-default-tooltip": "Naase filtri peamenüüsse",
+       "rcfilters-view-tags-help-icon-tooltip": "Uuri veel märgistatud muudatuste kohta",
        "rcfilters-liveupdates-button": "Uuendused reaalajas",
        "rcfilters-liveupdates-button-title-on": "Lülita reaalajas uuendamine välja",
        "rcfilters-liveupdates-button-title-off": "Näita uusi muudatusi kohe nende tegemise järel",
        "uploaded-script-svg": "Üleslaaditud SVG-failist leiti skriptitav element \"$1\".",
        "uploaded-hostile-svg": "Üleslaaditud SVG-faili laadielemendist leiti ebaturvaline CSS.",
        "uploaded-event-handler-on-svg": "Sündmuse halduse atribuutide <code>$1=\"$2\"</code> seadmine pole SVG-failis lubatud.",
-       "uploaded-href-attribute-svg": "SVG-failis on lubatud href-atribuudiga viidata ainult sihtkohta skeemiga http:// või https://. Leiti <code>&lt;$1 $2=\"$3\"&gt;</code>.",
+       "uploaded-href-attribute-svg": "Element <a> saab href-atribuudi väärtuses linkida ainult sihtobjektile data: (manusfail), http:// või https:// või fragmendile (#, sama-dokument).  Teistes elementides, nagu <image>, on lubatud ainult data: ja fragment. Proovi SVG-faili eksportimisel faile manustada. Leiti <code>&lt;$1 $2=\"$3\"&gt;</code>.",
        "uploaded-href-unsafe-target-svg": "Üleslaaditud SVG-failist leiti href, mis viitab ebaturvalistele andmetele: URI sihtkoht <code>&lt;$1 $2=\"$3\"&gt;</code>.",
        "uploaded-animate-svg": "Üleslaaditud SVG-failist leiti silt \"animate\", mis võib href-i muuta, kasutades from-atribuuti <code>&lt;$1 $2=\"$3\"&gt;</code>.",
        "uploaded-setting-event-handler-svg": "Sündmuse halduse atribuutide seadmine on keelatud, üleslaaditud SVG-failist leiti <code>&lt;$1 $2=\"$3\"&gt;</code>.",
        "uploadstash-refresh": "Värskenda faililoendit",
        "uploadstash-thumbnail": "vaata pisipilti",
        "uploadstash-exception": "Üleslaaditavat faili ei õnnestunud peithoidlas talletada ($1): \"$2\".",
+       "uploadstash-bad-path": "Teed pole olemas.",
+       "uploadstash-bad-path-invalid": "Tee pole sobiv.",
+       "uploadstash-bad-path-unknown-type": "Tundmatu tüüp \"$1\".",
+       "uploadstash-bad-path-unrecognized-thumb-name": "Tundmatu pisipildi nimi.",
+       "uploadstash-bad-path-no-handler": "Faili $2 MIME tüübile $1 ei leitud töötlejat.",
+       "uploadstash-bad-path-bad-format": "Võti \"$1\" pole sobivas vormingus.",
+       "uploadstash-file-not-found": "Peithoidlas ei leidu võtit \"$1\".",
+       "uploadstash-file-not-found-no-thumb": "Pisipilti ei õnnestu hankida.",
+       "uploadstash-file-not-found-no-local-path": "Mastaabitud elemendi kohalikku teed ei leitud.",
+       "uploadstash-file-not-found-no-object": "Pisipildi kohalikku failiobjekti ei õnnestunud luua.",
+       "uploadstash-file-not-found-no-remote-thumb": "Pisipilti ei õnnestunud hankida: $1\nURL = $2",
+       "uploadstash-file-not-found-missing-content-type": "Sisutüübi päis puudub.",
+       "uploadstash-file-not-found-not-exists": "Ei õnnestunud leida teed või faili ennast.",
+       "uploadstash-file-too-large": "$1 baidist suuremat faili ei saa töödelda.",
+       "uploadstash-not-logged-in": "Ükski kasutaja pole sisse logitud, fail peab kuuluma kasutajatele.",
+       "uploadstash-wrong-owner": "See fail ($1) ei kuulu praegusele kasutajale.",
+       "uploadstash-no-such-key": "Puudub selline võti ($1), ei saa eemaldada.",
+       "uploadstash-no-extension": "Faililaiend puudub.",
+       "uploadstash-zero-length": "Faili suurus on tühiväärtusega.",
        "invalid-chunk-offset": "Tüki vigane nihe",
        "img-auth-accessdenied": "Juurdepääs keelatud",
        "img-auth-nopathinfo": "PATH_INFO puudub.\nSinu server pole seadistatud seda teavet edastama.\nSee võib olla CGI-põhine ja ei toeta img_auth-i.\nVaata lehekülge https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization.",
        "apihelp": "API abi",
        "apihelp-no-such-module": "Moodulit \"$1\" ei leitud.",
        "apisandbox": "API liivakast",
+       "apisandbox-jsonly": "API liivakasti kasutamine nõuab JavaScripti.",
        "apisandbox-api-disabled": "API on selles võrgukohas keelatud.",
        "apisandbox-intro": "Kasuta seda lehekülge <strong>MediaWiki API</strong> katsetamiseks.\nÜksikasjad API kasutamise kohta leiad [[mw:API:Main page|API dokumentatsioonist]]. Näide: [https://www.mediawiki.org/wiki/API#A_simple_example esilehe sisu hankimine]. Vali toiming, et näha veel näiteid.\n\nPane tähele, et kuigi siin on liivakast, võivad siin leheküljel tehtud toimingud vikit muuta.",
+       "apisandbox-fullscreen": "Laienda paneel",
+       "apisandbox-fullscreen-tooltip": "Laienda liivakastipaneel brauseriakna suuruseks",
+       "apisandbox-unfullscreen": "Näita lehekülge",
+       "apisandbox-unfullscreen-tooltip": "Vähenda liivakastipaneeli, nii et MediaWiki navigeerimislingid on nähtaval",
        "apisandbox-submit": "Tee päring",
        "apisandbox-reset": "Puhasta",
+       "apisandbox-retry": "Proovi uuesti",
+       "apisandbox-loading": "API mooduli \"$1\" teabe laadimine...",
+       "apisandbox-load-error": "API mooduli \"$1\" teabe laadimisel esines tõrge: $2",
+       "apisandbox-no-parameters": "Sellel API moodulil pole parameetreid.",
+       "apisandbox-helpurls": "Abilingid",
        "apisandbox-examples": "Näited",
+       "apisandbox-dynamic-parameters": "Lisaparameetrid",
+       "apisandbox-dynamic-parameters-add-label": "Lisa parameeter:",
+       "apisandbox-dynamic-parameters-add-placeholder": "Parameetri nimi",
+       "apisandbox-dynamic-error-exists": "Parameeter nimega \"$1\" on juba olemas.",
+       "apisandbox-deprecated-parameters": "Vananenud parameetrid",
        "apisandbox-results": "Tulemused",
        "apisandbox-request-url-label": "Päringu URL:",
        "apisandbox-request-time": "Päringuaeg: {{PLURAL:$1|$1 ms}}",
        "protect-expiring": "aegumistähtaeg $1 (UTC)",
        "protect-expiring-local": "aegumistähtaeg $1",
        "protect-expiry-indefinite": "tähtajatu",
-       "protect-cascade": "Kaitse lehekülgi, mis on lülitatud käesoleva lehekülje koosseisu (kaskaadkaitse)",
+       "protect-cascade": "Kaitse lehekülgi, mis on siinse lehekülje koosseisus (kaskaadkaitse)",
        "protect-cantedit": "Sa ei saa lehekülje kaitsetaset muuta, sest sul puudub lehekülje redigeerimise õigus.",
        "protect-othertime": "Muu aeg:",
        "protect-othertime-op": "muu aeg",
        "ipb_blocked_as_range": "Tõrge: IP-aadressi $1 pole eraldi blokeeritud ja blokeeringut ei saa eemaldada.\nSee kuulub aga blokeeritud IP-vahemikku $2, mille blokeeringut saab eemaldada.",
        "ip_range_invalid": "Vigane IP-vahemik.",
        "ip_range_toolarge": "Suuremad aadressiblokid kui /$1 pole lubatud.",
+       "ip_range_exceeded": "See IP-aadressivahemik ületab maksimumvahemikku. Lubatud vahemik: /$1.",
+       "ip_range_toolow": "IP-aadressivahemikud on sisuliselt keelatud.",
        "proxyblocker": "Proksiblokeerija",
        "proxyblockreason": "Sinu IP-aadress on blokeeritud, sest see on avatud proksi. Palun võta ühendust oma internetiteenuse pakkujaga või tehnilise toega ja teata neile sellest probleemist.",
        "sorbsreason": "Sinu IP-aadress on {{GRAMMAR:genitive|{{SITENAME}}}} kasutatavas DNS-põhises mustas nimekirjas märgitud kui avatud proksi.",
index 4df5481..a0dc4c3 100644 (file)
@@ -61,7 +61,8 @@
                        "AzorAhai",
                        "Yoosef Pooranvary",
                        "DEXi",
-                       "Obzord"
+                       "Obzord",
+                       "Alp Er Tunqa"
                ]
        },
        "tog-underline": "خط کشیدن زیر پیوندها:",
        "rcfilters-savedqueries-apply-and-setdefault-label": "ایجاد پالایه پیش‌فرض",
        "rcfilters-savedqueries-cancel-label": "لغو",
        "rcfilters-savedqueries-add-new-title": "ذخیره تنظیمات کنونی پالایه",
+       "rcfilters-savedqueries-already-saved": "این پالایه‌ها اکنون ذخیره شده‌اند",
        "rcfilters-restore-default-filters": "بازگردانی پالایه‌های پیش‌فرض",
        "rcfilters-clear-all-filters": "پاک‌کردن تمام پالایه‌ها",
        "rcfilters-show-new-changes": "دیدن جدیدترین تغییرات",
        "uploadstash-refresh": "تازه کردن فهرست پرونده‌ها",
        "uploadstash-thumbnail": "نمایش بندانگشتی",
        "uploadstash-exception": "ناتوان از ذخیره کردن بارگذاری در نهانگاه ($1): ''$2''.",
+       "uploadstash-bad-path": "مسر وجود ندارد.",
+       "uploadstash-bad-path-invalid": "مسیر معتبر نیست.",
+       "uploadstash-bad-path-unknown-type": "گونهٔ ناشناختهٔ \"$1\".",
+       "uploadstash-bad-path-unrecognized-thumb-name": "بندانگشتی نامعلوم.",
+       "uploadstash-bad-path-no-handler": "برای نمایش $1 پروندهٔ $2 اجراکننده‌ای یافت نشد.",
+       "uploadstash-bad-path-bad-format": "کلید «$1» ساختار درستی ندارد.",
+       "uploadstash-file-not-found": "کلید «$1» در انبار یافت نشد.",
+       "uploadstash-file-not-found-no-thumb": "امکان گرفتن بندانگشتی نیست.",
+       "uploadstash-file-not-found-no-local-path": "مسیر محلی برای آیتم مقایس‌شده وجود ندارد.",
+       "uploadstash-file-not-found-no-object": "امکان ساخت شیء پروندهٔ محلی برای بندانگشتی وجود ندارد.",
+       "uploadstash-file-not-found-no-remote-thumb": "دریافت بندانگشتی با مشکل مواجه شد:$1\nنشانی = $2",
+       "uploadstash-file-not-found-missing-content-type": "سرآیند نوع-محتوی یافت نشد.",
+       "uploadstash-file-not-found-not-exists": "امکان یافتن مسیر نیست، یا فایل ساده نیست.",
+       "uploadstash-file-too-large": "امکان ذخیرهٔ پرونده بیش از $1 بایت نیست.",
+       "uploadstash-not-logged-in": "هیچ کاربری به سامانه وارد نشده‌است، پرونده باید متعلق به یک کاربر باشد.",
+       "uploadstash-wrong-owner": "این پرونده ($1) به این کاربر تعلق ندارد.",
+       "uploadstash-no-such-key": "امکان حذف کلید ($1) نیست.",
+       "uploadstash-no-extension": "افزونه نیست.",
+       "uploadstash-zero-length": "اندازهٔ پرونده صفر است.",
        "invalid-chunk-offset": "جابجایی نامعتبر قطعه",
        "img-auth-accessdenied": "منع دسترسی",
        "img-auth-nopathinfo": "PATH_INFO موجود نیست.\nسرور شما برای ردکردن این مقدار تنظیم نشده‌است.\nممکن است مبتنی بر سی‌جی‌آی باشد و از img_auth پشتیبانی نکند.\nhttps://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization را ببینید.",
index 04559d2..6f3a711 100644 (file)
                        "DePlusJean",
                        "Pierpao",
                        "Vexthedorito",
-                       "Djiboun"
+                       "Djiboun",
+                       "Pols12"
                ]
        },
        "tog-underline": "Soulignement des liens :",
        "tog-watchuploads": "Ajouter les nouveaux fichiers que j’importe à ma liste de suivi",
        "tog-watchrollback": "Ajouter à ma liste de suivi les pages sur lesquelles j’ai effectué une révocation",
        "tog-minordefault": "Marquer toutes mes modifications comme étant mineures par défaut",
-       "tog-previewontop": "Afficher la prévisualisation au dessus de la zone d’édition",
+       "tog-previewontop": "Afficher la prévisualisation au-dessus de la zone de modification",
        "tog-previewonfirst": "Afficher la prévisualisation lors de la première modification",
        "tog-enotifwatchlistpages": "M’avertir par courriel lorsqu’une page ou un fichier de ma liste de suivi est modifié",
        "tog-enotifusertalkpages": "M’avertir par courriel lorsque ma page de discussion est modifiée",
        "underline-always": "Toujours",
        "underline-never": "Jamais",
        "underline-default": "Valeur par défaut du thème ou du navigateur",
-       "editfont-style": "Style de police de la zone d’édition :",
+       "editfont-style": "Style de police de la zone de modification :",
        "editfont-monospace": "Police à chasse fixe",
        "editfont-sansserif": "Police sans-serif",
        "editfont-serif": "Police serif",
        "uploadstash-file-not-found-no-remote-thumb": "La récupération de la vignette a échoué : $1\nurl = $2",
        "uploadstash-file-not-found-missing-content-type": "Entête content-type manquant.",
        "uploadstash-file-not-found-not-exists": "Impossible de trouver le chemin, ou bien ce n’est pas un fichier.",
-       "uploadstash-file-too-large": "Impossible de fournir un fichier pus gros que $1 octets.",
+       "uploadstash-file-too-large": "Impossible de fournir un fichier plus grand que $1 octets.",
        "uploadstash-not-logged-in": "Aucun utilisateur n’est connecté, les fichiers doivent appartenir à des utilisateurs.",
        "uploadstash-wrong-owner": "Ce fichier ($1) n’appartient pas à l’utilisateur courant.",
-       "uploadstash-no-such-key": "Aucune clé semblable ($1), impossible de supprimer.",
+       "uploadstash-no-such-key": "Aucune clé ($1), impossible de supprimer.",
        "uploadstash-no-extension": "L’extension est nulle.",
        "uploadstash-zero-length": "La taille du fichier est zéro.",
        "invalid-chunk-offset": "Offset de segment non valide",
        "autoredircomment": "Page redirigée vers [[$1]]",
        "autosumm-new": "Page créée avec « $1 »",
        "autosumm-newblank": "Page vide créée",
-       "size-bytes": "$1&nbsp;o",
+       "size-bytes": "$1 {{PLURAL:$1|octet|octets}}",
        "size-kilobytes": "$1&nbsp;Kio",
        "size-megabytes": "$1&nbsp;Mio",
        "size-gigabytes": "$1&nbsp;Gio",
        "feedback-close": "Terminé",
        "feedback-external-bug-report-button": "Signaler un bogue technique",
        "feedback-dialog-title": "Soumettre un commentaire",
-       "feedback-dialog-intro": "Vous pouvez utiliser le simple formulaire ci-dessous pour faire parvenir vos commentaires. Votre commentaire sera ajouté à la page « $1 », ainsi que votre nom d’utilisateur.",
+       "feedback-dialog-intro": "Vous pouvez utiliser le simple formulaire ci-dessous pour faire parvenir votre commentaire. Il sera ajouté à la page « $1 », avec votre nom d’utilisateur.",
        "feedback-error1": "Erreur : résultat de l'API non reconnu",
        "feedback-error2": "Erreur : la modification a échoué",
        "feedback-error3": "Erreur : aucune réponse de l'API",
        "default-skin-not-found-row-disabled": "* <code>$1</code> / $2 (<strong>désactivé</strong>)",
        "mediastatistics": "Statistiques sur les médias",
        "mediastatistics-summary": "Statistiques sur les types de fichiers téléversés. Elles ne prennent en compte que la version la plus récente des fichiers. Les versions anciennes ou supprimées sont exclues.",
+       "mediastatistics-nfiles": "$1 ($2 %)",
        "mediastatistics-nbytes": "{{PLURAL:$1|$1 octet|$1 octets}} ($2 ; $3%)",
        "mediastatistics-bytespertype": "Taille totale de fichiers pour cette section : {{PLURAL:$1|$1 octet|$1 octets}} ($2 ; $3%).",
        "mediastatistics-allbytes": "Taille totale pour tous les fichiers : {{PLURAL:$1|$1 octet|$1 octets}} ($2).",
        "authprovider-confirmlink-message": "D’après vos dernières tentatives de connexion, les comptes suivants peuvent être liés à votre compte wiki. Les lier vous permettra de se connecter via ces comptes. Veuillez sélectionner lesquels doivent être liés.",
        "authprovider-confirmlink-request-label": "Comptes qui doivent être liés",
        "authprovider-confirmlink-success-line": "$1 : Liés avec succès.",
+       "authprovider-confirmlink-failed-line": "$1 : $2",
        "authprovider-confirmlink-failed": "La liaison du compte n’a pas bien réussi : $1",
        "authprovider-confirmlink-ok-help": "Continuer après l’affichage des messages d’échec de liaison.",
        "authprovider-resetpass-skip-label": "Sauter",
index 19b55a2..e956dcc 100644 (file)
        "search-redirect": "(athsheoladh $1)",
        "search-section": "(gearradh $1)",
        "search-suggest": "An raibh $1 á lorg agat?",
+       "search-rewritten": "Ag taispeáint torthaí le haghaidh $1. Ina ionad sin, cuardaigh le haghaidh $2.",
        "search-interwiki-caption": "Comhthionscadail",
        "search-interwiki-default": "Torthaí ó $1:",
        "search-interwiki-more": "(níos mó)",
        "stub-threshold-disabled": "Díchumasaithe",
        "recentchangesdays": "Méid laethanta le taispeáint sna hathruithe is déanaí:",
        "recentchangesdays-max": "(uasmhéid $1 {{PLURAL:$1|lá|lá}})",
-       "recentchangescount": "Méid athrú le taispeáint:",
+       "recentchangescount": "Méid athruithe le taispeáint:",
        "savedprefs": "Sábháladh do chuid sainroghanna.",
        "timezonelegend": "Crios ama:",
        "localtime": "An t-am áitiúil:",
        "rcfilters-other-review-tools": "Uirlisí athbhreithnithe eile",
        "rcfilters-activefilters": "Scagairí gníomhacha",
        "rcfilters-advancedfilters": "Ardscagairí",
-       "rcfilters-limit-shownum": "Taispeáin an {{$1 athrú}} is déanaí",
+       "rcfilters-limit-title": "Athruithe le taispeáint",
+       "rcfilters-limit-shownum": "Taispeáin an $1 athrú is déanaí",
        "rcfilters-days-title": "Le líon áirithe laethanta anuas",
        "rcfilters-hours-title": "Uaireanta is déanaí",
        "rcfilters-days-show-days": "$1 {{PLURAL:$1|lá}}",
        "rc_categories_any": "Aon chatagóir",
        "rc-change-size-new": "$1 {{PLURAL:$1|bheart|beart}} tar éis an athraithe",
        "newsectionsummary": "/* $1 */ mír nua",
-       "rc-enhanced-expand": "Taispeáin mionsonraithe (JavaScript riachtanach)",
+       "rc-enhanced-expand": "Taispeáin mionsonraithe",
        "rc-enhanced-hide": "Folaigh shonraí",
        "recentchangeslinked": "Athruithe gaolmhara",
        "recentchangeslinked-feed": "Athruithe gaolmhara",
        "undeleteinvert": "Cuir an roghnú bun os cionn",
        "undeletecomment": "Tuairisc:",
        "undelete-search-box": "Cuardaigh leathanaigh scriosta",
+       "undelete-search-prefix": "Taispeáin leathanaigh ag tosú le:",
        "undelete-search-submit": "Cuardaigh",
        "namespace": "Ainmspás:",
        "invert": "Iompaigh rogha bunoscionn",
        "bad_image_list": "Is é seo a leanas an formáid:\n\nNíl ach míreanna liosta amháin (línte ag tosú le *) san áireamh.\nIs riachtanach gur nasc do dhrochchomhad é an chéad nasc ar líne.\nIs eisceachtaí iad na naisc eile ar an líne céanna, .i. leathanaigh gur féidir an comhad a bheith orthu go hinlíne.",
        "metadata": "Meiteasonraí",
        "metadata-help": "Tá breis eolais sa comhad seo, curtha, is dócha, as ceamara digiteach ná scanóir a chruthaigh ná a digitigh é.\nMá tá an comhad mionathraithe as an bunleagan, b'fhéidir nach mbeidh ceann de na sonraí fágtha sa comhad atá athruithe.",
-       "metadata-expand": "Taispeáin sonraí síneadh",
+       "metadata-expand": "Taispeáin sonraí sínte",
        "metadata-collapse": "Folaigh sonraí síneadh",
        "metadata-fields": "Beidh na meiteasonraí EXIF seo a leanas dá dtaispeáint ar an leathanach íomhá nuair atá an clár meiteasonraí ceilte.\nBeidh na cinn eile ceilte de réir réamhshocraithe.\n* make\n* model\n* datetimeoriginal\n* exposuretime\n* fnumber\n* isospeedratings\n* focallength\n* artist\n* copyright\n* imagedescription\n* gpslatitude\n* gpslongitude\n* gpsaltitude",
        "exif-imagewidth": "Leithead",
        "table_pager_prev": "Leathanach roimhe",
        "table_pager_first": "Céad leathanach",
        "table_pager_last": "Deireadh leathanach",
+       "table_pager_limit": "Taispeáin $1 mír/leathanach",
        "table_pager_limit_submit": "Gabh",
        "table_pager_empty": "Folamh",
        "autoredircomment": "Ag athdhíriú go [[$1]]",
        "specialpages-group-spam": "Uirlisí turscar",
        "blankpage": "Leathanach bán",
        "tag-list-wrapper": "([[Special:Tags|{{PLURAL:$1|chlib amháin|clib}}]]: $2)",
+       "diff-form-submit": "Taispeáin difríochtaí",
        "htmlform-selectorother-other": "Eile",
        "logentry-move-move": "{{GENDER:$2|Bhog}} $1 an leathanach $3 go $4",
        "feedback-cancel": "Cealaigh",
index 51286cd..e8ae8e4 100644 (file)
        "rcfilters-savedqueries-apply-and-setdefault-label": "Crear filtro por defecto",
        "rcfilters-savedqueries-cancel-label": "Cancelar",
        "rcfilters-savedqueries-add-new-title": "Gardar a configuración do filtro actual",
+       "rcfilters-savedqueries-already-saved": "Estes filtro xa están gardados",
        "rcfilters-restore-default-filters": "Restaurar os filtros por defecto",
        "rcfilters-clear-all-filters": "Borrar todos os filtros",
        "rcfilters-show-new-changes": "Mostrar os cambios máis recentes",
index 58a0c36..6584a3d 100644 (file)
        "rcfilters-savedqueries-apply-and-setdefault-label": "Alapértelmezett szűrő készítése",
        "rcfilters-savedqueries-cancel-label": "Mégse",
        "rcfilters-savedqueries-add-new-title": "Szűrők mentése gyors hivatkozásként",
+       "rcfilters-savedqueries-already-saved": "Ezek a szűrők már el lettek mentve",
        "rcfilters-restore-default-filters": "Alapértelmezett szűrők visszaállítása",
        "rcfilters-clear-all-filters": "Összes szűrő kikapcsolása",
        "rcfilters-show-new-changes": "Legfrissebb változtatások megtekintése",
        "uploadstash-refresh": "Fájlok listájának frissítése",
        "uploadstash-thumbnail": "bélyegkép megjelenítése",
        "uploadstash-exception": "Nem sikerült eltárolni a feltöltést a stash-ben ($1): „$2”",
+       "uploadstash-bad-path": "Útvonal nem létezik",
+       "uploadstash-bad-path-invalid": "Érvénytelen útvonal",
+       "uploadstash-bad-path-unknown-type": "Ismeretlen típus: „$1”",
        "invalid-chunk-offset": "Érvénytelen darab eltolás",
        "img-auth-accessdenied": "Hozzáférés megtagadva",
        "img-auth-nopathinfo": "Hiányzó PATH_INFO.\nA szerver nincs beállítva, hogy továbbítsa ezt az információt.\nLehet, hogy CGI-alapú, és nem támogatja az img_auth-ot.\nLásd https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization!",
index 0c52fb4..a70c190 100644 (file)
@@ -73,7 +73,6 @@
        "underline-never": "Numquam",
        "underline-default": "Defalta navigatri interretialis",
        "editfont-style": "Stilus:",
-       "editfont-default": "iuxta navigatrum",
        "editfont-sansserif": "Fons Sans-serif",
        "editfont-serif": "Fons Serif",
        "sunday": "dies Solis",
        "anontalk": "Disputatio",
        "navigation": "Navigatio",
        "and": "&#32;et",
-       "qbfind": "Invenire",
-       "qbbrowse": "Perspicere",
-       "qbedit": "Recensere",
-       "qbpageoptions": "Optiones paginae",
-       "qbmyoptions": "Paginae meae",
        "faq": "Quaestiones frequentes",
-       "faqpage": "Project:Quaestiones frequentes",
        "actions": "Actiones",
        "namespaces": "Spatia nominalia",
        "variants": "Variantes",
        "view-foreign": "Legere apud {{grammar:accusative|$1}}",
        "edit": "Recensere",
        "create": "Creare",
-       "editthispage": "Recensere hanc paginam",
-       "create-this-page": "Creare hanc paginam",
        "delete": "Delere",
-       "deletethispage": "Delere hanc paginam",
-       "undeletethispage": "Hanc paginam restituere",
        "undelete_short": "{{PLURAL:$1|Unam recensionem|$1 recensiones}} restituere",
        "viewdeleted_short": "{{PLURAL:$1|unam redactionem deletam|$1 redactiones deletas}} inspicere",
        "protect": "Protegere",
        "protect_change": "mutare",
-       "protectthispage": "Protegere hanc paginam",
        "unprotect": "Protectionem mutare",
-       "unprotectthispage": "Protectionem huius paginae mutare",
        "newpage": "Nova pagina",
-       "talkpage": "Disputare hanc paginam",
        "talkpagelinktext": "Disputatio",
        "specialpage": "Pagina specialis",
        "personaltools": "Instrumenta personalia",
-       "articlepage": "Videre rem",
        "talk": "Disputatio",
        "views": "Visae",
        "toolbox": "Arca ferramentorum",
-       "userpage": "Videre paginam usoris",
-       "projectpage": "Videre consilium",
        "imagepage": "Videre paginam fasciculi",
        "mediawikipage": "Videre nuntium",
        "templatepage": "Videre formulam",
        "explainconflict": "Alius hanc paginam mutavit postquam eadem recensere incipiebas.\nCapsa superior paginae verba recentissima continet.\nMutationes tuae in capsa inferiore monstrantur.\nMutationes tuae in verba superiora adiungare debes.\n'''Solum''' verba capsae superioris servabuntur quando \"$1\" premes.",
        "yourtext": "Tua redactio",
        "storedversion": "Redactio modo servata",
-       "nonunicodebrowser": "'''CAVETO: Navigatorium retiale tuum systemati UNICODE morem non gerit. Modum habemus quo commentationes sine damno recenseas: litterae non-ASCII in capsa sub veste hexadecimali ostendentur.'''",
        "editingold": "'''CAVE, ne huius paginae redactionem recenses obsoletam!\nQua servata omnes recensiones abhinc factas peribunt.'''",
        "yourdiff": "Differentia",
        "copyrightwarning": "Nota bene omnia contributa divulgari sub ''$2'' (vide singula apud $1).\nNisi vis verba tua crudelissime recenseri, mutari, et ad libidinem redistribui, noli ea submittere.<br />\nNobis etiam spondes te esse ipsum horum verborum scriptorem primum, aut ex opere in \"dominio publico\" exscripsisse.\n'''NOLI OPERIBUS SUB IURE DIVULGANDI UTI SINE POTESTATE!'''",
        "sp-contributions-username": "Locus IP aut nomen usoris:",
        "sp-contributions-submit": "Quaerere",
        "whatlinkshere": "Nexus ad paginam",
-       "whatlinkshere-title": "Paginae quae ad \"$1\" nectunt",
+       "whatlinkshere-title": "Paginae quae ad \"$1\" nectuntur",
        "whatlinkshere-page": "Pagina:",
        "linkshere": "Paginae sequentes ad '''[[:$1]]''' nectunt:",
        "nolinkshere": "Nullae paginae ad '''[[:$1]]''' nectunt.",
        "whatlinkshere-hideimages": "$1 nexus fasciculi",
        "whatlinkshere-filters": "Filtra",
        "blockip": "Usorem obstruere",
-       "blockip-legend": "Usorem vel locum IP obstruere",
        "blockiptext": "Forma infra data utere, ut quendam usorem vel locum IP arceas a scribendo.\nQuod non nisi secundum [[{{MediaWiki:Policy-url}}|hoc consilium]] fiat, ut vandalismus supprimatur.\nRationem certam da (exempli gratia titulos paginarum, quibus iste usor more vandalico nocuit)!",
        "ipaddressorusername": "Locus IP aut nomen usoris:",
        "ipbexpiry": "Exitus:",
        "compare-page2": "Pagina 2",
        "compare-rev1": "Redactio una",
        "compare-rev2": "Redactio altera",
+       "diff-form": "'''forma'''",
        "htmlform-submit": "Submittere",
        "htmlform-reset": "Mutationes abrogare",
        "htmlform-selectorother-other": "Aliud",
index 1f945f3..2f501a8 100644 (file)
        "mytalk": "Diskusyón",
        "anontalk": "Diskusyón para este adresso de IP",
        "navigation": "Navigación",
-       "and": "&#32;i",
+       "and": "&#32;y",
        "faq": "DDS",
        "actions": "Aksiones",
        "namespaces": "Espacios de nombres",
        "otherlanguages": "En otras linguas",
        "redirectedfrom": "(Redirijado de $1)",
        "redirectpagesub": "Hoja redirigida",
-       "lastmodifiedat": "Esta hoja fue trocada por la vez dalcavo en el $1, a las $2 la ora.",
+       "lastmodifiedat": "Esta hoja la vez dalcavo se trocó enel $1, a las $2 la ora.",
        "viewcount": "Este pajina fue vijitado {{PLURAL:$1|una vez|$1 vezes}}.",
        "protectedpage": "Hoja guardada",
        "jumpto": "Saltar a:",
        "tooltip-pt-login": "Te consejamos de entrar a tu cuento, portanto no sos obligado",
        "tooltip-pt-logout": "Sal de tu cuento",
        "tooltip-pt-createaccount": "Te consejamos de avrir un cuento y hazer entrada allá, portanto no sos obligado",
-       "tooltip-ca-talk": "Diskusyón encima del artíkolo",
-       "tooltip-ca-edit": "Puedes trocar esta hoja. Ma te rogamos para que eches una ojada (previsteo) antes de enrejistrarla.",
+       "tooltip-ca-talk": "Diskusyón encima del contènido desta hoja",
+       "tooltip-ca-edit": "Troca esta hoja",
        "tooltip-ca-addsection": "Ajusta un kapítolo muevo",
        "tooltip-ca-viewsource": "Esta hoja está guadrada.\nPuedes ver su manadero",
        "tooltip-ca-history": "Enderechamientos passados desta hoja",
        "tooltip-n-portal": "Encima del projeto, lo que se puede hazer y ande se topa las cosas",
        "tooltip-n-currentevents": "Jhaberes de oy día en ancho",
        "tooltip-n-recentchanges": "La lista de los trocamientos dalcavo enel viki",
-       "tooltip-n-randompage": "Carga una hoja por azardo",
+       "tooltip-n-randompage": "Avre una hoja por azardo",
        "tooltip-n-help": "Para saver mas y tomar ayudo",
-       "tooltip-t-whatlinkshere": "Una lista de todas las hojas del viki que tienen atamientos a esta hoja",
+       "tooltip-t-whatlinkshere": "La lista de todas las hojas del viki que tienen atamientos a esta hoja",
        "tooltip-t-recentchangeslinked": "Los trocamientos dalcavo en las hojas atadas a la ésta",
        "tooltip-feed-rss": "Sindicación RSS de esta hoja",
        "tooltip-feed-atom": "Canal Atomo parâ esta hoja",
        "tooltip-t-emailuser": "A este usuario, mándale una letra electrόnica (ímey)",
        "tooltip-t-upload": "Suve dosyas",
        "tooltip-t-specialpages": "La lista de todas las hojas especiales",
-       "tooltip-t-print": "La forma apropiada parâ imprimir esta hoja",
+       "tooltip-t-print": "La vista desta hoja apropiada para imprimir",
        "tooltip-t-permalink": "Atamiento permanente (fikso) a este enderechamiento de la hoja",
        "tooltip-ca-nstab-main": "Ve el artíkolo",
        "tooltip-ca-nstab-user": "Ver la hoja del usador",
index 7e96931..ad5a415 100644 (file)
        "subject-preview": "Sujet kucken ouni ze späicheren:",
        "previewerrortext": "Beim Versuch fir Är Ännerungen ze weisen, ass e Feeler geschitt.",
        "blockedtitle": "Benotzer ass gespaart",
-       "blockedtext": "Äre Benotzernumm oder Är IP-Adress gouf gespaart.\n\nD'Spär gouf vum $1 gemaach. Als Grond gouf ''$2'' uginn.\n\n* Ufank vun der Spär: $8\n* Enn vun der Spär: $6\n* Spär betrëfft: $7\n\nDir kënnt den/d' $1 kontaktéieren oder ee vun den aneren [[{{MediaWiki:Grouppage-sysop}}|Administrateure]] fir iwwer d'Spär ze schwätzen.\n\nDëst sollt Der besonnesch maachen, wann Der d'Gefill hutt, datt de Grond fir d'Spären net bei Iech läit.\nD'Ursaach dofir ass an deem Fall, datt der eng dynamesch IP hutt, iwwer en Access-Provider, iwwer deen och aner Leit fueren.\nAus deem Grond ass et recommandéiert, sech e Benotzernumm zouzeleeën, fir all Mëssverständnes z'evitéieren.\n\nDir kënnt d'Funktioun \"Dësem Benotzer eng E-Mail schécken\" nëmme benotzen, wann Dir eng gëlteg E-Mail Adress bei Ären [[Special:Preferences|Astellungen]] aginn hutt.\nÄr aktuell IP-Adress ass $3 an d'Nummer vun der Spär ass #$5.\nSchreift all dës Informatioune w.e.g. bei all Ufro derbäi.",
+       "blockedtext": "Äre Benotzernumm oder Är IP-Adress gouf gespaart.\n\nD'Spär gouf vum $1 gemaach. Als Grond gouf ''$2'' uginn.\n\n* Ufank vun der Spär: $8\n* Enn vun der Spär: $6\n* Spär betrëfft: $7\n\nDir kënnt den/d' $1 kontaktéieren oder ee vun den aneren [[{{MediaWiki:Grouppage-sysop}}|Administrateure]] fir iwwer d'Spär ze schwätzen.\n\nDëst sollt Dir besonnesch maachen, wann Dir d'Gefill hutt, datt de Grond fir d'Spären net bei Iech läit.\nD'Ursaach dofir ass an deem Fall, datt Dir eng dynamesch IP hutt, iwwer en Access-Provider, iwwer deen och aner Leit fueren.\nAus deem Grond ass et recommandéiert, sech e Benotzernumm zouzeleeën, fir all Mëssverständnes z'evitéieren.\n\nDir kënnt d'Funktioun \"Dësem Benotzer eng E-Mail schécken\" nëmme benotzen, wann Dir eng gëlteg E-Mail Adress bei Ären [[Special:Preferences|Astellungen]] aginn hutt.\nÄr aktuell IP-Adress ass $3 an d'Nummer vun der Spär ass #$5.\nSchreift all dës Informatioune w.e.g. bei all Ufro derbäi.",
        "autoblockedtext": "Är IP-Adress gouf automatesch gespaart, well se vun engem anere Benotzer gebraucht gouf, an dee vum $1 gespaart gouf.\nDe Grond dofir war:\n\n:''$2''\n\n* Ufank vun der Spär: $8\n* Dauer vun der Spär: $6\n* D'Spär leeft of: $7\n\nDir kënnt de(n) $1 oder soss een [[{{MediaWiki:Grouppage-sysop}}|Administrateur]] kontaktéieren, fir iwwer déi Spär ze diskutéieren.\n\nBedenkt datt Dir d'Funktioun \"Dësem Benotzer eng E-Mail schécken\" benotze kënnt wann Dir eng gëlteg E-Mail-Adress an Ären [[Special:Preferences|Astellungen]] uginn hutt a wann dat net fir Iech gespaart gouf.\n\nÄr aktuell IP-Adress ass $3 an d'Nummer vun Ärer Spär ass $5.\nGitt dës Donnéeë w.e.g bei allen Ufroen zu dëser Spär un.",
        "blockednoreason": "Kee Grond uginn",
        "whitelistedittext": "Dir musst Iech $1, fir Säiten änneren ze kënnen.",
        "userpage-userdoesnotexist": "De Benotzerkont \"<nowiki>$1</nowiki>\" ass net registréiert.\nIwwerpréift w.e.g. op Dir dës Säit uleeën/ännere wëllt.",
        "userpage-userdoesnotexist-view": "De Benotzerkont \"$1\" ass net registréiert.",
        "blocked-notice-logextract": "Dëse Benotzer ass elo gespaart.\nDéi lescht Entrée am Logbuch vun de Späre steet als Referenz hei drënner:",
-       "clearyourcache": "<strong>Opgepasst - Nom Späichere muss der Ärem Browser seng Cache eidel maachen, fir d'Ännerungen ze gesinn.</strong>\n* <strong>Firefox / Safari:</strong> Halt <em>Shift</em> während Dir <em>Reload</em> klickt oder dréckt entweder <em>Ctrl-F5</em> oder <em>Ctrl-R</em> (<em>⌘-R</em> op engem Mac);\n* <strong>Google Chrome:</strong> Dréckt <em>Ctrl-Shift-R</em> (<em>⌘-Shift-R</em> op engem Mac)\n* <strong>Internet Explorer:</strong> dréckt <em>Ctrl</em> während Dir op <em>Refresh</em> klickt oder dréckt <em>Ctrl-F5.</em>\n* <strong>Opera:</strong> Gitt op de <em>Menu → Settings</em> (<em>Opera → Preferences</em> op engem  Mac) an dann op <em>Privacy & security → Clear browsing data → Cached images and files</em>.",
+       "clearyourcache": "<strong>Opgepasst - Nom Späichere musst Dir Ärem Browser seng Cache eidel maachen, fir d'Ännerungen ze gesinn.</strong>\n* <strong>Firefox / Safari:</strong> Halt <em>Shift</em> während Dir <em>Reload</em> klickt oder dréckt entweder <em>Ctrl-F5</em> oder <em>Ctrl-R</em> (<em>⌘-R</em> op engem Mac);\n* <strong>Google Chrome:</strong> Dréckt <em>Ctrl-Shift-R</em> (<em>⌘-Shift-R</em> op engem Mac)\n* <strong>Internet Explorer:</strong> dréckt <em>Ctrl</em> während Dir op <em>Refresh</em> klickt oder dréckt <em>Ctrl-F5.</em>\n* <strong>Opera:</strong> Gitt op de <em>Menu → Settings</em> (<em>Opera → Preferences</em> op engem  Mac) an dann op <em>Privacy & security → Clear browsing data → Cached images and files</em>.",
        "usercssyoucanpreview": "'''Tipp:''' Benotzt de \"{{int:showpreview}}\"-Knäppchen, fir Ären neien CSS virum Späicheren ze testen.",
        "userjsyoucanpreview": "'''Tipp:''' Benotzt de ''{{int:showpreview}}''-Knäppchen, fir Ären neie JavaScript virum Späicheren ze testen.",
        "usercsspreview": "'''Bedenkt: Dir kuckt just är Benotzer CSS.\nSi gouf nach net gespäichert!'''",
        "rcfilters-savedqueries-apply-and-setdefault-label": "Standardfilter uleeën",
        "rcfilters-savedqueries-cancel-label": "Ofbriechen",
        "rcfilters-savedqueries-add-new-title": "Aktuell Filter-Astellunge späicheren",
+       "rcfilters-savedqueries-already-saved": "Dës Filtere si scho gespäichert",
        "rcfilters-restore-default-filters": "Standardfiltere restauréieren",
        "rcfilters-clear-all-filters": "All Filteren eidelmaachen",
        "rcfilters-show-new-changes": "Rezentst Ännerunge weisen",
        "log": "Logbicher",
        "logeventslist-submit": "Weisen",
        "all-logs-page": "All ëffentlech Logbicher",
-       "alllogstext": "Dëst ass eng kombinéiert Lëscht vu Logbicher op {{SITENAME}}.\nDir kënnt d'Siche limitéieren wann Dir e Log-Typ, e Benotzernumm (case-senisitive) oder déi gefrote Säit (och case-senisitive) agitt.",
+       "alllogstext": "Dëst ass eng kombinéiert Lëscht vu Logbicher op {{SITENAME}}.\nDir kënnt d'Siche limitéiere wann Dir e Log-Typ, e Benotzernumm (case-senisitive) oder déi gefrot Säit (och case-senisitive) agitt.",
        "logempty": "Näischt fonnt.",
        "log-title-wildcard": "Titel fänkt mat dësem Text un",
        "showhideselectedlogentries": "Déi erausgesicht Entréeën am Logbuch weisen/verstoppen",
        "pageinfo-recent-edits": "Zuel vun de rezenten Ännerungen (an de leschten $1)",
        "pageinfo-recent-authors": "Zuel vun de verschiddenen Auteuren",
        "pageinfo-magic-words": "{{PLURAL:$1|Magescht Wuert|Magesch Wierder}} ($1)",
-       "pageinfo-hidden-categories": "Verstoppte {{PLURAL:$1|Kategorie|Kategorien}} ($1)",
-       "pageinfo-templates": "Agebonne {{PLURAL:$1|Schabloun|Schabloune}} ($1)",
+       "pageinfo-hidden-categories": "Verstoppt {{PLURAL:$1|Kategorie|Kategorien}} ($1)",
+       "pageinfo-templates": "Agebonn {{PLURAL:$1|Schabloun|Schablounen}} ($1)",
        "pageinfo-transclusions": "Agebonnen {{PLURAL:$1|an eng Säit|a(n) $1 Säiten}}",
        "pageinfo-toolboxlink": "Informatiounen iwwer d'Säit",
        "pageinfo-redirectsto": "Viruleedung op",
index 581e409..137a1bc 100644 (file)
@@ -15,7 +15,7 @@
        },
        "tog-underline": "خط کیشائن ژێر پیوندەل:",
        "tog-hideminor": "آشاردن دەسکاریەل گؤجەر  إژ گؤەڕیال(تغییرات) ایسە(اخیر)",
-       "tog-hidepatrolled": "دسکاریۀل گه دیار بینۀ ئژ فئرست-رزگ تغییرات اخیر بشارا",
+       "tog-hidepatrolled": "ویرایش‌های گشت‌خورده از فهرست تغییرات اخیر پنهان شود",
        "tog-newpageshidepatrolled": "وڵگۀل گه دیار بینۀ ئژ فئرست-رزگ ولگۀل تازۀ بشارا",
        "tog-hidecategorization": "فهرست بالا سی ئی صفحه",
        "tog-extendwatchlist": " کؤل رزگ-فئرست الؤن(آلشت)کریال-تغیرات نیشان دۀ،نۀ هر تنیا دؤمائنۀل",
        "tog-minordefault": "کؤڵ دسکاری بیۀل به عنؤان پئش فرض عڵامت بۀرن",
        "tog-previewontop": "پیش نمایش وهِ رئ جعبۀ نمایش نیشؤن به",
        "tog-previewonfirst": "پێش دئین وە اوەڵێن دەسکاری نیشۆن دە",
-       "tog-enotifwatchlistpages": "ئÛ\80ر Ù\88ÚµÚ¯Û\80 Û\8cا Ù¾Ø±Ø¤Ù\86دئÙ\87 Ø¦Ú\98 Ù\81ئرست-رزگ Ù¾Û\8câ\80\8cÚ¯Û\8cرÛ\8câ\80\8cÛ\80Ù\84Ù\85 Ø¯Ø³Ú©Ø§Ø±Û\8c Ø¨Û\8c Ù\86اÙ\85Ù\87 Ø¦Û\80را Ù\85Ù\87 Ú©Ù\90Ù\84Ù\91 Ú©Û\80",
-       "tog-enotifusertalkpages": "Ù\87Û\80Ù\86ئگÙ\87\88ختئ Ú¯Ù\87 Ø¦Û\80 Ù\88ÚµÚ¯Û\80 Ú¯Ù¾ Ú©Ø§Ø¨Ø±Û\8cÙ\85 ØªØºÛ\8cÛ\8cر Ú©Ø±Û\8cا Ù\86اÙ\85Ù\87 Ø¦Û\80را Ù\85Ù\87 Ú©Ù\90Ù\84 Ú©Û\80",
-       "tog-enotifminoredits": "ئÛ\80ر ØªØºÛ\8cÛ\8cرÛ\80Ù\84-آڵؤÙ\86Û\80Ù\84(Ø¢Ù\84شتÛ\80Ù\84)گؤجÛ\80رÛ\8cجÛ\8c Ø¦Û\80ر Ù\88ÚµÚ¯Û\80Ù\84 Ø¤ Ù¾Ø±Ø¤Ù\86دÛ\80Ù\84Ù\85 Ú©Ø±Û\8cا Ù\86اÙ\85Ù\87 Ø¦Û\80را Ù\85Ù\87 Ú©Ù\90Ù\84 Ú©Û\80",
+       "tog-enotifwatchlistpages": "ئÛ\95Ú¯Û\95ر Ù¾Û\95Ú\95Û\95Û\8e Û\8cا Ú¤Û\95ÚµÚ¯Û\95Û\8e Ø¦Û\95Ú\98 Ù¾Û\95Û\8eÚ¯Û\8cرÛ\8cÛ\95Ù\84Ù\85 Ú¯Ù\88Ù\88Û\95Ú\95Û\8cا(تغÛ\8cرÛ\8cاÙ\81ت)ئÛ\8cÙ\85Û\95Û\8cÙ\84Û\8e Ø¦Û\95Ú\95اÙ\86Ù\85 Ú©Ù\84 Ú©Û\95",
+       "tog-enotifusertalkpages": "Ù\87Û\95Ù\86Û\8e(Ú¤Û\95Ù\82تÛ\8e)Ù¾Û\95Ú\95Û\95Û\8e Ø¦Û\95Ú\98 Ú¤Û\95ÚµÚ¯Û\95 Ú¯Û\95Ù¾(Ù\82سÛ\95)Ú¯Ù\88Ù\88Û\95Ú\95Û\8cا Ø¦Û\8cÙ\85Û\95Ù\84Û\8e Ø¦Û\95Ú\95اÙ\86Ù\85 Ú©Ù\84 Ú©Û\95",
+       "tog-enotifminoredits": "ئÛ\95Ú\95ا Ú¯Ù\88Ù\88Û\95Ú\95اÙ\86Ù\86Û\95Ù\84(تغÛ\8cرات)Ú¯Ù\88Ù\88جÛ\95ر Ø¦Û\95 Ú¤Û\95ÚµÚ¯Û\95Ù\84/Ù¾Û\95Ú\95Û\95Ù\84 Ø¦Û\8cÙ\85Û\95Û\8cÙ\84Û\8e Ø¦Û\95Ú\95اÙ\86Ù\85 Ú©Ù\84 Ú©Û\95",
        "tog-enotifrevealaddr": "نیشانی ایمیل مه ئۀر ایمیل‌ل حاوواڵ رۀسن نیشؤن دۀ",
        "tog-shownumberswatching": "گلۀ شؤماری-شؤمار کاربۀل پی‌گیر نیشان دۀ",
        "tog-oldsig": ":امضاێ موجود ایوه",
        "tog-fancysig": "(امضا چؤی ویکی‌متن بوو(بدون پئؤن خودکار نیائن",
-       "tog-uselivepreview": "استفاده از پیش‌نمایش زنده",
+       "tog-uselivepreview": "پێش سەیرکەر بدون گرەک(نیاز)ڤە بروز رسانی ڤەڵگە",
        "tog-forceeditsummary": "هۀنئ گه-وختئ که خؤلاصۀ دسکاریم نَنیؤیسائۀ خۀؤۀ رم کۀ",
        "tog-watchlisthideown": "دسکاریۀل ووژم ئژ فئرست سئرکردن بشارآ",
        "tog-watchlisthidebots": "دسکاریۀل ربات ئژ فئرست سئرکردن بشآرا",
        "tog-watchlisthideminor": "دسکاریۀل گؤجۀر ئژ فئرست سئرکردن بشارآ",
        "tog-watchlisthideliu": "دەسکاری کاربرەل إنۆم هەتێ سیستم وە لیست پیگیریەل بشارآ",
        "tog-watchlistreloadautomatically": "Reload the watchlist automatically whenever a filter is changed (JavaScript required)",
+       "tog-watchlistunwatchlinks": "افزودن پیوندهای مستقیم خروج از پی‌گیری به فهرست پی‌گیری (جاواسکریپت ممکن است نیاز شود)",
        "tog-watchlisthideanons": "دةسکاری کاربرةل ناشنا ئة لیست نمائش بشارآ",
        "tog-watchlisthidepatrolled": "دسکاریۀل گشت خورده-سئرکریا ئژ فئرست سئرکردن بشآرا",
        "tog-watchlisthidecategorization": "نهفتن رده‌بندی صفحه‌ها",
@@ -60,7 +61,6 @@
        "underline-never": "هؤیچ وخت",
        "underline-default": "پوسته یا مِنِی کەر پیش‌فرض",
        "editfont-style": ":شئؤۀ قلم جعبهٔ دسکاری",
-       "editfont-default": "پیشفرض مِنِی کەر",
        "editfont-monospace": "قلم وە فاصلۀ ثابت",
        "editfont-sansserif": "قلم بئ گوشۀ",
        "editfont-serif": "قلم گوشۀ دار",
        "index-category": "صفحه‌های نمایه‌شده",
        "noindex-category": "صفحه‌های نمایه‌نشده",
        "broken-file-category": "صفحه‌های دارای پیوند خراب به پرونده",
+       "categoryviewer-pagedlinks": "($1) ($2)",
        "about": "دۀربارۀ",
        "article": "وەڵگە نۆم چێنە",
        "newwindow": "(واز کردن ئۀر دۀروۀچۀ جدید)",
        "faq": "پرسش‌های متداول",
        "actions": "کارۀل",
        "namespaces": "فضای نامۀل",
-       "variants": "قصۀ کِرۀل",
+       "variants": "گەپ دێەل(قسەکرەل)",
        "navigation-heading": "منوی ناوبری",
        "errorpagetitle": "خطا",
        "returnto": "بازگشت به $1",
        "redirectedfrom": "(تغییرمسیر إژ $1)",
        "redirectpagesub": "وةڵگة تغییرمسیر",
        "redirectto": ":تغییر مسیر به",
-       "lastmodifiedat": ".اێ وەڵگەآخرین گِل وە $1 سات $2 گؤەڕیائە(تغییریافته)",
+       "lastmodifiedat": "ئێ ڤەڵگەئاخرێن گِل ڤە $1 سات $2 گووەڕیائە(تغییریافته)",
        "viewcount": "إژ ئئ وةڵگة  {{PLURAL:$1|یإ گِل|$1$1چةن گِل}} بازدید بیة.",
        "protectedpage": "وەڵگە پڵۆم بیە",
        "jumpto": ":وازآ کردن/پریدن وۀ",
        "versionrequired": "نسخهٔ $1 از نرم‌افزار مدیاویکی لازم است",
        "versionrequiredtext": "برای دیدن این صفحه به نسخهٔ $1 از نرم‌افزار مدیاویکی نیاز دارید.\nبه [[Special:Version|این صفحه]] مراجعه کنید.",
        "ok": "خوو/ باشد",
+       "pagetitle": "$1 - {{SITENAME}}",
+       "pagetitle-view-mainpage": "{{SITENAME}}",
        "retrievedfrom": "إژ \"$1\" گیریائۀ",
        "youhavenewmessages": "{{PLURAL:$3|درین}}$1$2",
        "youhavenewmessagesfromusers": "{{PLURAL:$4|هؤمة}} $1 د {{PLURAL:$3|کاربةرێ تِر|$3 کاربةر}}دِرین($2).",
        "youhavenewmessagesmulti": ".پیغامةل جدیدی ئة $1 درین",
        "editsection": "دةسکاری",
        "editold": "دةسکاری",
-       "viewsourceold": "سئرکردÙ\86 Ø¨Ù\90Ù\86Ú\86Û\80Ú©/Ù\85Û\80Ù\86بÛ\80ع",
+       "viewsourceold": "بÙ\86Ú\86Û\95Ú©(Ù\85Ù\86بع) Ø¨Û\8aÙ\86(سÛ\95Û\8cرکÛ\95)",
        "editlink": "دەسکاری",
-       "viewsourcelink": "سئرکردÙ\86 Ø¨Ù\90Ù\86Ú\86Û\80Ú©/Ù\85Û\80Ù\86بÛ\80ع",
+       "viewsourcelink": "بÙ\86Ú\86Û\95Ú©(Ù\85Ù\86بع) Ø¨Û\8aÙ\86(سÛ\95Û\8cرکÛ\95)",
        "editsectionhint": "دۀسکاری بۀخش: $1",
        "toc": "محتویات",
        "showtoc": "نیشان دائن",
        "perfcached": "داده‌های زیر از حافظهٔ نهانی فراخوانی شده‌اند و ممکن است کاملاً به‌روز نباشند. حداکثر {{PLURAL:$1|یک نتیجه| $1 نتیجه}} در حافظهٔ نهانی قابل دسترس است.",
        "perfcachedts": "داده‌های زیر از حافظهٔ نهانی فراخوانی شده‌اند و آخرین بار در $1 به‌روزرسانی شدند. حداکثر {{PLURAL:$4|یک نتیجه|$4 نتیجه}} در حافظهٔ نهانی قابل دسترس است.",
        "querypage-no-updates": "امکان به‌روزرسانی این صفحه فعلاً غیرفعال شده‌است.\nاطلاعات این صفحه ممکن است به‌روز نباشد.",
-       "viewsource": "سئرکردÙ\86 Ø¨Ù\90Ù\86Ú\86Û\80Ú©/Ù\85Û\80Ù\86بÛ\80ع",
+       "viewsource": "بÙ\86Ú\86Û\95Ú©(Ù\85Ù\86بع) Ø¨Û\8aÙ\86(سÛ\95Û\8cرکÛ\95)",
        "viewsource-title": "نمایش بِنچةک ئةرا $1",
        "actionthrottled": "جلوی عمل شما گرفته شد",
        "actionthrottledtext": "به منظور جلوگیری از انتشار خرابکاری، اجازه ندارید که چنین عملی را بیش از چند بار در یک مدت زمان کوتاه انجام بدهید.\nلطفاً پس از چند دقیقه دوباره تلاش کنید.",
        "yourdomainname": ":دامنهٔ شما",
        "password-change-forbidden": ".شما نمی‌توانید گذرواژه‌ها را در این ویکی تغییر دهید",
        "externaldberror": "خطایی در ارتباط با پایگاه داده رخ داده است یا اینکه شما اجازهٔ به‌روزرسانی حساب خارجی خود را ندارید.",
-       "login": "إ نۆم هەتن سیستم",
+       "login": "ڤە نۆم هەتن",
        "login-security": "وژت معرفی‌که",
        "nav-login-createaccount": " إ نؤم هةتن سیستم/ حساوو کاربةری سازین",
        "logout": "دەرچێن|خروج",
        "badretype": "گذرواژةلێ گإ نۆیساتة چؤِی یةک نیِن",
        "usernameinprogress": ". دِرێ حساوو دؤرسة مةکإ . خواهشا صبر کةن",
        "userexists": ".نام کاربةری‌ گإ واردت کردئة قبلاً استفاده بیة\n.خواهشا نامێ تر استفادة کةن",
-       "loginerror": "خطای إ نام هةتن سیستم",
+       "loginerror": "نادوەرستی ڤە نۆم هەتن",
        "createacct-error": "خطای  حساوو کاربةری سازین",
        "createaccounterror": "نمآوو ئئ حساووة بِسازین: $1",
        "nocookiesnew": "حساوو کاربةری سازیا، اما هؤمة أ سیستم نهةتینة/نهاتینة.\n{{SITENAME}} برای ورود کاربران به سامانه از کوکی استفاده می‌کند.\nشما کوکی‌ها را از کار انداخته‌اید.\nلطفاً کوکی‌ها را به کار بیندازید، و سپس با نام کاربری و گذرواژهٔ جدیدتان به سامانه وارد شوید.",
        "suspicious-userlogout": "درخواست هؤمة ئةرا  دةرچئن إژ سیستم  رد بیة زیرا به نظر می‌رسد که این  .درخواست توسط یک مرورگر معیوب یا پروکسی میانگیر کل/ارسال بیة",
        "createacct-another-realname-tip": "نام راسکانی/واقعی دڵ بخواهیة.\nاگر آن را وارد کنید هنگام ارجاع به آثارتان و انتساب آن‌ها به شما از نام واقعی‌تان استفاده خواهد شد.",
        "pt-login": "إنۆم هەتِن.",
-       "pt-login-button": "إ نۆم هەتن سیستم",
+       "pt-login-button": "ڤە نۆم هەتن",
        "pt-login-continue-button": "ادامه سی ورود سیستم",
        "pt-createaccount": "حساووئ أرا ووژتان بِسازِن",
        "pt-userlogout": "دەرچێن|خروج",
        "resetpass-no-info": "برای دسترسی مستقیم به این صفحه شما باید به سامانه وارد شده باشید.",
        "resetpass-submit-loggedin": "تغییردائن رمز",
        "resetpass-submit-cancel": "ئآهووسانن/لغو",
-       "resetpass-wrong-oldpass": "گذرÙ\88اÚ\98Ù\87Ù\94 Ù\85Ù\88Ù\82ت Û\8cا Ø§Ø®Û\8cر Ù\86اÙ\85عتبر.\nÙ\85Ù\85Ú©Ù\86 Ø§Ø³Øª Ú©Ù\87 Ø´Ù\85ا Ù\87Ù\85Û\8cÙ\86Ú© Ú¯Ø°Ø±Ù\88اÚ\98Ù\87â\80\8cتاÙ\86 Ø±Ø§ Ø¨Ø§ Ù\85Ù\88Ù\81Ù\82Û\8cت ØªØºÛ\8cÛ\8cر Ø¯Ø§Ø¯Ù\87 Ø¨Ø§Ø´Û\8cد Û\8cا Ø¯Ø±Ø®Ù\88است Û\8cÚ© Ú¯Ø°Ø±Ù\88اÚ\98Ù\87Ù\94 Ù\85Ù\88Ù\82ت ØªØ§Ø²Ù\87 Ú©Ø±Ø¯Ù\87 Ø¨Ø§Ø´Û\8cد.",
+       "resetpass-wrong-oldpass": "گذرواژهٔ موقت یا اخیر نامعتبر.\nممکن است که شما همینک گذرواژه‌تان را تغییر داده باشید یا درخواست یک گذرواژهٔ موقت تازه کرده باشید.",
        "resetpass-recycled": "لطفاً رمز عبور خود را به چیز دیگری غیر از رمز عبور فعلی تنظیم کنید.",
        "resetpass-temp-emailed": "شما با یک کد ایمیل شدهٔ موقت وارد شده‌اید.\nبرای پایان ورود، شما باید رمز عبور جدیدی اینجا وارد کنید:",
        "resetpass-temp-password": ":رمز عبور موقت",
        "passwordreset-emailsentusername": "اگر نشانی پست الکترونیکی مرتبطی موجود باشد، یک نامه برای بازنشانی گذرواژه به آن ارسال خواهد شد.",
        "passwordreset-nocaller": "زنگ مجبور نییه به تأمین کردن",
        "passwordreset-nosuchcaller": "زنگ موجود نییه: $1",
+       "passwordreset-ignored": "به بازنشانی گذرواژه پرداخته نشد. آیا ممکن است که هيچ مهياکننده‌ای برای این کار تنظيم نشده باشد؟",
        "passwordreset-invalidemail": "آدرس ایمیل نامعتبره",
+       "passwordreset-nodata": "یک نام کاربری و یا یک آدرس ايميل، هيچکدام ارائه نشده",
        "changeemail": "تغییر یا حذف نشانی ایمیل",
        "changeemail-header": "برای تغییر ایمیلتان این فرم را کامل کنید. برای حذف ایملیتان کافی است بخش ایمیل را خالی رها کنید و فرم را ارسال کنید.",
        "changeemail-no-info": ".برای دسترسی مستقیم به این صفحه شما باید به سیستم وارد شده باشید",
        "headline_tip": "عنوان سطح ۲",
        "nowiki_sample": "متن قالب‌بندی‌نشده اینجا وارد شود",
        "nowiki_tip": "نادیده‌گرفتن قالب‌بندی ویکی",
+       "image_sample": "نموونە.jpg",
        "image_tip": "تصویر داخل متن",
+       "media_sample": "نموونە.ogg",
        "media_tip": "پیوند پرونده",
        "sig_tip": "امضای هومۀ و برچسب زۀمان",
        "hr_tip": " )خط افقی(از آن کم استفاده کنید",
        "preview": "پیش‌نمایش",
        "showpreview": "پیش‌نمایش",
        "showdiff": "گؤەڕیال(تغییرات) بۆین",
-       "blankarticle": "<strong>هوشدار:</strong> هۆمە وەڵگەتۆن سازیە پەتیە(حالیە).\nأڕ «$1» دۆِ گِل کلیک کِین ، وەڵگە بێ  نۆم جِک(محتوا) مەسازێ.",
+       "blankarticle": "<strong>ئاگاتۆ داشتوو:</strong> هۆمە ڤەڵگەتۆن سازیە پەتیە(خالیە).\nئەڕ «$1» دۆِ گِل کلیک کِین ، ڤەڵگە بێ  نۆمجِک(محتوا) مەسازێ.",
        "anoneditwarning": "<strong>هشدار:</strong> شما وارد نشده‌اید. نشانی آی‌پی شما برای عموم قابل مشاهده خواهد بود اگر هر تغییری ایجاد کنید. اگر <strong>[$1 وارد شوید]</strong> یا <strong>[$2 یک حساب کاربری بسازید]</strong>، ویرایش‌هایتان به نام کاربری‌تان نسبت داده خواهد شد، همراه با مزایای دیگر.",
        "anonpreviewwarning": "''شما به سامانه وارد نشده‌اید. ذخیره کردن باعث می‌شود که نشانی آی‌پی شما در تاریخچهٔ این صفحه ثبت گردد.''",
        "missingsummary": "'''یادآوری:''' شما خلاصهٔ ویرایش ننوشته‌اید.\nاگر دوباره دکمهٔ «$1» را فشار دهید ویرایش شما بدون آن ذخیره خواهد شد.",
        "updated": "(تازة سازی بیة)",
        "note": "'''نکته:'''",
        "previewnote": "'''به یاد داشته باشید که این فقط پیش‌نمایش است.'''\nتغییرات شما هنوز ذخیره نشده‌است!",
-       "continue-editing": "بچۆإ بةخش دةکاری",
+       "continue-editing": "بچۆ ئەڕا بەش دەسکاریکردن",
        "previewconflict": "این پیش‌نمایش منعکس‌کنندهٔ متن ناحیهٔ ویرایش متن بالایی است، به شکلی که اگر متن را ذخیره کنید نمایش خواهد یافت.",
        "session_fail_preview": "'''شرمنده! به علت از دست رفتن اطلاعات نشست کاربری نمی‌توانیم ویرایش شما را پردازش کنیم.'''\nلطفاً دوباره سعی کنید.\nاگر دوباره به همین پیام برخوردید از سامانه [[Special:UserLogout|خارج شوید]] و دوباره وارد شوید.",
        "session_fail_preview_html": "'''متأسفانه امکان ثبت ویرایش شما به خاطر از دست رفتن اطلاعات نشست کاربری وجود ندارد.'''\n\n''با توجه به این که در {{SITENAME}} امکان درج اچ‌تی‌ام‌ال خام فعال است، پیش‌نمایش صفحه پنهان شده تا امکان حملات مبتنی بر جاوااسکریپت وجود نداشته باشد.''\n\n'''اگر مطمئن هستید که این پیش‌نمایش یک ویرایش مجاز است، آن را تکرار کنید.'''\nاگر تکرار پیش‌نمایش نتیجه نداد، از سامانه [[Special:UserLogout|خارج شوید]] و دوباره وارد شوید.",
        "explainconflict": "از وقتی ویرایش این صفحه را آغاز کرده‌اید شخص دیگری آن را تغییر داده است.\nناحیهٔ متنی بالایی شامل متن صفحه به شکل کنونی آن است.\nتغییرات شما در ناحیهٔ متنی پایینی نشان داده شده‌است.\nشما باید تغییراتتان را با متن کنونی ترکیب کنید.\nبا فشردن دکمهٔ «$1» <strong>فقط</strong> متن ناحیهٔ متنی بالایی ذخیره خواهد شد.",
        "yourtext": "متن شما",
        "storedversion": "نسخهٔ ذخیره شده",
-       "nonunicodebrowser": "'''هشدار: مرورگر شما با استانداردهای یونیکد سازگار نیست.'''\nراه حلی به کار گرفته شده تا شما بتوانید صفحات را با امنیت ویرایش کنید: کاراکترهای غیر ASCII به صورت کدهایی در مبنای شانزده به شما نشان داده می‌شوند.",
        "editingold": "'''هشدار: شما در حال ویرایش نسخه‌ای قدیمی از این صفحه هستید.'''\nاگر ذخیره‌اش کنید، هر تغییری که پس از این نسخه انجام شده‌است از بین خواهد رفت.",
        "yourdiff": "تفاوت‌ها",
        "copyrightwarning": "لطفاً توجه داشته‌باشید که همهٔ مشارکت‌ها در {{SITENAME}} منتشرشده تحت $2 در نظر گرفته‌می‌شوند (برای جزئیات بیش‌تر $1 را ببینید).\nاگر نمی‌خواهید نوشته‌هایتان بی‌رحمانه ویرایش و توزیع شوند؛ بنابراین، آنها را اینجا ارائه نکنید.<br />\nشما همچنین به ما تعهد می‌کنید که خودتان این را نوشته‌اید یا آن را از یک منبع با مالکیت عمومی یا مشابه آزاد آن برداشته‌اید (برای جزئیات بیش‌تر $1 را ببینید).\n<strong>کارهای دارای حق تکثیر را بدون اجازه ارائه نکنید!</strong>",
        "yourgender": "ترجیح می‌دهید چگونه توصیف شوید؟",
        "gender-unknown": "هنگام ذکر شما، نرم‌افزار تا جای ممکن از کلمات خنثی از نظر جنسیت استفاده خواهد",
        "gender-male": "پیا",
-       "gender-female": "ژن",
+       "gender-female": "ئافرەت(ژەن)",
        "prefs-help-gender": "انجام این تنظیم اختیاری است.\nنرم‌افزار از این مقدار برای اشارهٔ صحیح به جنسیت و ذکر شما برای دیگران با استفاده از دستور زبان درست استفاده می‌کند.\nاین اطلاعات عمومی خواهند بود.",
        "email": "ایمیل",
        "prefs-help-realname": "نام واقعی اختیاری است.\nاگر وارد شده است هنگام ارجاع به آثارتان و انتساب آن‌ها به شما ممکن است از نام واقعی‌تان استفاده شود.",
        "userrights-changeable-col": "گروه‌هایی که می‌توانید تغییر دهید",
        "userrights-unchangeable-col": "گروه‌هایی که نمی‌توانید تغییر دهید",
        "userrights-conflict": "تعارض دسترسی‌های کاربری! لطفاً بررسی کنید و تغییرات را تأیید کنید.",
-       "group": "گروه:",
+       "group": "داکووکە(گروو):",
        "group-user": "کاربۀر",
        "group-autoconfirmed": "کاربران تأییدشدهٔ خودکار",
        "group-bot": "ربات‌ها",
        "rc_categories": "محدود به این رده‌ها (رده‌ها را با «|» جدا کنید):",
        "rc_categories_any": "هر کدام از منتخب‌ها",
        "rc-change-size-new": " $1دؤما تۀقیر دائن{{PLURAL:$1|بایت|بایتل}}",
-       "newsectionsummary": "/* $1 */ بةخش جدید",
+       "newsectionsummary": "/* $1 */ بەخش نوو",
        "rc-enhanced-expand": "نمایش جزئیات",
        "rc-enhanced-hide": "نهفتن جزئیات",
        "rc-old-title": "ایجادشده با عنوان اصلی «$1»",
        "recentchangeslinked-toolbox": "تغییرۀ مرتبط",
        "recentchangeslinked-title": "تغییرات مرتبط با $1",
        "recentchangeslinked-summary": "در زیر فهرستی از تغییرات اخیر صفحه‌های پیوند داده شده از این صفحه (یا اعضای رده مورد نظر) را می‌بینید.\nصفحه‌هایی که در [[Special:Watchlist|فهرست پی‌گیری‌هایتان]] باشند به صورت '''پررنگ''' نشان داده می‌شوند.",
-       "recentchangeslinked-page": ":نام وةڵگة",
+       "recentchangeslinked-page": "نۆم ڤەڵگە:",
        "recentchangeslinked-to": "نمایش تغییرات صفحه‌هایی که به صفحهٔ داده‌شده پیوند دارند",
        "recentchanges-page-added-to-category": "[[:$1]] اضاف بیە ڕِزگ",
        "recentchanges-page-added-to-category-bundled": "[[:$1]] و {{PLURAL:$2|یک صفحه|$2 صفحه}}ٔ دیگر به رده اضافه شدند",
        "fileuploadsummary": "خلاصه:",
        "filereuploadsummary": "تغییرات پرونده:",
        "filestatus": "وضعیت حق تکثیر:",
-       "filesource": ":بِنچۀک/مۀنبۀع",
+       "filesource": "بنچەک(منبع)",
        "ignorewarning": "چشم‌پوشی از هشدار و ذخیرهٔ پرونده.",
        "ignorewarnings": "چشم‌پوشی از همهٔ هشدارها",
        "minlength1": "نام پرونده دست کم باید یک حرف باشد.",
        "listgrouprights": "اختیارات گروه‌های کاربری",
        "listgrouprights-summary": "فهرست زیر شامل گروه‌های کاربری تعریف شده در این ویکی و اختیارات داده شده به آن‌ها است.\nاطلاعات بیشتر در مورد هر یک از اختیارات را در [[{{MediaWiki:Listgrouprights-helppage}}]] بیابید.",
        "listgrouprights-key": "* <span class=\"listgrouprights-granted\">اختیارات داده‌شده</span>\n* <span class=\"listgrouprights-revoked\">اختیارات گرفته‌شده</span>",
-       "listgrouprights-group": "گروه",
+       "listgrouprights-group": "داکووکە(گروو)",
        "listgrouprights-rights": "دسترسی‌ها",
        "listgrouprights-helppage": "Help:دسترسی‌های گروهی",
        "listgrouprights-members": "(فهرست اعضا)",
        "blanknamespace": "(سەر/اصلی)",
        "contributions": "هؤمکاریۀل{{GENDER:$1|کاربۀر}}",
        "contributions-title": "مشارکت‌های کاربری $1",
-       "mycontris": "هؤمکاری کِرۀل",
-       "anoncontribs": "هؤمکاری کِرۀل",
+       "mycontris": "بەشاکرەل(هام بێرەل)",
+       "anoncontribs": "بەشاکرەل(هام بێرەل)",
        "contribsub2": "برای {{GENDER:$3|$1}} ($2)",
        "contributions-userdoesnotexist": "حساب کاربری «$1» ثبت نشده‌است.",
        "nocontribs": "هیچ تغییری با این مشخصات یافت نشد.",
        "block": "بستن کاربر.",
        "unblock": "بازکردن کاربر",
        "blockip": "بستن {{GENDER:$1|کاربر}}",
-       "blockip-legend": "بستن کاربر",
        "blockiptext": "از فرم زیر برای بستن دسترسی ویرایش یک نشانی آی‌پی یا نام کاربری مشخص استفاده کنید.\nاین کار فقط فقط باید برای جلوگیری از خرابکاری و بر اساس [[{{MediaWiki:Policy-url}}|سیاست قطع دسترسی]] انجام شود.\nدلیل مشخص این کار را در زیر ذکر کنید (مثلاً با ذکر صفحه‌های به‌خصوصی که مورد خرابکاری واقع شده‌اند).",
        "ipaddressorusername": "نشانی آی‌پی یا نام کاربری:",
        "ipbexpiry": "زمان سرآمدن:",
        "exif-sublocationdest": "بخش شهر نمایش داده شده",
        "exif-objectname": "عنوان کوتاه",
        "exif-specialinstructions": "دستورالعمل‌های ویژه",
-       "exif-headline": "سةر Ù\88ةڵگة",
+       "exif-headline": "عÙ\86Ù\88اÙ\86",
        "exif-credit": "صاحب امتیاز/ارائه کننده",
-       "exif-source": "بÙ\90Ù\86Ú\86Û\80Ú©/Ù\85Û\80Ù\86بÛ\80ع",
+       "exif-source": "بÙ\86Ú\86Û\95Ú©(Ù\85Ù\86بع)",
        "exif-editstatus": "وضعیت تحریریه تصویر",
        "exif-urgency": "فوریت/هڵةپڵة",
        "exif-fixtureidentifier": "نام ستون نشریه",
        "exif-gpsdirection-m": "جهت مغناطیسی",
        "exif-ycbcrpositioning-1": "وسط‌چین‌شده",
        "exif-ycbcrpositioning-2": "اشتراکی/هام بةشی",
-       "exif-dc-contributor": "هؤمکاری کِرۀل",
+       "exif-dc-contributor": "بەشاکرەل(هام بێرەل)",
        "exif-dc-coverage": "محدوده مکانی و یا زمانی رسانه",
        "exif-dc-date": "تاریخ(ها)",
        "exif-dc-publisher": "بۀشا کۀر-ناشر",
        "tags-tag": "نام برچسب",
        "tags-display-header": "نمایش در فهرست‌های تغییرات",
        "tags-description-header": "توضیح کامل معنی",
-       "tags-source-header": "بÙ\90Ù\86Ú\86Û\80Ú©/Ù\85Û\80Ù\86بÛ\80ع",
+       "tags-source-header": "بÙ\86Ú\86Û\95Ú©(Ù\85Ù\86بع)",
        "tags-active-header": "فعال(کارکةر)؟",
        "tags-hitcount-header": "تغییرهای برچسب‌دار",
        "tags-actions-header": "کارۀل",
index 48cf1d5..5e3778e 100644 (file)
        "accmailtext": "Nejauši ģenerēta parole lietotājam [[User talk:$1|$1]] tika nosūtīta uz $2.\n\nŠī konta paroli pēc ielogošanās varēs nomainīt ''[[Special:ChangePassword|šeit]]''.",
        "newarticle": "(Jauns raksts)",
        "newarticletext": "Šajā projektā vēl nav lapas ar šādu nosaukumu.\nLai izveidotu lapu, sāc rakstīt teksta logā apakšā (par teksta formatēšanu un sīkākai informācija skatīt [$1 palīdzības lapu]).\nJa tu šeit nonāci kļūdas pēc, vienkārši uzspied <strong>back</strong> pogu pārlūkprogrammā.",
-       "anontalkpagetext": "----''Šī ir diskusiju lapa anonīmam dalībniekam, kurš vēl nav kļuvis par reģistrētu dalībnieku vai arī neizmanto savu dalībnieka vārdu. Tādēļ mums ir jāizmanto skaitliskā IP adrese, lai viņu identificētu.\nŠāda IP adrese var būt vairākiem dalībniekiem.\nJa tu esi anonīms dalībnieks un uzskati, ka tev ir adresēti neatbilstoši komentāri, lūdzu, [[Special:CreateAccount|kļūsti par dalībnieku]] vai arī [[Special:UserLogin|izmanto jau izveidotu dalībnieka vārdu]], lai izvairītos no turpmākām neskaidrībām un tu netiktu sajaukts ar citiem anonīmiem dalībniekiem.''",
+       "anontalkpagetext": "----\n<em>Šī ir anonīma dalībnieka, kurš vēl nav izveidojis lietotāja kontu vai to nelieto, diskusiju lapa.</em>\nTādēļ mums ir jāizmanto IP adrese, lai viņu identificētu.\nŠāda IP adrese var būt vairākiem dalībniekiem.\nJa tu esi anonīms dalībnieks un uzskati, ka tev ir adresēti neatbilstoši komentāri, lūdzu, [[Special:CreateAccount|izveido kontu]] vai [[Special:UserLogin|pieslēdzies]], lai izvairītos no turpmākām neskaidrībām un tu netiktu sajaukts ar citiem anonīmiem dalībniekiem.",
        "noarticletext": "Šajā lapā šobrīd nav nekāda teksta, tu vari [[Special:Search/{{PAGENAME}}|meklēt citās lapās pēc šīs lapas nosaukuma]], <span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} meklēt saistītos reģistru ierakstos] vai arī [{{fullurl:{{FULLPAGENAME}}|action=edit}} sākt rediģēt šo lapu]</span>.",
        "noarticletext-nopermission": "Šajā lapā pašlaik nav nekāda teksta.\nTu vari [[Special:Search/{{PAGENAME}}|meklēt šīs lapas nosaukumu]] citās lapās,\nvai <span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} meklēt saistītus reģistru ierakstus]</span>, bet jums nav atļauja izveidot šo lapu.",
        "userpage-userdoesnotexist": "Lietotājs \"<nowiki>$1</nowiki>\" nav reģistrēts.\nLūdzu, pārliecinies vai vēlies izveidot/izmainīt šo lapu.",
        "prefs-editor": "Redaktors",
        "prefs-preview": "Priekšskatījums",
        "prefs-advancedrc": "Papildu iespējas",
+       "prefs-opt-out": "Atteikties no uzlabojumiem",
        "prefs-advancedrendering": "Papildu iespējas",
        "prefs-advancedsearchoptions": "Papildu iespējas",
        "prefs-advancedwatchlist": "Papildu iespējas",
        "action-userrights-interwiki": "mainīt dalībnieku tiesības citās Vikipēdijās",
        "action-siteadmin": "bloķēt vai atbloķēt datubāzi",
        "action-sendemail": "sūtīt e-pastus",
+       "action-editmyoptions": "labot savas izvēles",
        "action-deletechangetags": "dzēst iezīmes no datubāzes",
        "nchanges": "$1 {{PLURAL:$1|izmaiņas|izmaiņa|izmaiņas}}",
        "enhancedrc-since-last-visit": "$1 {{PLURAL:$1|kopš pēdējā apmeklējuma}}",
        "listfiles-delete": "dzēst",
        "listfiles-summary": "Šajā īpašajā lapā ir redzami visi augšupielādētie faili.",
        "listfiles_search_for": "Meklēt failu pēc vārda:",
+       "listfiles-userdoesnotexist": "Dalībnieks \"$1\" nav reģistrēts.",
        "imgfile": "fails",
        "listfiles": "Attēlu uzskaitījums",
        "listfiles_thumb": "Sīktēls",
        "apisandbox-dynamic-parameters-add-placeholder": "Parametra nosaukums",
        "apisandbox-deprecated-parameters": "Novecojuši parametri",
        "apisandbox-results": "Rezultāti",
+       "apisandbox-sending-request": "Sūta API pieprasījumu...",
+       "apisandbox-loading-results": "Saņem API rezultātus...",
+       "apisandbox-request-selectformat-label": "Rādīt pieprasījuma datus kā:",
        "apisandbox-request-format-url-label": "URL vaicājuma teksts",
        "apisandbox-request-url-label": "Pieprasījuma URL:",
        "apisandbox-request-json-label": "Pieprasījuma JSON:",
        "protectexpiry": "Beidzas:",
        "protect_expiry_invalid": "Beigu termiņš ir nederīgs.",
        "protect_expiry_old": "Beigu termiņs ir pagātnē.",
+       "protect-unchain-permissions": "Pieslēgt papildu aizsargāšanas iespējas",
        "protect-text": "Šeit var apskatīt un izmainīt lapas <strong>$1</strong> aizsardzības līmeni.",
        "protect-locked-access": "Jūsu kontam nav atļaujas mainīt lapas aizsardzības pakāpi.\nPašreizējie lapas '''$1''' iestatījumi ir:",
        "protect-cascadeon": "Šī lapa pašlaik ir aizsargāta, jo tā ir iekļauta {{PLURAL:$1|šajās lapās|šajā lapā|šajās lapās}} (mainot šīs lapas aizsardzības līmeni aizsardzība netiks noņemta):",
        "protect-default": "Atļaut visiem lietotājiem",
        "protect-fallback": "Atļaut tikai lietotājiem ar \"$1\" atļauju",
-       "protect-level-autoconfirmed": "Atļaut tikai autoapstiprinātiem lietotājiem",
+       "protect-level-autoconfirmed": "Atļaut tikai pašpārbaudītajiem",
        "protect-level-sysop": "Atļaut tikai administratoriem",
        "protect-summary-cascade": "kaskāde",
        "protect-expiring": "līdz $1 (UTC)",
        "protect-expiring-local": "beidzas $1",
        "protect-expiry-indefinite": "bezgalīgs",
-       "protect-cascade": "Aizsargāt šajā lapā iekļautās lapas (veidnes) ''(cascading protection)''",
+       "protect-cascade": "Aizsargāt šajā lapā iekļautās lapas un veidnes (kaskādes aizsardzība)",
        "protect-cantedit": "Tu nevari izmainīt šīs lapas aizsardzības līmeņus, tāpēc, ka tur nevari izmainīt šo lapu.",
        "protect-othertime": "Cits laiks:",
        "protect-othertime-op": "cits laiks",
        "pageinfo-article-id": "Lapas ID",
        "pageinfo-language": "Lappuses satura valoda",
        "pageinfo-content-model": "Lapas satura modelis",
+       "pageinfo-content-model-change": "mainīt",
        "pageinfo-robot-policy": "Indeksācija ar robotiem",
        "pageinfo-robot-index": "Atļauta",
        "pageinfo-robot-noindex": "Aizliegta",
        "pageinfo-watchers": "Lapas uzraudzītāju skaits",
+       "pageinfo-visiting-watchers": "Lapas uzraudzītāju skaits, kuri apskatījuši pēdējos labojumus",
        "pageinfo-few-watchers": "Mazāk kā $1 {{PLURAL:$1|uzraudzītāju|uzraudzītājs|uzraudzītāju}}",
        "pageinfo-redirects-name": "Pāradresāciju skaits uz šo lapu",
        "pageinfo-subpages-name": "Šīs lapas apakšlapas",
        "pageinfo-edits": "Kopējais izmaiņu skaits",
        "pageinfo-authors": "Kopējais atsevišķu autoru skaits",
        "pageinfo-recent-edits": "Izmaiņu skaits (pēdējās $1)",
+       "pageinfo-recent-authors": "Neseno lapas labotāju skaits",
        "pageinfo-magic-words": "{{PLURAL:$1|Maģiskie vārdi|Maģiskais vārds|Maģiskie vārdi}} ($1)",
        "pageinfo-hidden-categories": "{{PLURAL:$1|Slēptas kategorijas|Slēpta kategorija|Slēptas kategorijas}} ($1)",
        "pageinfo-templates": "{{PLURAL:$1|Iekļautās veidnes|Iekļautā veidne|Iekļautās veidnes}} ($1)",
index 507d04f..2186a3b 100644 (file)
@@ -8,7 +8,8 @@
                        "Bennylin",
                        "아라",
                        "Macofe",
-                       "Mbrt"
+                       "Mbrt",
+                       "Empu"
                ]
        },
        "tog-underline": "Garisen ngisoré pranala:",
@@ -36,9 +37,9 @@
        "tog-enotifminoredits": "Kirimna imel maring inyong uga nek ana suntingan cilik nang kaca lan berkas",
        "tog-enotifrevealaddr": "Tidokna alamat imel-e inyong nang imel notifikasi",
        "tog-shownumberswatching": "Tidhokna jumlah pangawas",
-       "tog-oldsig": "Tapak asma sekiye:",
+       "tog-oldsig": "Tapak asma:",
        "tog-fancysig": "Tapak asma dianggep dadi teks wiki (ora nganggo pranala otomatis)",
-       "tog-uselivepreview": "Gunakna pratayang langsung",
+       "tog-uselivepreview": "Tonton kaca sedurungé tapi aja dimuat ulang",
        "tog-forceeditsummary": "Emutna inyong anggere durung ngisi kotak ringkesan suntingan",
        "tog-watchlisthideown": "Umpetna suntingane inyong sekang daftar pangawasan",
        "tog-watchlisthidebots": "Umpetna suntingane bot sekang daftar pangawasan",
        "tog-showhiddencats": "Tidokna kategori sing diumpetna",
        "tog-norollbackdiff": "Aja ndeleng perbedaane seuwise nglakokna pambalikan",
        "tog-useeditwarning": "Elingna inyong angger ninggalna kaca panyuntingan sing durung disimpen owahane",
-       "tog-prefershttps": "Gunakna koneksi aman terus angger mlebu log",
+       "tog-prefershttps": "Kudu nganggo koneksi sing aman terus angger mlebu log",
        "underline-always": "Saben",
        "underline-never": "Ora tau",
-       "underline-default": "Gawane kulitutawa peramban",
+       "underline-default": "Kulit utawa gawan peramban",
        "editfont-style": "Modhèl aksara (font) nang kotak suntingan:",
-       "editfont-default": "Gawane peramban",
        "editfont-monospace": "Aksara (font) Monospace",
        "editfont-sansserif": "Aksara (font) Sans-serif",
        "editfont-serif": "Aksara (font) Serif",
        "newwindow": "(buka nang jendhéla anyar)",
        "cancel": "Ora Sida",
        "moredotdotdot": "Liyané...",
-       "morenotlisted": "Daftar kiye ora kumplit.",
+       "morenotlisted": "Daftar kiyé ora kumplit.",
        "mypage": "Kaca",
        "mytalk": "Dopokan",
        "anontalk": "Dhiskusi IP kiye",
        "navigation": "pandhu arah",
        "and": "&#32;lan",
-       "qbfind": "Goleti",
-       "qbbrowse": "Jelajahi",
-       "qbedit": "Sunting",
-       "qbpageoptions": "Kaca kiye",
-       "qbmyoptions": "Kaca-ne inyong",
        "faq": "FAQ (Pitakonan sing sering ditakokna)",
-       "faqpage": "Project:FAQ",
        "actions": "Tindakan",
        "namespaces": "Bilik jeneng",
        "variants": "Varian",
        "edit-local": "Sunting deskripsi lokal",
        "create": "Gawe",
        "create-local": "Tambahna pawedharan lokal",
-       "editthispage": "Sunting kaca kiye",
-       "create-this-page": "Gawe kaca kiye",
        "delete": "Busek",
-       "deletethispage": "Busak kaca kiye",
-       "undeletethispage": "Batalna pembusekan kaca kiye",
        "undelete_short": "Batalna pambusakan $1 {{PLURAL:$1|suntingan|suntingan}}",
        "viewdeleted_short": "Deleng {{PLURAL:$1|siji suntingan|$1 suntingan}} sing wis dibusak",
        "protect": "Direksa",
        "protect_change": "owahi",
-       "protectthispage": "Reksa kaca kiye",
        "unprotect": "Owahi pangreksan",
-       "unprotectthispage": "Owahi pangreksane kaca kiye",
        "newpage": "Kaca anyar",
-       "talkpage": "Dhiskusikna kaca kiye",
        "talkpagelinktext": "Dopokan",
        "specialpage": "Kaca khusus",
        "personaltools": "Piranti pribadi",
-       "articlepage": "Deleng isi tulisan",
        "talk": "bahas",
        "views": "Tampilan",
        "toolbox": "Pekakas",
-       "userpage": "Ndeleng kaca panganggo",
-       "projectpage": "Deleng kaca proyèk",
        "imagepage": "Deleng kaca berkas",
        "mediawikipage": "Ndeleng kaca pesen sistem",
        "templatepage": "Ndeleng kaca cithakan",
        "redirectedfrom": "(Dialihna sekang $1)",
        "redirectpagesub": "Kaca pangalihan",
        "redirectto": "Dialihna maring:",
-       "lastmodifiedat": "Kaca kiye nembe diowahi dong jam $2, tanggal $1.",
+       "lastmodifiedat": "Kaca kiyé nembé diowahi jam $2, tanggal $1.",
        "viewcount": "Kaca kiye uwis diakses ping {{PLURAL:$1|sepisan|$1}}",
        "protectedpage": "Kaca sing direksa",
        "jumpto": "Mlumpat maring:",
        "perfcached": "Data kiye dijikot sekang singgahan (''cache'') lan ndeyane dudu data pungkasan. Paling akeh {{PLURAL:$1|siji asil|$1 asil}} disediakna nang papan singgahan.",
        "perfcachedts": "Data kiye dijikot sekang singgahan (''cache''), lan dianyarna keri dhewek dong $1. Paling akeh ana  {{PLURAL:$4|siji asil|$4 asil}} disediakna nang papan singgahan.",
        "querypage-no-updates": "Update nggo kaca kiye lagi dipateni.\nData sing ana nang kene sekiye ora teyeng dibaleni unggah maning.",
-       "viewsource": "Deleng sumbere",
+       "viewsource": "Deleng sumberé",
        "viewsource-title": "Deleng sumbere nggo $1",
        "actionthrottled": "Tindakan diwatesi",
        "actionthrottledtext": "Kanggo ngukur anti-spam, Rika diwatesi gole nglakoni tikdakan kiye keseringen nang wektu sing cendhak, lan Rika uwis nglewati watese kuwe.\nMonggo dijajal maning nang sawetara menit.",
        "nocookieslogin": "{{SITENAME}} nggunakna ''cookies'' nggo log panganggone.\n''Cookies'' nang panjlajah web Rika dipateni.\nMonggo diaktfna lan jajal maning.",
        "nocookiesfornew": "Akun panganggo ora digawe, jalaran inyong ora teyeng mastikna sumbere.\nPastekna Rika uwis ngaktifna ''cookies'', trus baleni muat kaca kiye maning lan jajal sepisan maning.",
        "noname": "Jeneng panganggo sing Rika lebokna ora sah.",
-       "loginsuccesstitle": "Sukses mlebu log",
+       "loginsuccesstitle": "Mlebu log",
        "loginsuccess": "'''Rika sekiye mlebu log nang {{SITENAME}} nganggo jeneng \"$1\".'''",
        "nosuchuser": "Ora ana panganggo sing jenenge \"$1\".\nJeneng panganggo kuwe dibedakna nang kapitalisasi.\nPriksa maning ejaane Rika, utawa [[Special:CreateAccount|gawe akun anyar]]",
        "nosuchusershort": "Ora ana panganggo sing jenenge \"$1\".\nJajal dipriksa maning ejaane Rika.",
        "createaccount-title": "Gawe akun kanggo {{SITENAME}}",
        "createaccount-text": "Ana wong sing gawe akun nggo alamat imel-e Rika nang {{SITENAME}} ($4) nganggo jeneng \"$2\", lan tembung sandhi \"$3\".\nRika mendingan mlebu log disit lan ganti tembung sandine sekiye.\n\nRika teyeng nglirwakna pesen kiye anggere akun kiye kuwe jebule anu salah gawe.",
        "login-throttled": "Rika wis kakehan gole njajal mlebu log.\nTulung ngenteni $1 sedurunge njajal maning.",
-       "login-abort-generic": "Proses mlebu log Rika ora gagal - Dibatalna",
+       "login-abort-generic": "Rika gagal mlebu log - Dibatalna",
        "login-migrated-generic": "Akune rika uwis dipindahna, lan jeneng panganggone rika wis ora ana maning nang wiki kiye.",
        "loginlanguagelabel": "Basa: $1",
        "suspicious-userlogout": "Panjalukan Rika nggo metu log ditolak jalarak ketone dikirim nang panjlajah sing rusak utawa proksi panyinggah (''caching proxy'').",
        "newpassword": "Tembung sandi anyar:",
        "retypenew": "Ketik maning tembung sandhi:",
        "resetpass_submit": "Nata tembung sandhi lan mlebu log",
-       "changepassword-success": "Tembung sandhi Rika wis sukses diowahi!",
+       "changepassword-success": "Sandhiné Rika uwis diganti!",
        "changepassword-throttled": "Rika wis kakehan gole njajal mlebu log.\nTulung ngenteni $1 sedurunge njajal maning.",
        "resetpass_forbidden": "Tembung sandhi ora teyeng diganti",
        "resetpass-no-info": "Rika kudu mlebu log kanggo ngakses kaca kiye sacara langsung.",
        "resetpass-submit-loggedin": "Ganti tembung sandhi",
        "resetpass-submit-cancel": "Batal",
-       "resetpass-wrong-oldpass": "Tembung sandhi ora sah.\nRika ndeyan  uwis kasil ngganti tembung sandhine Rika utawa wis njaluk tembung sandhi sauntara sing anyar.",
+       "resetpass-wrong-oldpass": "Sandhi siki utawa sementara ora sah.\nRika ndeyan  uwis kasil ngganti tembung sandhiné Rika utawa wis njaluk tembung sandhi sementara sing anyar.",
        "resetpass-recycled": "Monggo diganti tembung sandhine rika nganggo sing sejen sekang tembung sandhi sekiye.",
        "resetpass-temp-emailed": "Rika mlebu long nganggo kode sawetara sing ana nang surel.\nKanggo ngrampungna gole mlebu log, rika kudu ngatur tembung sandhi anyar nang kene:",
        "resetpass-temp-password": "Tembung sandhi sauntara:",
        "changeemail": "Ganti alamat imel",
        "changeemail-header": "Ganti alamat imel-e akun",
        "changeemail-no-info": "Rika kudu mlebu log kanggo ngakses kaca kiye sacara langsung.",
-       "changeemail-oldemail": "Alamat imel sekiye:",
+       "changeemail-oldemail": "Alamat imel sekiyé:",
        "changeemail-newemail": "Alamat imel anyar:",
        "changeemail-none": "(ora ana)",
        "changeemail-password": "Tembung sandhi {{SITENAME}} Rika:",
        "changeemail-submit": "Ganti imel",
        "resettokens-no-tokens": "Ora ana token sing arep disetel maning.",
-       "resettokens-token-label": "$1 (biji sekiye:$2)",
+       "resettokens-token-label": "$1 (siki bijiné:$2)",
        "resettokens-done": "Token wis disetel maning.",
        "resettokens-resetbutton": "Nyetel maning token sing dipilih",
        "bold_sample": "Tèks kiye bakal dicithak kandel",
        "sig_tip": "Tapak astane Rika nganggo tandha wektu",
        "hr_tip": "Garis horisontal",
        "summary": "Ringkesan:",
-       "subject": "Subyek/judhul:",
+       "subject": "Subyèk:",
        "minoredit": "Kiye suntingan cilik",
        "watchthis": "Awasi kaca kiyé",
        "savearticle": "Terbitna Kaca",
        "cantcreateaccount-text": "Ngawe akun sekang alamat IP kiye ('''$1''') wis diblokir nang [[User:$3|$3]].\n\nAlesane miturut $3 yakuwe ''$2''",
        "viewpagelogs": "Deleng log-e kaca kiye",
        "nohistory": "Ora ana sajarah panyuntingan kanggo kaca kiye.",
-       "currentrev": "Revisi sekiye",
+       "currentrev": "Revisi sekiyé",
        "currentrev-asof": "Revisi paling anyar nang tanggal $1",
        "revisionasof": "Revisi per $1",
        "revision-info": "Revisi per $1; $2",
        "previousrevision": "Revisi sedurunge",
        "nextrevision": "Revisi lewih anyar",
-       "currentrevisionlink": "Revisi sekiye",
-       "cur": "sekiye",
+       "currentrevisionlink": "Revisi sekiyé",
+       "cur": "siki",
        "next": "Lanjutane",
        "last": "sedurunge",
        "page_first": "kapisan",
        "searchprofile-images": "Multimedia",
        "searchprofile-everything": "Kabèh",
        "searchprofile-advanced": "Lanjutan",
-       "searchprofile-articles-tooltip": "Panggolèkan nang $1",
+       "searchprofile-articles-tooltip": "Nggoléti neng $1",
        "searchprofile-images-tooltip": "Panggolèkan berkas",
        "searchprofile-everything-tooltip": "Goleti kabeh isi (termasuke kaca dhiskusi)",
        "searchprofile-advanced-tooltip": "Goleti nang bilik jeneng biasa",
        "rightslogtext": "Kiye log pangowahan maring hak-hak panganggo.",
        "action-read": "maca kaca kiye",
        "action-edit": "nyunting kaca kiye",
-       "action-createpage": "gawe kaca",
-       "action-createtalk": "nggawé kaca dhiskusi",
+       "action-createpage": "gawé kaca kiyé",
+       "action-createtalk": "gawé kaca dhiskusiné",
        "action-createaccount": "nggawé akun panganggo kiye",
        "action-minoredit": "nandani suntingan minangka suntingan cilik",
        "action-move": "mindahna kaca kiye",
        "filehist-deleteall": "busek kabeh",
        "filehist-deleteone": "busek",
        "filehist-revert": "balekna",
-       "filehist-current": "Sekiye",
+       "filehist-current": "siki",
        "filehist-datetime": "Tanggal/Wektu",
        "filehist-thumb": "Miniatur (''thumbnail'')",
        "filehist-thumbtext": "Miniatur nggo versi dong $1",
        "emailsenttext": "Pesen imele Rika wis dikirim.",
        "emailuserfooter": "Layang kiye dikirimna sekang $1 ming $2 nggunakna fungsi \"Layangpanganggo\" nang {{SITENAME}}.",
        "watchlist": "Daftar pangawasan",
-       "mywatchlist": "Daftar sawangané inyong",
+       "mywatchlist": "Daftar sawangan",
        "watchlistfor2": "Kanggo $1 $2",
        "watch": "Pantau",
        "unwatch": "Batalna pantauan",
        "contributions-title": "Kontribusi panganggo kanggo $1",
        "mycontris": "Kontribusi",
        "contribsub2": "Kanggo $1 ($2)",
-       "uctop": "(sekiye)",
+       "uctop": "(siki)",
        "month": "Sekang sasi (lan sadurungé):",
        "year": "Sekang taun (lan sadurunge):",
        "sp-contributions-newbies": "Tidokna kontribusine panganggo anyar thok",
index 257ad66..bb0bed3 100644 (file)
        "showdiff": "बदल दाखवा",
        "blankarticle": "<strong>ईशारा:</strong>आपण तयार करीत असलेले पान कोरे आहे.जर आपण पुन्हा \"$1\" टिचकले तर,कोणताही आशय/मजकूर नसलेले पान तयार होईल.",
        "anoneditwarning": "<strong>इशारा:</strong> तुम्ही विकिपीडियाचे सदस्य म्हणून सनोंद-प्रवेश (लॉग-इन) केलेले नाही.आपण काही संपादन केले तर, तुमचा अंकपत्ता (आयपी) सार्वजनिक रित्या दृष्य होईल. जर आपण <strong>[$1 सनोंद प्रवेश केला]</strong> किंवा <strong>[$2 खाते उघडले]</strong>,तर आपण केलेली संपादने ही आपल्या नांवाशी संलग्न होतील, त्याशिवाय याचे इतरही फायदे आहेत.",
-       "anonpreviewwarning": "\"'''सावधान:''' à¤¤à¥\81मà¥\8dहà¥\80 à¤µà¤¿à¤\95िपà¥\80डियाà¤\9aà¥\87 à¤¸à¤¦à¤¸à¥\8dय à¤®à¥\8dहणà¥\82न à¤¸à¤¨à¥\8bà¤\82द-पà¥\8dरवà¥\87श (लà¥\89à¤\97-à¤\87न) à¤\95à¥\87लà¥\87ला à¤¨à¤¾à¤¹à¥\80. à¤¯à¤¾ à¤ªà¤¾à¤¨à¤¾à¤\9aà¥\8dया à¤¸à¤\82पादन à¤\87तिहासात à¤¤à¥\81मà¤\9aा à¤\85à¤\82à¤\95पतà¥\8dता (à¤\86य.पà¥\80. à¥²ड्रेस) नोंदला जाईल.\"",
+       "anonpreviewwarning": "\"'''सावधान:''' à¤¤à¥\81मà¥\8dहà¥\80 à¤µà¤¿à¤\95िपà¥\80डियाà¤\9aà¥\87 à¤¸à¤¦à¤¸à¥\8dय à¤®à¥\8dहणà¥\82न à¤¸à¤¨à¥\8bà¤\82द-पà¥\8dरवà¥\87श (लà¥\89à¤\97-à¤\87न) à¤\95à¥\87लà¥\87ला à¤¨à¤¾à¤¹à¥\80. à¤¯à¤¾ à¤ªà¤¾à¤¨à¤¾à¤\9aà¥\8dया à¤¸à¤\82पादन à¤\87तिहासात à¤¤à¥\81मà¤\9aा à¤\85à¤\82à¤\95पतà¥\8dता (à¤\86य.पà¥\80. à¤\85à¥\85ड्रेस) नोंदला जाईल.\"",
        "missingsummary": "'''आठवण:''' आपण संपादन सारांश पुरवलेला नाही.आपण 'जतन करा' वर पुन्हा टिचकी मारली तर, ते त्याशिवायच जतन होईल.",
        "selfredirect": "<strong>ईशारा:</strong>आपण या पानास, त्याच पानावर पुनर्निर्देशित करीता आहात.\nआपण पुनर्निर्देशनासाठी चूकिचे लक्ष्य नमूद केले आहे किंवा आपण चूकिच्या पानाचे संपादन करीत आहात.\nजर आपण पुन्हा \"$1\" टिचकले तर, कसेहीकरुन ते पुनर्निर्देशन तयार होईल.",
        "missingcommenttext": "कृपया खाली प्रतिक्रिया भरा.",
        "action-rollback": "या आधीच्या सदस्याने नुकतेच संपादन केलेले एखादे विशिष्ट पानाचे बदल लवकर पूर्वस्थितीत न्या",
        "action-import": "दुसऱ्या विकीवरुन पाने आयात करा",
        "action-importupload": "अपभारीत संचिकेतून पाने आयात करा",
-       "action-patrol": "à¤\87तराà¤\82à¤\9aà¥\80 संपादनांवर 'पहारा दिला' म्हणून खूण करा",
+       "action-patrol": "à¤\87तराà¤\82à¤\9aà¥\8dया संपादनांवर 'पहारा दिला' म्हणून खूण करा",
        "action-autopatrol": "आपल्या संपादनांवर पहारा दिल्याची खूण करा",
        "action-unwatchedpages": "पहारा न दिलेल्या पानांची यादी पहा",
        "action-mergehistory": "पानाचा इतिहास विलीन करा",
        "timezone-local": "स्थानिक",
        "duplicate-defaultsort": "'''ताकिद:''' डिफॉल्ट सॉर्ट की \"$2\" ओवर्राइड्स अर्लीयर डिफॉल्ट सॉर्ट की \"$1\".",
        "version": "आवृत्ती",
-       "version-extensions": "सà¥\8dथापित à¤µà¤¿à¤¸à¥\8dतार",
+       "version-extensions": "यà¥\87थà¥\87 à¤¸à¥\8dथापलà¥\87लà¥\80 à¤µà¤¿à¤¸à¥\8dतारà¤\95à¥\87",
        "version-skins": "इंस्टॉल केल्या गेलेल्या त्वचा",
        "version-specialpages": "विशेष पाने",
        "version-parserhooks": "पृथकक अंकुश",
index b037fa6..7687415 100644 (file)
        "rcfilters-savedqueries-apply-and-setdefault-label": "Opprett standardfilter",
        "rcfilters-savedqueries-cancel-label": "Avbryt",
        "rcfilters-savedqueries-add-new-title": "Lagre de gjeldende filterinnstillingene",
+       "rcfilters-savedqueries-already-saved": "Disse filtrene er allerede lagret",
        "rcfilters-restore-default-filters": "Gjenopprett standardfiltre",
        "rcfilters-clear-all-filters": "Nullstill alle filtre",
        "rcfilters-show-new-changes": "Vis de nyeste endringene",
index a7cb8f8..d711feb 100644 (file)
        "cannotloginnow-title": "Niet mogelijk om aan te melden",
        "cannotloginnow-text": "Aanmelden is niet mogelijk bij het gebruik van $1.",
        "cannotcreateaccount-title": "Kan geen accounts aanmaken",
-       "cannotcreateaccount-text": "Direct aanmaken van een gebruiker is niet ingeschakeld op deze wiki.",
+       "cannotcreateaccount-text": "Direct aanmaken van een account is niet ingeschakeld op deze wiki.",
        "yourdomainname": "Uw domein:",
        "password-change-forbidden": "U kunt uw wachtwoord niet wijzigen in deze wiki.",
-       "externaldberror": "Er is een fout opgetreden bij het aanmelden bij de database of u hebt geen toestemming uw externe gebruiker bij te werken.",
+       "externaldberror": "Er is een fout opgetreden bij het aanmelden bij de database of u hebt geen toestemming om uw externe account bij te werken.",
        "login": "Aanmelden",
        "login-security": "Uw identiteit controleren",
        "nav-login-createaccount": "Aanmelden / registreren",
        "userlogin-helplink2": "Hulp bij aanmelden",
        "userlogin-loggedin": "U bent al aangemeld als {{GENDER:$1|$1}}.\nGebruik het onderstaande formulier om aan te melden als een andere gebruiker.",
        "userlogin-reauth": "U moet opnieuw inloggen om te bevestigen dat u {{GENDER:$1|$1}} bent.",
-       "userlogin-createanother": "Een andere account registreren",
+       "userlogin-createanother": "Een ander account aanmaken",
        "createacct-emailrequired": "E-mailadres",
        "createacct-emailoptional": "E-mailadres (optioneel)",
        "createacct-email-ph": "Geef uw e-mailadres op",
        "createacct-another-email-ph": "Geef een e-mailadres op",
        "createaccountmail": "Gebruik een tijdelijk willekeurig wachtwoord en stuur het naar het opgegeven e-mailadres",
-       "createaccountmail-help": "Kan worden gebruikt voor het aanmaken van een gebruiker voor een andere persoon zonder het wachtwoord te leren.",
+       "createaccountmail-help": "Kan worden gebruikt voor het aanmaken van een account voor een andere persoon zonder het wachtwoord te leren.",
        "createacct-realname": "Echte naam (optioneel)",
        "createacct-reason": "Reden",
-       "createacct-reason-ph": "Waarom u een andere account aanmaakt",
+       "createacct-reason-ph": "Waarom u een ander account aanmaakt",
        "createacct-reason-help": "Weergegeven bericht in het logbestand van aangemaakte gebruikers",
        "createacct-submit": "Account aanmaken",
        "createacct-another-submit": "Account aanmaken",
        "createacct-benefit-body2": "pagina{{PLURAL:$1||'s}}",
        "createacct-benefit-body3": "recente bijdrager{{PLURAL:$1||s}}",
        "badretype": "De ingevoerde wachtwoorden verschillen van elkaar.",
-       "usernameinprogress": "Het aanmaken van een gebruiker met die naam is al bezig.\nEven geduld alstublieft.",
+       "usernameinprogress": "Het aanmaken van een account met die naam is al bezig.\nEven geduld alstublieft.",
        "userexists": "De gekozen gebruikersnaam is al in gebruik.\nKies een andere naam.",
        "loginerror": "Aanmeldfout",
        "createacct-error": "Fout tijdens aanmaken account",
-       "createaccounterror": "Het was niet mogelijk de account aan te maken: $1",
-       "nocookiesnew": "De gebruiker is geregistreerd, maar niet aangemeld.\n{{SITENAME}} gebruikt cookies voor het aanmelden van gebruikers.\nSchakel die in en meld daarna aan met uw nieuwe gebruikersnaam en wachtwoord.",
+       "createaccounterror": "Het was niet mogelijk het account aan te maken: $1",
+       "nocookiesnew": "Het gebruikersaccount is aangemaakt, maar u bent niet aangemeld.\n{{SITENAME}} gebruikt cookies voor het aanmelden van gebruikers.\nSchakel die in en meld daarna aan met uw nieuwe gebruikersnaam en wachtwoord.",
        "nocookieslogin": "{{SITENAME}} gebruikt cookies voor het aanmelden van gebruikers.\nCookies zijn uitgeschakeld in uw browser.\nSchakel deze optie in en probeer het opnieuw.",
-       "nocookiesfornew": "De gebruiker is niet gemaakt omdat de bron niet bevestigd kon worden.\nZorg ervoor dat u cookies hebt ingeschakeld, herlaad deze pagina en probeer het opnieuw.",
-       "createacct-loginerror": "De gebruiker is succesvol aangemaakt, maar u kon niet automatisch worden aangemeld. Ga naar [[Special:UserLogin|handmatig aanmelden]].",
+       "nocookiesfornew": "Het gebruikersaccount is niet aangemaakt, omdat de bron niet bevestigd kon worden.\nZorg ervoor dat u cookies hebt ingeschakeld, herlaad deze pagina en probeer het opnieuw.",
+       "createacct-loginerror": "Het account is succesvol aangemaakt, maar u kon niet automatisch worden aangemeld. Ga naar [[Special:UserLogin|handmatig aanmelden]].",
        "noname": "U hebt geen geldige gebruikersnaam opgegeven.",
        "loginsuccesstitle": "Aangemeld",
        "loginsuccess": "<strong>U bent nu aangemeld bij {{SITENAME}} als \"$1\".</strong>",
-       "nosuchuser": "De gebruiker \"$1\" bestaat niet.\nGebruikersnamen zijn hoofdlettergevoelig.\nControleer de schrijfwijze of [[Special:CreateAccount|maak een nieuw gebruiker aan]].",
+       "nosuchuser": "De gebruiker \"$1\" bestaat niet.\nGebruikersnamen zijn hoofdlettergevoelig.\nControleer de schrijfwijze of [[Special:CreateAccount|maak een nieuw account aan]].",
        "nosuchusershort": "De gebruiker \"$1\" bestaat niet.\nControleer de schrijfwijze.",
        "nouserspecified": "Geef een gebruikersnaam op.",
        "login-userblocked": "Deze gebruiker is geblokkeerd.\nAanmelden is niet mogelijk.",
        "password-login-forbidden": "Het gebruik van deze gebruikersnaam met dit wachtwoord is niet toegestaan.",
        "mailmypassword": "Nieuw wachtwoord e-mailen",
        "passwordremindertitle": "Nieuw tijdelijk wachtwoord voor {{SITENAME}}",
-       "passwordremindertext": "Iemand, waarschijnlijk u, heeft vanaf IP-adres $1 een verzoek\ngedaan tot het toezenden van een nieuw wachtwoord voor {{SITENAME}}\n($4). Er is een tijdelijk wachtwoord aangemaakt voor gebruiker \"$2\":\n\"$3\". Als dat uw bedoeling was, meld u dan nu aan en kies een nieuw\nwachtwoord.\nUw tijdelijke wachtwoord vervalt over {{PLURAL:$5|$5 dag|$5 dagen}}.\n\nAls iemand anders dan u dit verzoek heeft gedaan of als u zich inmiddels het\nwachtwoord herinnert en het niet langer wilt wijzigen, negeer dit bericht\ndan en blijf uw bestaande wachtwoord gebruiken.",
+       "passwordremindertext": "Iemand, waarschijnlijk u, heeft vanaf IP-adres $1 een verzoek\ngedaan tot het toezenden van een nieuw wachtwoord voor {{SITENAME}}\n($4). Er is een tijdelijk wachtwoord aangemaakt voor gebruiker \"$2\":\n\"$3\". Als dat uw bedoeling was, meld u dan nu aan en kies een nieuw\nwachtwoord.\nUw tijdelijke wachtwoord vervalt over {{PLURAL:$5|één dag|$5 dagen}}.\n\nAls iemand anders dan u dit verzoek heeft gedaan, of als u zich het\nwachtwoord inmiddels herinnert en het niet langer wilt wijzigen, negeer\ndit bericht dan en blijf uw oude wachtwoord gebruiken.",
        "noemail": "Er is geen e-mailadres bekend voor gebruiker \"$1\".",
        "noemailcreate": "U moet een geldig e-mailadres opgeven",
        "passwordsent": "Het wachtwoord is verzonden naar het e-mailadres voor \"$1\".\nMeld u aan nadat u het hebt ontvangen.",
        "blocked-mailpassword": "Uw IP-adres is geblokkeerd voor het maken van wijzigingen. Om misbruik te voorkomen is het niet mogelijk om een nieuw wachtwoord aan te vragen.",
-       "eauthentsent": "Er is ter bevestiging een e-mail naar het opgegeven e-mailadres gezonden.\nVolg de aanwijzingen in de e-mail om aan te geven dat het uw e-mailadres is.\nTot die tijd worden er geen e-mails naar het e-mailadres gezonden.",
+       "eauthentsent": "Er is ter bevestiging een e-mail naar het opgegeven e-mailadres gezonden.\nVolg de aanwijzingen in de e-mail om te bevestigen dat het uw account is.\nTot die tijd wordt er geen andere e-mail naar het account gezonden.",
        "throttled-mailpassword": "In {{PLURAL:$1|het laatste uur|de laatste $1 uur}} is al een wachtwoordherinnering verzonden.\nOm misbruik te voorkomen wordt er slechts één wachtwoordherinnering per {{PLURAL:$1|uur|$1 uur}} verzonden.",
        "mailerror": "Fout bij het verzenden van e-mail: $1",
        "acct_creation_throttle_hit": "Bezoekers van deze wiki met hetzelfde IP-adres als u hebben de afgelopen $2 al {{PLURAL:$1|1 gebruiker|$1 gebruikers}} geregistreerd, wat het maximale toegestane aantal is voor deze periode.\nDaarom kunt u vanaf uw IP-adres op dit moment geen nieuwe gebruikers registreren.",
        "accountcreated": "Account aangemaakt",
        "accountcreatedtext": "Het gebruikersaccount [[{{ns:User}}:$1|$1]] ([[{{ns:User talk}}:$1|overleg]]) is aangemaakt.",
        "createaccount-title": "Gebruikers registreren voor {{SITENAME}}",
-       "createaccount-text": "Iemand heeft een gebruiker op {{SITENAME}} ($4) aangemaakt met de naam \"$2\" en uw e-mailadres.\nHet wachtwoord voor \"$2\" is \"$3\".\nMeld u aan en wijzig uw wachtwoord.\n\nNegeer dit bericht als deze gebruiker zonder uw medeweten is aangemaakt.",
+       "createaccount-text": "Iemand heeft een account voor uw e-mailadres op {{SITENAME}} ($4) aangemaakt genaamd \"$2\", met wachtwoord \"$3\".\nMeld u aan en wijzig uw wachtwoord.\n\nU kunt dit bericht negeren als dit account zonder uw medeweten is aangemaakt.",
        "login-throttled": "U heeft recentelijk te veel mislukte aanmeldpogingen gedaan.\nWacht alstublieft $1 voordat u het opnieuw probeert.",
        "login-abort-generic": "Uw aanmelding is mislukt - Afgebroken",
        "login-migrated-generic": "Uw gebruikersnaam is hernoemd, en uw gebruikersnaam bestaat niet langer op deze wiki.",
        "passwordreset-domain": "Domein:",
        "passwordreset-email": "E-mailadres:",
        "passwordreset-emailtitle": "Accountgegevens op {{SITENAME}}",
-       "passwordreset-emailtext-ip": "Iemand, waarschijnlijk u, heeft vanaf het IP-adres $1 een aanvraag gedaan om uw wachtwoord voor {{SITENAME}} ($4) opnieuw in te stellen. De volgende {{PLURAL:$3|gebruiker is|gebruikers zijn}} gekoppeld aan dit e-mailadres:\n\n$2\n\n{{PLURAL:$3|Dit tijdelijke wachtwoord vervalt|Deze tijdelijke wachtwoorden vervallen}} over {{PLURAL:$5|een dag|$5 dagen}}. Meld u aan en wijzig het wachtwoord nu. Als u dit verzoek niet zelf heeft gedaan, of als u het oorspronkelijke wachtwoord nog kent en het niet wilt wijzigen, negeer dit bericht dan en blijf uw oude wachtwoord gebruiken.",
-       "passwordreset-emailtext-user": "Gebruiker $1 op de site {{SITENAME}} heeft een aanvraag gedaan om uw wachtwoord voor {{SITENAME}} ($4) opnieuw in te stellen. De volgende {{PLURAL:$3|gebruiker is|gebruikers zijn}} gekoppeld aan dit e-mailadres:\n\n$2\n\n{{PLURAL:$3|Dit tijdelijke wachtwoord vervalt|Deze tijdelijke wachtwoorden vervallen}} over {{PLURAL:$5|een dag|$5 dagen}}.\nMeld u aan en wijzig het wachtwoord nu. Als u dit verzoek niet zelf heeft gedaan, of als u het oorspronkelijke wachtwoord nog kent en het niet wilt wijzigen, negeer dit bericht dan en blijf uw oude wachtwoord gebruiken.",
+       "passwordreset-emailtext-ip": "Iemand (waarschijnlijk u, vanaf IP-adres $1) heeft een aanvraag gedaan om uw wachtwoord voor {{SITENAME}} ($4) opnieuw in te stellen. {{PLURAL:$3|Het volgende gebruikersaccount is|De volgende gebruikersaccounts zijn}} gekoppeld aan dit e-mailadres:\n\n$2\n\n{{PLURAL:$3|Dit tijdelijke wachtwoord vervalt|Deze tijdelijke wachtwoorden vervallen}} over {{PLURAL:$5|een dag|$5 dagen}}. Meld u aan en wijzig het wachtwoord nu. Als u dit verzoek niet zelf heeft gedaan, of als u het oorspronkelijke wachtwoord nog kent en het niet wilt wijzigen, negeer dit bericht dan en blijf uw oude wachtwoord gebruiken.",
+       "passwordreset-emailtext-user": "Gebruiker $1 op {{SITENAME}} heeft een aanvraag gedaan om uw wachtwoord voor {{SITENAME}} ($4) opnieuw in te stellen. {{PLURAL:$3|Het volgende gebruikersaccount is|De volgende gebruikersaccounts zijn}} gekoppeld aan dit e-mailadres:\n\n$2\n\n{{PLURAL:$3|Dit tijdelijke wachtwoord vervalt|Deze tijdelijke wachtwoorden vervallen}} over {{PLURAL:$5|een dag|$5 dagen}}.\nMeld u aan en wijzig het wachtwoord nu. Als u dit verzoek niet zelf heeft gedaan, of als u het oorspronkelijke wachtwoord nog kent en het niet wilt wijzigen, negeer dit bericht dan en blijf uw oude wachtwoord gebruiken.",
        "passwordreset-emailelement": "Gebruikersnaam: \n$1\n\nTijdelijk wachtwoord: \n$2",
        "passwordreset-emailsentemail": "Als dit e-mailadres aan uw account gekoppeld is, dan wordt er een e-mail verzonden om uw wachtwoord opnieuw in te stellen.",
        "passwordreset-emailsentusername": "Als er een e-mailadres geregistreerd is voor die gebruikersnaam, dan wordt er een e-mail verzonden om uw wachtwoord opnieuw in te stellen.",
        "showpreview": "Bewerking ter controle bekijken",
        "showdiff": "Wijzigingen bekijken",
        "blankarticle": "<strong>Waarschuwing:</strong> de pagina die u wilt aanmaken is leeg.\nAls u opnieuw op \"$1\" klikt, wordt de pagina aangemaakt zonder enige inhoud.",
-       "anoneditwarning": "<strong>Waarschuwing:</strong> u bent niet aangemeld.\nUw IP-adres wordt opgeslagen als u wijzigingen op deze pagina maakt. Wanneer u <strong>[$1 aanmeldt]</strong> of <strong>[$2 een gebruiker aanmaakt]</strong> verschijnen uw bewerkingen onder uw gebruikersnaam, naast andere voordelen.",
+       "anoneditwarning": "<strong>Waarschuwing:</strong> U bent niet aangemeld.\nUw IP-adres zal voor iedereen zichtbaar zijn als u wijzigingen op deze pagina maakt. Wanneer u <strong>[$1 zich aanmeldt]</strong> of <strong>[$2 een account aanmaakt]</strong>, verschijnen uw bewerkingen onder uw gebruikersnaam, naast andere voordelen.",
        "anonpreviewwarning": "''U bent niet aangemeld.''\n''Door uw bewerking op te slaan wordt uw IP-adres opgeslagen in de paginageschiedenis.''",
        "missingsummary": "'''Let op:''' u hebt geen bewerkingssamenvatting opgegeven.\nAls u nogmaals op \"$1\" klikt wordt de bewerking zonder samenvatting opgeslagen.",
        "selfredirect": "<strong>Waarschuwing:</strong> U heeft een doorverwijzing gemaakt naar deze pagina. Mogelijk heeft u de verkeerde bestemming voor de doorverwijzing gebruikt, of bewerkt u de verkeerde pagina. Door nogmaals op \"$1\" te klikken word de doorverwijzing alsnog aangemaakt.",
        "subject-preview": "Voorvertoning van het onderwerp:",
        "previewerrortext": "Er is een fout opgetreden tijdens het weergeven van uw wijzigingen.",
        "blockedtitle": "Gebruiker is geblokkeerd",
-       "blockedtext": "'''Uw gebruiker of IP-adres is geblokkeerd.'''\n\nDe blokkade is uitgevoerd door $1.\nDe opgegeven reden is ''$2''.\n\n* Aanvang blokkade: $8\n* Einde blokkade: $6\n* Bedoeld te blokkeren: $7\n\nU kunt contact opnemen met $1 of een andere [[{{MediaWiki:Grouppage-sysop}}|beheerder]] om de blokkade te bespreken.\nU kunt geen gebruik maken van de functie \"Deze gebruiker e-mailen\", tenzij u een geldig e-mailadres hebt opgegeven in uw [[Special:Preferences|voorkeuren]] en het gebruik van deze functie niet geblokkeerd is.\nUw huidige IP-adres is $3 en het blokkadenummer is #$5.\nVermeld alle bovenstaande gegevens als u ergens op deze blokkade reageert.",
-       "autoblockedtext": "Uw IP-adres is automatisch geblokkeerd, omdat het is gebruikt door een andere gebruiker, die is geblokkeerd door $1.\nDe opgegeven reden is:\n\n:''$2''\n\n* Aanvang blokkade: $8\n* Einde blokkade: $6\n* Bedoeld te blokkeren: $7\n\nU kunt deze blokkade bespreken met $1 of een andere [[{{MediaWiki:Grouppage-sysop}}|beheerder]].\n\nU kunt geen gebruik maken van de functie \"Deze gebruiker e-mailen\", tenzij u een geldig e-mailadres hebt opgegeven in uw [[Special:Preferences|voorkeuren]] en het gebruik van deze functie niet is geblokkeerd.\n\nUw huidige IP-adres is $3 en het blokkadenummer is #$5.\nVermeld alle bovenstaande gegevens als u ergens op deze blokkade reageert.",
-       "systemblockedtext": "Uw gebruikersnaam of IP-adres is automatisch geblokkeerd door MediaWiki.\nDe opgegeven reden is:\n\n:<em>$2</em>\n\n* Aanvang blokkade: $8\n* Einde blokkade: $6\n* Bedoeld te blokkeren: $7\n\nUw huidige IP-adres is $3.\nVermeld alle bovenstaande gegevens in een query die u maakt.",
+       "blockedtext": "'''Uw gebruikersaccount of IP-adres is geblokkeerd.'''\n\nDe blokkade is uitgevoerd door $1.\nDe opgegeven reden is ''$2''.\n\n* Aanvang blokkade: $8\n* Einde blokkade: $6\n* Bedoeld te blokkeren: $7\n\nU kunt contact opnemen met $1 of een andere [[{{MediaWiki:Grouppage-sysop}}|beheerder]] om de blokkade te bespreken.\nU kunt geen gebruik maken van de functie \"Deze gebruiker e-mailen\", tenzij u een geldig e-mailadres hebt opgegeven in uw [[Special:Preferences|voorkeuren]] en het gebruik van deze functie niet geblokkeerd is.\nUw huidige IP-adres is $3 en het blokkadenummer is #$5.\nVermeld alle bovenstaande gegevens als u ergens op deze blokkade reageert.",
+       "autoblockedtext": "Uw IP-adres is automatisch geblokkeerd, omdat het gebruikt is door een andere gebruiker, die geblokkeerd is door $1.\nDe opgegeven reden is:\n\n:''$2''\n\n* Aanvang blokkade: $8\n* Einde blokkade: $6\n* Bedoeld te blokkeren: $7\n\nU kunt contact opnemen met $1 of een andere [[{{MediaWiki:Grouppage-sysop}}|beheerder]] om de blokkade te bespreken.\n\nU kunt geen gebruik maken van de functie \"Deze gebruiker e-mailen\", tenzij u een geldig e-mailadres hebt opgegeven in uw [[Special:Preferences|voorkeuren]] en het gebruik van deze functie niet geblokkeerd is.\n\nUw huidige IP-adres is $3 en het blokkadenummer is #$5.\nVermeld alle bovenstaande gegevens als u ergens op deze blokkade reageert.",
+       "systemblockedtext": "Uw gebruikersaccount of IP-adres is automatisch geblokkeerd door MediaWiki.\nDe opgegeven reden is:\n\n:<em>$2</em>\n\n* Aanvang blokkade: $8\n* Einde blokkade: $6\n* Bedoeld te blokkeren: $7\n\nUw huidige IP-adres is $3.\nVermeld alle bovenstaande gegevens als u ergens op deze blokkade reageert.",
        "blockednoreason": "geen reden opgegeven",
        "whitelistedittext": "U moet $1 om pagina's te bewerken.",
        "confirmedittext": "U moet uw e-mailadres bevestigen voor u kunt bewerken.\nVoer uw e-mailadres in en bevestig het via uw [[Special:Preferences|voorkeuren]].",
        "accmailtext": "Een willekeurig gegenereerd wachtwoord voor [[User talk:$1|$1]] is verzonden naar $2. Het kan worden gewijzigd op de pagina \"[[Special:ChangePassword|wachtwoord wijzigen]]\" na het aanmelden.",
        "newarticle": "(Nieuw)",
        "newarticletext": "Deze pagina bestaat niet.\nTyp in het onderstaande veld om de pagina aan te maken (meer informatie staat op de [$1 hulppagina]).\nGebruik de knop <strong>Terug</strong> in uw browser als u hier per ongeluk terecht bent gekomen.",
-       "anontalkpagetext": "----\n<em>Deze overlegpagina hoort bij een anonieme gebruiker die geen gebruikersnaam heeft of deze niet gebruikt.</em>\nDaarom wordt het IP-adres ter identificatie gebruikt.\nHet is mogelijk dat meerdere personen hetzelfde IP-adres gebruiken.\nMogelijk ontvangt u hier berichten die niet voor u bedoeld zijn.\nAls u dat wilt voorkomen, [[Special:CreateAccount|registreer u]] of [[Special:UserLogin|meld u aan]] om verwarring met andere anonieme gebruikers te voorkomen.",
+       "anontalkpagetext": "----\n<em>Deze overlegpagina hoort bij een anonieme gebruiker die nog geen account heeft aangemaakt, of het niet gebruikt.</em>\nDaarom wordt het IP-adres ter identificatie gebruikt.\nHet is mogelijk dat meerdere personen hetzelfde IP-adres gebruiken.\nMogelijk ontvangt u hier berichten die niet voor u bedoeld zijn.\nAls u dat wilt voorkomen, [[Special:CreateAccount|registreer u]] of [[Special:UserLogin|meld u aan]] om verwarring met andere anonieme gebruikers te voorkomen.",
        "noarticletext": "Deze pagina bevat geen tekst.\nU kunt [[Special:Search/{{PAGENAME}}|naar deze term zoeken]] in andere pagina's, <span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} de logboeken doorzoeken] of [{{fullurl:{{FULLPAGENAME}}|action=edit}} deze pagina aanmaken]</span>.",
        "noarticletext-nopermission": "Deze pagina bevat geen tekst.\nU kunt [[Special:Search/{{PAGENAME}}|naar deze term zoeken]] in andere pagina's of\n<span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} de logboeken doorzoeken]</span>, maar u mag de pagina niet aanmaken.",
        "missing-revision": "De versie #$1 van de pagina \"{{FULLPAGENAME}}\" bestaat niet.\n\nDit wordt meestal veroorzaakt door het volgen van een verouderde koppeling naar een pagina die is verwijderd.\nMeer gegevens zijn mogelijk te vinden in het [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} verwijderingslogboek].",
-       "userpage-userdoesnotexist": "U bewerkt een gebruikerspagina van een gebruiker die niet bestaat (gebruiker \"$1\").\nControleer of u deze pagina wel wilt aanmaken of bewerken.",
-       "userpage-userdoesnotexist-view": "De gebruiker \"$1\" is niet geregistreerd.",
-       "blocked-notice-logextract": "Deze gebruiker is op het moment geblokkeerd.\nDe laatste regel uit het blokkeerlogboek wordt hieronder ter referentie weergegeven:",
+       "userpage-userdoesnotexist": "Gebruikersaccount \"$1\" bestaat niet.\nControleer of u deze pagina wel wilt aanmaken/bewerken.",
+       "userpage-userdoesnotexist-view": "Gebruikersaccount \"$1\" is niet geregistreerd.",
+       "blocked-notice-logextract": "Deze gebruiker is momenteel geblokkeerd.\nDe laatste regel uit het blokkeerlogboek wordt hieronder ter referentie weergegeven:",
        "clearyourcache": "<strong>Opmerking:</strong> nadat u de wijzigingen hebt opgeslagen is het wellicht nodig uw browsercache te legen.\n* <strong>Firefox / Safari:</strong> houd <em>Shift</em> ingedrukt terwijl u op <em>Vernieuwen</em> klikt of druk op <em>Ctrl-F5</em> of <em>Ctrl-R</em> (<em>⌘-Shift-R</em> op een Mac)\n* <strong>Google Chrome:</strong> druk op <em>Ctrl-Shift-R</em> (<em>⌘-Shift-R</em> op een Mac)\n* <strong>Internet Explorer:</strong> houd <em>Ctrl</em> ingedrukt terwijl u op <em>Vernieuwen</em> klikt of druk op <em>Ctrl-F5</em>\n* '''Opera:''' ga naar <em>Menu → Instellingen</em> (<em>Opera → Voorkeuren</em> op een Mac) en daarna naar <em>Privacy & beveiliging → Browsegegevens wissen... →  Tijdelijk opgeslgen afbeeldingen en bestanden</em>.",
        "usercssyoucanpreview": "'''Tip:''' gebruik de knop \"{{int:showpreview}}\" om uw nieuwe CSS te testen alvorens op te slaan.",
        "userjsyoucanpreview": "'''Tip:''' gebruik de knop \"{{int:showpreview}}\" om uw nieuwe JavaScript te testen alvorens op te slaan.",
        "yourlanguage": "Taal:",
        "yourvariant": "Taalvariant voor inhoud:",
        "prefs-help-variant": "Uw voorkeursvariant of -spelling om de inhoudspagina's van deze wiki in weer te geven.",
-       "yournick": "Tekst voor ondertekening:",
-       "prefs-help-signature": "Reacties op de overlegpagina's worden meestal ondertekend met \"<nowiki>~~~~</nowiki>\".\nDe tildes worden omgezet in uw ondertekening en een datum en tijd van de bewerking.",
+       "yournick": "Tekst voor handtekening:",
+       "prefs-help-signature": "Reacties op de overlegpagina's worden meestal ondertekend met \"<nowiki>~~~~</nowiki>\".\nDe tildes worden omgezet in uw handtekening en de datum en tijd van de bewerking.",
        "badsig": "Ongeldige ondertekening; controleer de HTML-labels.",
        "badsiglength": "Uw ondertekening is te lang.\nDeze moet minder dan $1 {{PLURAL:$1|teken|tekens}} bevatten.",
        "yourgender": "Hoe wilt u beschreven worden?",
        "email": "E-mail",
        "prefs-help-realname": "Echte naam is optioneel.\nAls u deze opgeeft, kan deze naam gebruikt worden om u erkenning te geven voor uw werk.",
        "prefs-help-email": "E-mailadres is optioneel, maar maakt het mogelijk om u uw wachtwoord te e-mailen als u het bent vergeten.",
-       "prefs-help-email-others": "U kunt ook anderen in staat stellen per e-mail contact met u op te nemen via een koppeling op uw gebruikers- en overlegpagina zonder dat u uw identiteit prijsgeeft.",
+       "prefs-help-email-others": "U kunt ook anderen in staat stellen per e-mail contact met u op te nemen via een koppeling op uw gebruikers- en overlegpagina.\nUw e-mailadres wordt niet prijsgegeven als andere gebruikers contact met u opnemen.",
        "prefs-help-email-required": "Hiervoor is een e-mailadres nodig.",
        "prefs-info": "Basisgegevens",
        "prefs-i18n": "Taalinstellingen",
-       "prefs-signature": "Ondertekening",
+       "prefs-signature": "Handtekening",
        "prefs-dateformat": "Datumopmaak",
        "prefs-timeoffset": "Tijdverschil",
        "prefs-advancedediting": "Algemene instellingen",
        "saveusergroups": "{{GENDER:$1|Gebruikersgroepen}} opslaan",
        "userrights-groupsmember": "Lid van:",
        "userrights-groupsmember-auto": "Impliciet lid van:",
-       "userrights-groups-help": "U kunt de groepen wijzigen waar deze gebruiker lid van is.\n* Een aangekruist vakje betekent dat de gebruiker lid is van de groep.\n* Een niet aangekruist vakje betekent dat de gebruiker geen lid is van de groep.\n* Een \"*\" betekent dat u een gebruiker niet uit een groep kunt verwijderen nadat u die hebt toegevoegd of vice versa.\n* Een \"#\" betekent dat u dit groepslidmaatschap alleen kunt verlengen. U kunt het niet verkorten.",
+       "userrights-groups-help": "U kunt de groepen wijzigen waar deze gebruiker lid van is:\n* Een aangekruist vakje betekent dat de gebruiker lid is van de groep.\n* Een niet aangekruist vakje betekent dat de gebruiker geen lid is van de groep.\n* Een \"*\" betekent dat u een gebruiker niet uit een groep kunt verwijderen nadat u die hebt toegevoegd of vice versa.\n* Een \"#\" betekent dat u dit groepslidmaatschap alleen kunt verlengen; u kunt het niet verkorten.",
        "userrights-reason": "Reden:",
        "userrights-no-interwiki": "U hebt geen rechten om gebruikersrechten op andere wiki's te wijzigen.",
        "userrights-nodatabase": "De database $1 bestaat niet of is geen lokale database.",
        "right-edit": "Pagina's bewerken",
        "right-createpage": "Pagina's aanmaken",
        "right-createtalk": "Overlegpagina's aanmaken",
-       "right-createaccount": "Nieuwe gebruikers aanmaken",
+       "right-createaccount": "Nieuwe gebruikersaccounts aanmaken",
        "right-autocreateaccount": "Automatisch aanmelden met een extern gebruikersaccount",
        "right-minoredit": "Bewerkingen als klein markeren",
        "right-move": "Pagina's hernoemen",
        "action-edit": "deze pagina te bewerken",
        "action-createpage": "deze pagina aan te maken",
        "action-createtalk": "deze overlegpagina aan te maken",
-       "action-createaccount": "deze gebruiker aan te maken",
-       "action-autocreateaccount": "dit externe gebruikersaccount automatisch aanmaken",
+       "action-createaccount": "dit gebruikersaccount aan te maken",
+       "action-autocreateaccount": "dit externe gebruikersaccount automatisch aan te maken",
        "action-history": "de geschiedenis van deze pagina te bekijken",
        "action-minoredit": "deze bewerking als klein te markeren",
        "action-move": "deze pagina te hernoemen",
        "rcfilters-savedqueries-apply-and-setdefault-label": "Standaard filter aanmaken",
        "rcfilters-savedqueries-cancel-label": "Annuleren",
        "rcfilters-savedqueries-add-new-title": "Huidige filter instellingen opslaan",
+       "rcfilters-savedqueries-already-saved": "Deze filters zijn al opgeslagen",
        "rcfilters-restore-default-filters": "Standaard filters terugzetten",
        "rcfilters-clear-all-filters": "Alle filters verwijderen",
        "rcfilters-show-new-changes": "Toon nieuwste wijzigingen",
        "zip-bad": "Het bestand is een beschadigd of onleesbaar ZIP-bestand.\nDe veiligheid kan niet worden gecontroleerd.",
        "zip-unsupported": "Het bestand is een ZIP-bestand dat gebruik maakt van ZIP-mogelijkheden die MediaWiki niet ondersteunt.\nDe veiligheid kan niet worden gecontroleerd.",
        "uploadstash": "Verborgen uploads",
-       "uploadstash-summary": "Deze pagina biedt toegang tot bestanden die geüpload zijn of nog geüpload worden maar nog niet beschikbaar gemaakt zijn in de wiki. Deze bestanden zijn alleen zichtbaar voor de gebruiker die ze uploadt.",
+       "uploadstash-summary": "Deze pagina biedt toegang tot bestanden die geüpload zijn of nu geüpload worden, maar nog niet beschikbaar gemaakt zijn in de wiki. Deze bestanden zijn alleen zichtbaar voor de gebruiker die ze heeft geüpload.",
        "uploadstash-clear": "Verborgen bestanden weggooien",
        "uploadstash-nofiles": "Er zijn geen verborgen bestanden.",
        "uploadstash-badtoken": "Het uitvoeren van de handeling is mislukt, mogelijk doordat uw bewerkingsreferenties zijn verlopen. Probeer het opnieuw.",
        "log": "Logboeken",
        "logeventslist-submit": "Weergeven",
        "all-logs-page": "Alle openbare logboeken",
-       "alllogstext": "Dit is het gecombineerde logboek van {{SITENAME}}.\nU kunt ook kiezen voor specifieke logboeken en filteren op gebruiker (hoofdlettergevoelig) en paginanaam (hoofdlettergevoelig).",
+       "alllogstext": "Dit is het gecombineerde logboek van {{SITENAME}}.\nU kunt de lijst filteren door een specifiek logboektype te selecteren, of de gebruikersnaam (hoofdlettergevoelig) of paginatitel (tevens hoofdlettergevoelig) in te geven.",
        "logempty": "Er zijn geen regels in het logboek die voldoen aan deze criteria.",
        "log-title-wildcard": "Pagina's zoeken die met deze tekens beginnen",
        "showhideselectedlogentries": "Geselecteerde logboekregels weergeven of verbergen",
        "listgrouprights-namespaceprotection-namespace": "Naamruimte",
        "listgrouprights-namespaceprotection-restrictedto": "Recht(en) waardoor gebruiker kan bewerken",
        "listgrants": "Toestemmingen",
-       "listgrants-summary": "Hieronder staat een lijst met toestemmingen en de bijbehorende gebruikersrechten. Gebruikers kunnen toepassingen machtigen voor toegang tot hun gebruikers, maar met beperkte rechten gebaseerd op de toestemmingen die de gebruiker aan de toepassing heeft gegeven. Een toepassing die namens een gebruiker handelt, kan nooit rechten gebruiken die een gebruiker niet heeft.\nEr zijn mogelijk [[{{MediaWiki:Listgrouprights-helppage}}|aanvullende  gegevens]] over individuele rechten.",
+       "listgrants-summary": "Hieronder staat een lijst met toestemmingen en de bijbehorende gebruikersrechten. Gebruikers kunnen toepassingen machtigen voor toegang tot hun account, maar met beperkte rechten gebaseerd op de toestemmingen die de gebruiker aan de toepassing heeft gegeven. Een toepassing die namens een gebruiker handelt, kan nooit rechten gebruiken die een gebruiker niet heeft.\nEr zijn mogelijk [[{{MediaWiki:Listgrouprights-helppage}}|aanvullende  gegevens]] over individuele rechten.",
        "listgrants-grant": "Toestemming",
        "listgrants-rights": "Rechten",
        "trackingcategories": "Volgcategorieën",
        "emailuser-title-notarget": "Gebruiker e-mailen",
        "emailpagetext": "Via dit formulier kunt u een e-mail aan {{GENDER:$1|deze gebruiker}} verzenden.\nHet e-mailadres dat u hebt opgegeven bij [[Special:Preferences|uw voorkeuren]] wordt als afzender gebruikt.\nDe ontvanger kan dus direct naar u reageren.",
        "defemailsubject": "E-mail van {{SITENAME}}-gebruiker \"$1\"",
-       "usermaildisabled": "Gebruikerse-mail uitgeschakeld",
+       "usermaildisabled": "Gebruikers-e-mail uitgeschakeld",
        "usermaildisabledtext": "U kunt geen e-mail verzenden naar andere gebruikers op deze wiki",
        "noemailtitle": "Van deze gebruiker is geen e-mailadres bekend",
        "noemailtext": "Deze gebruiker heeft geen geldig e-mailadres opgegeven.",
        "unwatchthispage": "Niet meer volgen",
        "notanarticle": "Is geen pagina",
        "notvisiblerev": "De laatste versie van een andere gebruiker is verwijderd",
-       "watchlist-details": "Er {{PLURAL:$1|staat één pagina|staan $1 pagina's}} op uw volglijst (inclusief overlegpagina's).",
+       "watchlist-details": "Er {{PLURAL:$1|staat één pagina|staan $1 pagina's}} op uw volglijst (plus overlegpagina's).",
        "wlheader-enotif": "U wordt per e-mail gewaarschuwd.",
        "wlheader-showupdated": "Pagina's die zijn bewerkt sinds uw laatste bezoek worden '''vet''' weergegeven.",
        "wlnote": "Hieronder {{PLURAL:$1|staat de laaste wijziging|staan de laatste $1 wijzigingen}} in {{PLURAL:$2|het laatste uur|de laatste $2 uur}} per $3 om $4.",
        "sp-contributions-logs": "logboeken",
        "sp-contributions-talk": "overleg",
        "sp-contributions-userrights": "{{GENDER:$1|gebruikersrechtenbeheer}}",
-       "sp-contributions-blocked-notice": "Deze gebruiker is op het moment geblokkeerd.\nDe laatste regel uit het blokkeerlogboek wordt hieronder ter referentie weergegeven:",
+       "sp-contributions-blocked-notice": "Deze gebruiker is momenteel geblokkeerd.\nDe laatste regel uit het blokkeerlogboek wordt hieronder ter referentie weergegeven:",
        "sp-contributions-blocked-notice-anon": "Dit IP-adres is geblokkeerd.\nDe laatste regel uit het blokkeerlogboek wordt hieronder ter referentie weergegeven:",
        "sp-contributions-search": "Zoeken naar bijdragen",
        "sp-contributions-username": "IP-adres of gebruikersnaam:",
        "ipbexpiry": "Vervalt (maak een keuze):",
        "ipbreason": "Reden:",
        "ipbreason-dropdown": "*Veelvoorkomende redenen voor blokkades\n** Foutieve informatie invoeren\n** Verwijderen van informatie uit pagina's\n** Spamkoppeling naar externe websites\n** Invoegen van nonsens in pagina's\n** Intimiderend gedrag\n** Misbruik door meerdere gebruikers\n** Onaanvaardbare gebruikersnaam",
-       "ipb-hardblock": "Voorkomen dat aangemelde gebruikers vanaf dit IP-adres kunnen bewerken",
+       "ipb-hardblock": "Aangemelde gebruikers de mogelijkheid ontnemen om vanaf dit IP-adres te bewerken",
        "ipbcreateaccount": "Registreren accounts blokkeren",
-       "ipbemailban": "Gebruiker weerhouden van het sturen van e-mail",
-       "ipbenableautoblock": "Automatisch de IP-adressen van deze gebruiker blokkeren",
+       "ipbemailban": "Gebruiker de mogelijkheid ontnemen om e-mail te versturen",
+       "ipbenableautoblock": "Automatisch het laatste IP-adres van deze gebruiker blokkeren, en alle volgende IP-adressen waarvandaan degene probeert te bewerken",
        "ipbsubmit": "Deze gebruiker blokkeren",
        "ipbother": "Andere duur:",
        "ipboptions": "2 uur:2 hours,1 dag:1 day,3 dagen:3 days,1 week:1 week,2 weken:2 weeks,1 maand:1 month,3 maanden:3 months,6 maanden:6 months,1 jaar:1 year,onbepaald:infinite",
-       "ipbhidename": "Gebruiker in bewerkingen en lijsten verbergen",
-       "ipbwatchuser": "Gebruikerspagina en overlegpagina op volglijst plaatsen",
-       "ipb-disableusertalk": "Voorkomen dat deze gebruiker tijdens de blokkade de eigen overlegpagina kan bewerken",
+       "ipbhidename": "Gebruikersnaam in bewerkingen en lijsten verbergen",
+       "ipbwatchuser": "Gebruikerspagina en overlegpagina van deze gebruiker op de volglijst plaatsen",
+       "ipb-disableusertalk": "Deze gebruiker de mogelijkheid ontnemen om tijdens de blokkade de eigen overlegpagina te bewerken",
        "ipb-change-block": "De gebruiker opnieuw blokkeren met deze instellingen",
        "ipb-confirm": "Blokkade bevestigen",
        "badipaddress": "Geen geldig IP-adres",
        "blockipsuccesssub": "De blokkering is ingesteld",
        "blockipsuccesstext": "[[Special:Contributions/$1|$1]] is geblokkeerd.<br />\nZie de [[Special:BlockList|blokkadelijst]] voor recente blokkades.",
        "ipb-blockingself": "U staat op het punt uzelf te blokkeren. Weet u zeker dat u dat wilt doen?",
-       "ipb-confirmhideuser": "U staat op het punt een verborgen gebruiker te blokkeren. Hiervoor worden gebruikersnamen in alle lijsten en logboekregels verborgen. Weet u het zeker?",
+       "ipb-confirmhideuser": "U staat op het punt een verborgen gebruiker te blokkeren. Hiermee wordt de gebruikersnaam in alle lijsten en logboekregels verborgen. Weet u het zeker?",
        "ipb-confirmaction": "Weet u zeker dat u dit wilt doen? Selecteer dan het selectievakje \"{{int:ipb-confirm}}\" hieronder.",
        "ipb-edit-dropdown": "Lijst van redenen bewerken",
        "ipb-unblock-addr": "$1 deblokkeren",
        "ipb_expiry_invalid": "Ongeldige duur.",
        "ipb_expiry_old": "Vervaldatum is in het verleden.",
        "ipb_expiry_temp": "Blokkades voor verborgen gebruikers moeten permanent zijn.",
-       "ipb_hide_invalid": "Het is niet mogelijk deze gebruiker te verbergen; deze heeft meer dan {{PLURAL:$1|een bewerking|$1 bewerkingen}} uitgevoerd.",
+       "ipb_hide_invalid": "Het is niet mogelijk dit account te verbergen; het heeft meer dan {{PLURAL:$1|een bewerking|$1 bewerkingen}}.",
        "ipb_already_blocked": "\"$1\" is al geblokkeerd",
        "ipb-needreblock": "$1 is al geblokkeerd.\nWilt u de instellingen wijzigen?",
        "ipb-otherblocks-header": "Andere {{PLURAL:$1|blokkade|blokkades}}",
        "proxyblocker": "Proxyblocker",
        "proxyblockreason": "Uw IP-adres is geblokkeerd, omdat u gebruik maakt van een open proxyserver.\nNeem contact op met uw internetprovider of uw helpdesk en stel die op de hoogte van dit ernstige beveiligingsprobleem.",
        "sorbsreason": "Uw IP-adres staat bekend als open proxyserver in de DNS-blacklist die {{SITENAME}} gebruikt.",
-       "sorbs_create_account_reason": "Uw IP-adres staat bekend als open proxyserver in de DNS-blacklist die {{SITENAME}} gebruikt.\nU kunt geen gebruiker registreren.",
+       "sorbs_create_account_reason": "Uw IP-adres staat bekend als open proxyserver in de DNS-blacklist die {{SITENAME}} gebruikt.\nU kunt geen account aanmaken.",
        "softblockrangesreason": "Anonieme bijdragen zijn niet toegestaan op basis van uw IP-adres ($1). Gelieve in te loggen.",
        "xffblockreason": "Een IP-adres dat u gebruikt is geblokkeerd. Dit staat de X-Forwarded-For van de header. De oorspronkelijke blokkadereden is: $1",
        "cant-see-hidden-user": "De gebruiker die u probeert te blokken is al geblokkeerd en verborgen.\nOmdat u het recht \"hideuser\" niet hebt, kunt u de blokkade van de gebruiker niet bekijken of bewerken.",
        "confirmemail": "E-mailadres bevestigen",
        "confirmemail_noemail": "U hebt geen geldig e-mailadres opgegeven in uw [[Special:Preferences|gebruikersvoorkeuren]].",
        "confirmemail_text": "{{SITENAME}} eist bevestiging van uw e-mailadres voordat u de e-mailmogelijkheden kunt gebruiken.\nKlik op de onderstaande knop om een bevestigingsbericht te ontvangen.\nDit bericht bevat een koppeling met een code.\nOpen die koppeling om uw e-mailadres te bevestigen.",
-       "confirmemail_pending": "Er is al een bevestigingsbericht aan u verzonden.\nAls u recentelijk uw gebruiker hebt aangemaakt, wacht dan een paar minuten totdat die aankomt voordat u opnieuw een e-mail laat sturen.",
+       "confirmemail_pending": "Er is al een bevestigingsbericht aan u verzonden.\nAls u recentelijk uw account hebt aangemaakt, wacht dan een paar minuten totdat het bericht aankomt voordat u opnieuw een e-mail laat sturen.",
        "confirmemail_send": "Een bevestigingscode verzenden",
        "confirmemail_sent": "Bevestigingscode verzonden.",
        "confirmemail_oncreate": "Er is een bevestigingscode naar uw e-mailadres verzonden.\nDeze code is niet nodig om u aan te melden, maar u dient deze wel te bevestigen voordat u de e-mailmogelijkheden van deze wiki kunt gebruiken.",
        "confirmemail_success": "Uw e-mailadres is bevestigd.\nU kunt zich nu [[Special:UserLogin|aanmelden]] en de wiki gebruiken.",
        "confirmemail_loggedin": "Uw e-mailadres is nu bevestigd.",
        "confirmemail_subject": "Bevestiging e-mailadres voor {{SITENAME}}",
-       "confirmemail_body": "Iemand, waarschijnlijk u, met het IP-adres $1,\nheeft zich met dit e-mailadres geregistreerd als gebruiker \"$2\" op {{SITENAME}}.\n\nOpen de volgende koppeling in uw webbrowser om te bevestigen dat u deze gebruiker bent en om de e-mailmogelijkheden op {{SITENAME}} te activeren:\n\n$3\n\nAls u uzelf *niet* hebt aangemeld, volg dan de volgende koppeling om de bevestiging van uw e-mailadres te annuleren:\n\n$5\n\nDe bevestigingscode vervalt op $4.",
-       "confirmemail_body_changed": "Iemand, waarschijnlijk u, met het IP-adres $1,\nheeft het e-mailadres geregistreerd voor gebruiker \"$2\" op {{SITENAME}} gewijzigd naar dit e-mailadres.\n\nOpen de volgende koppeling in uw webbrowser om te bevestigen dat u deze gebruiker bent en om de e-mailmogelijkheden op {{SITENAME}} opnieuw te activeren:\n\n$3\n\nAls u uzelf *niet* hebt aangemeld, volg dan de volgende koppeling om de bevestiging van uw e-mailadres te annuleren:\n\n$5\n\nDe bevestigingscode vervalt op $4.",
-       "confirmemail_body_set": "Iemand, waarschijnlijk u, met het IP-adres $1,\nheeft het e-mailadres voor gebruiker \"$2\" op {{SITENAME}} ingesteld op dit e-mailadres.\n\nOpen de volgende koppeling in uw webbrowser om te bevestigen dat u deze gebruiker bent en om de e-mailmogelijkheden op {{SITENAME}} opnieuw te activeren:\n\n$3\n\nAls deze gebruiker *niet* aan u toebehoort, klik dan op de volgende koppeling om de bevestiging van uw e-mailadres te annuleren:\n\n$5\n\nDe bevestigingscode vervalt op $4.",
+       "confirmemail_body": "Iemand, waarschijnlijk u, vanaf IP-adres $1,\nheeft met dit e-mailadres een account \"$2\" aangemaakt op {{SITENAME}}.\n\nOpen de volgende koppeling in uw webbrowser om te bevestigen dat dit account echt aan u toebehoort en de e-mailmogelijkheden op {{SITENAME}} te activeren:\n\n$3\n\nAls u *niet* dit account hebt aangemaakt, volg dan de volgende koppeling om de bevestiging van uw e-mailadres te annuleren:\n\n$5\n\nDe bevestigingscode vervalt op $4.",
+       "confirmemail_body_changed": "Iemand, waarschijnlijk u, vanaf IP-adres $1,\nheeft het e-mailadres van het account \"$2\" op {{SITENAME}} gewijzigd naar dit e-mailadres.\n\nOpen de volgende koppeling in uw webbrowser om te bevestigen dat dit account echt aan u toebehoort en de e-mailmogelijkheden op {{SITENAME}} opnieuw te activeren:\n\n$3\n\nAls dit account *niet* aan u toebehoort, volg dan de volgende koppeling om de bevestiging van uw e-mailadres te annuleren:\n\n$5\n\nDe bevestigingscode vervalt op $4.",
+       "confirmemail_body_set": "Iemand, waarschijnlijk u, vanaf IP-adres $1,\nheeft het e-mailadres van het account \"$2\" op {{SITENAME}} ingesteld op dit e-mailadres.\n\nOpen de volgende koppeling in uw webbrowser om te bevestigen dat dit account echt aan u toebehoort en de e-mailmogelijkheden op {{SITENAME}} te activeren:\n\n$3\n\nAls dit account *niet* aan u toebehoort, volg dan de volgende koppeling om de bevestiging van uw e-mailadres te annuleren:\n\n$5\n\nDe bevestigingscode vervalt op $4.",
        "confirmemail_invalidated": "De e-mailbevestiging is geannuleerd",
        "invalidateemail": "E-mailbevestiging annuleren",
        "notificationemail_subject_changed": "{{SITENAME}} geregistreerd e-mailadres is gewijzigd",
        "notificationemail_subject_removed": "{{SITENAME}} geregistreerd e-mailadres is verwijderd",
-       "notificationemail_body_changed": "Iemand, waarschijnlijk u, met het IP-adres $1, heeft het e-mailadres van de gebruiker \"$2\" op {{SITENAME}} gewijzigd naar \"$3\". \n\nAls u dit niet was, neem dan onmiddellijk contact op met een sitebeheerder.",
-       "notificationemail_body_removed": "Iemand, waarschijnlijk u, met het IP-adres $1, heeft het e-mailadres geregistreerd voor gebruiker \"$2\" verwijderd op {{SITENAME}}. \n\nAls u dit niet was, neem dan onmiddellijk contact op met een sitebeheerder.",
+       "notificationemail_body_changed": "Iemand, waarschijnlijk u, vanaf IP-adres $1, heeft het e-mailadres van het account \"$2\" op {{SITENAME}} gewijzigd naar \"$3\". \n\nAls u dit niet was, neem dan onmiddellijk contact op met een sitebeheerder.",
+       "notificationemail_body_removed": "Iemand, waarschijnlijk u, vanaf IP-adres $1, heeft het e-mailadres van het account \"$2\" verwijderd op {{SITENAME}}. \n\nAls u dit niet was, neem dan onmiddellijk contact op met een sitebeheerder.",
        "scarytranscludedisabled": "[Interwiki-invoeging van sjablonen is uitgeschakeld]",
        "scarytranscludefailed": "[De sjabloon $1 kon niet opgehaald worden]",
        "scarytranscludefailed-httpstatus": "[De sjabloon $1 kon niet opgehaald worden: HTTP $2]",
        "logentry-patrol-patrol-auto": "$1 {{GENDER:$2|heeft}} versie $4 van pagina $3 automatisch gemarkeerd als gecontroleerd",
        "logentry-newusers-newusers": "Gebruikersaccount $1 {{GENDER:$2|is}} aangemaakt",
        "logentry-newusers-create": "Gebruikersaccount $1 {{GENDER:$2|is}} aangemaakt",
-       "logentry-newusers-create2": "Gebruiker $3 {{GENDER:$2|is}} aangemaakt door $1",
-       "logentry-newusers-byemail": "Gebruiker $3 {{GENDER:$2|is}} aangemaakt door $1 en het wachtwoord is per e-mail verzonden",
+       "logentry-newusers-create2": "Gebruikersaccount $3 is {{GENDER:$2|aangemaakt}} door $1",
+       "logentry-newusers-byemail": "Gebruikersaccount $3 is {{GENDER:$2|aangemaakt}} door $1 en het wachtwoord is per e-mail verzonden",
        "logentry-newusers-autocreate": "Gebruikersaccount $1 {{GENDER:$2|is}} automatisch aangemaakt",
        "logentry-protect-move_prot": "$1 heeft de beveiligingsinstellingen {{GENDER:$2|verplaatst}} van $4 naar $3",
        "logentry-protect-unprotect": "$1 heeft de beveiliging {{GENDER:$2|opgeheven}} van $3",
        "log-action-filter-upload-overwrite": "Herupload",
        "authmanager-authn-not-in-progress": "Verificatie is niet in uitvoering of de sessiegegevens zijn verloren gegaan. Gelieve opnieuw starten vanaf het begin.",
        "authmanager-authn-no-primary": "De meegeleverde inloggegevens kunnen niet worden geverifieerd.",
-       "authmanager-authn-no-local-user": "De ingevoerde inloggegevens zijn niet geassocieerd met een gebruiker op deze wiki.",
-       "authmanager-authn-no-local-user-link": "De meegeleverde inloggegevens zijn geldig, maar zijn niet gekoppeld aan enige gebruiker op deze wiki. Log in op een andere manier, of creëer een nieuwe gebruiker, en u heeft een optie om uw eerdere inloggegevens van te koppelen.",
+       "authmanager-authn-no-local-user": "De ingevoerde inloggegevens zijn niet gekoppeld aan een gebruiker op deze wiki.",
+       "authmanager-authn-no-local-user-link": "De ingevoerde inloggegevens zijn geldig, maar zijn niet gekoppeld aan een gebruiker op deze wiki. Meld u op een andere manier aan, of maak een nieuw account aan, en u krijgt een optie om uw eerdere inloggegevens aan dat account te koppelen.",
        "authmanager-authn-autocreate-failed": "Het automatisch aanmaken van een lokaal account is mislukt: $1",
        "authmanager-change-not-supported": "De meegeleverde inloggegevens kunnen niet worden gewijzigd, omdat niets deze zou gebruiken.",
        "authmanager-create-disabled": "Het aanmaken van accounts is uitgeschakeld.",
index 1e13db1..6c15199 100644 (file)
        "changepassword-success": "ستاسې پټنوم بدل شو!",
        "changepassword-throttled": "تاسې څو واره هڅه کړې چې غونډال ته ورننوځۍ.\nلطفاً د بيا هڅې نه مخکې $1 شېبې تم شۍ.",
        "botpasswords": "روباټ پټنومونه",
+       "botpasswords-summary": "<em>د بوټ پټنومونه</em> د اصلي پټنوم کارولو څخه پرته د ای پی ادرس سره ګڼون ته لاسرسي نه ورکول کيږی. د کاروونکي موجوده لاسرسی ممکن محدود وي کله چې د روباټ پاسورډ داخل شي.\nکه تاسو نه پوهیږئ چې څه شی کولی شئ له دې سره وکړئ، تاسو ممکن هیڅکله هم ونه کړئ. هیڅوک باید له تاسو څخه د دې د ورکولو لپاره نه وپوښتل شي.",
+       "botpasswords-disabled": "د بوټ پټنوم ناممکنه دي.",
+       "botpasswords-no-central-id": "د بوټ د پټنوم کارولو لپاره، تاسو باید په مرکزي حساب کې ننوتلي ياست.",
        "botpasswords-existing": "د بوټ موجود پټ نومونه",
        "botpasswords-createnew": "نوی پټنوم (پاسورډ) جوړ کړي",
        "botpasswords-editexisting": "د بوټ موجود پاسورډ جوړ کړئ",
        "botpasswords-label-delete": "ړنگول",
        "botpasswords-label-resetpassword": "پټوم بدل کړي",
        "botpasswords-label-grants": "تطبیق وړ ګرانټ:",
+       "botpasswords-help-grants": "هر اجازه روبوټ ته اجازه ورکوي چې هغه واک ته لاسرسۍ ومومي کوم چې ستاسو حساب ساتي. د اجازې فعالول دلته، نوې لاسرسی نشته چې ستاسو حساب اوس مهال نلري. د نورو معلوماتو لپاره [[Special:ListGrants|table of grants]] وګورئ.",
        "botpasswords-label-grants-column": "ورکړل شو",
        "botpasswords-bad-appid": "د بوټ نوم \"$1\" وجود نلري.",
        "botpasswords-insert-failed": "د بوټ \"$1\" نوم په ورګډولو کي پاتې راغلې دا نوم د پخوا څخه ورګډ سوي وو?",
+       "botpasswords-update-failed": "د بوټ نوم په نوي کولو کې ناکام شوې \"$1\".ایا دا ړنګ شوی دی؟",
        "botpasswords-created-title": "د بوټ پټنوم جوړ شو",
        "botpasswords-created-body": "د بوټ پټنوم د بوټ \"$1\" د کارن \"$2\" لپاره جوړ شو.",
        "botpasswords-updated-title": "د بوټ پټنوم آپډيټ سو",
        "botpasswords-updated-body": "د بوټ پټنوم د بوټ \"$1\" د کارن \"$2\" لپاره آپډيټ شو.",
        "botpasswords-deleted-title": "د بوټ پټنوم ړنګ شو",
        "botpasswords-deleted-body": "د بوټ پټنوم د بوټ \"$1\" د کارن \"$2\" لپاره ړنګ شو.",
+       "botpasswords-newpassword": "<strong>$2</strong> د ګڼون سره د ننوتلو لپاره نوی پټنوم <strong>$1</strong> دی. <em>مهرباني وکړئ دا د راتلونکی لپاره وساتئ.</em> <br> (د زړو روبوټونو لپاره چې یو کارنومینر ته اړتیا لري چې خپل ګڼون سره سمون لري، تاسو کولی شئ له <strong>$3</strong> لاندې يو کارننوم او <strong>$4</strong> د پټنوم په توګه کاروئ.)",
+       "botpasswords-no-provider": "د بوټ شفر د غونډو وړاندې کول شتون نلري.",
+       "botpasswords-restriction-failed": "د بوټ پاسورډ محدودیتونه د دې ننوتنې مخه نیسي",
+       "botpasswords-invalid-name": "په کارنۍ نومول شوی کې د بوټو د پاسورډ جلا کول شامل نه دی (\"$1\").",
+       "botpasswords-not-exist": "کارن \"$1\"  يو روباټ پټنوم نه لري نوم \"$2\".",
        "resetpass_forbidden": "پټنومونه مو نه شي بدلېدلای",
+       "resetpass_forbidden-reason": "پټنومونه مو نه شي بدلېدلای: $1",
        "resetpass-no-info": "دې مخ ته د لاسرسي لپاره بايد غونډال کې ورننوځۍ.",
        "resetpass-submit-loggedin": "پټنوم بدلول",
        "resetpass-submit-cancel": "ناگارل",
-       "resetpass-wrong-oldpass": "Ù\84Ù\86Ú\89Ù\85Ù\87اÙ\84 Ø§Ù\88 Ù\8aا Ù\87Ù\85 Ø§Ù\88سÙ\86Û\8c Ù¾Ù¼Ù\86Ù\88Ù\85 Ù\85Ù\88 Ù\86اسÙ\85 Ø¯Û\8c",
+       "resetpass-wrong-oldpass": "Ù\86اسÙ\85 Ù\84Ù\86Ú\89Ù\85Ù\87اÙ\84Ù\87 Û\8cا Ø§Ù\88سÙ\86Û\8c Ù¾Ù¼Ù\86Ù\88Ù\85.\nتاسÙ\88 Ù\85Ù\85Ú©Ù\86Ù\86 Ù\85خکÛ\90 Ø®Ù¾Ù\84 Ù¾Ù¼Ù\86Ù\88Ù\85 Ø¨Ø¯Ù\84 Ú©Ú\93Û\8c Ù\88Ù\8a Û\8cا Ø¯ Ù\86Ù\88Ù\8a Ù\84Ù\86Ú\89Ù\85Ù\87اÙ\84Ù\87 Ù¾Ù¼Ù\86Ù\88Ù\85 ØºÙ\88Ú\9aتÙ\86Ù\87 Ú©Ú\93Û\90 Ù\88Û\8c.",
        "resetpass-recycled": "لطفاً پټنوم مو داسې وټاکئ چې له اوسني پټنوم سره يې توپير وي.",
        "resetpass-temp-emailed": "تاسې د يو لنډمهاله کوډ په مرسته چې دربرېښليک شوی و، ننوتلي ياست. \nد ننوتلو د بشپړولو لپاره بايد ځانته يو نوی پټنوم دلته وټاکئ:",
        "resetpass-temp-password": "لنډمهالی پټنوم:",
        "passwordreset-domain": "شپول:",
        "passwordreset-email": "برېښليک پته:",
        "passwordreset-emailtitle": "د {{SITENAME}} د گڼون څرگندنې",
+       "passwordreset-emailtext-ip": "یک نفر (شاید تاسو، دآی‌پی پتی سره$1) د خپل پټنوم بیا سمولو لپاره غوښتنه{{SITENAME}} ($4) کړی ده. {{PLURAL:$3|ګڼون|ګڼونونه}} لاندې کارن د دې برېښنالیک سره تړلی دی:\n\n$2\n\n{{PLURAL:$3|دا یو لنډمهاله پاسورډ دی|دا شفرونه لنډمهاله دي}} وروسته تر {{PLURAL:$5|یوه ورځ|$5 ورځی}} به باطل شي.\nتاسو باید اوس ننوځئ او نوي شفرونه غوره کړئ. که تاسو فکر کوئ چې بل چا دا غوښتنه کړې ده یا که تاسو خپل اصلي پټنوم په یاد ولرئ او تاسو نور یې نه غواړئ بدلون ومومئ، تاسو کولی شئ دا پیغام غفلت کړئ او خپل پخوانی پاسورډ کارولو ته دوام ورکړئ.",
+       "passwordreset-emailtext-user": "یک نفر (شاید تاسو، دآی‌پی پتی سره$1) د خپل پټنوم بیا سمولو لپاره غوښتنه{{SITENAME}} ($4) کړی ده. {{PLURAL:$3|ګڼون|ګڼونونه}} لاندې کارن د دې برېښنالیک سره تړلی دی:\n\n$2\n\n{{PLURAL:$3|دا یو لنډمهاله پاسورډ دی|دا شفرونه لنډمهاله دي}} وروسته تر {{PLURAL:$5|یوه ورځ|$5 ورځی}} به باطل شي.\nتاسو باید اوس ننوځئ او نوي شفرونه غوره کړئ. که تاسو فکر کوئ چې بل چا دا غوښتنه کړې ده یا که تاسو خپل اصلي پټنوم په یاد ولرئ او تاسو نور یې نه غواړئ بدلون ومومئ، تاسو کولی شئ دا پیغام غفلت کړئ او خپل پخوانی پاسورډ کارولو ته دوام ورکړئ.",
        "passwordreset-emailelement": "کارن-نوم: \n$1\n\nلنډمهاله پټنوم: \n$2",
        "passwordreset-emailsentemail": "د پټنوم بيا پرځای کېدنې لپاره برېښليک درولېږل شو.",
+       "passwordreset-emailsentusername": "که د دې کارن-نوم سره یو بریښنالیک پته شتون ولري نو بیا به د پاسورډ ری سیټ ای میل ته واستول شي.",
+       "passwordreset-nocaller": "يو اواز باید ورکړل شي",
+       "passwordreset-nosuchcaller": "کالر شتون نلري: $1",
+       "passwordreset-ignored": "د شفر بیاچالان سم نه و. کیدای شي کوم برابرونکي ترتیب نه وي؟",
        "passwordreset-invalidemail": "ناسمه برېښليک پته",
+       "passwordreset-nodata": "نه هم یو کاروونکي نوم او نه بریښنالیک پته ورکړل شوی",
        "changeemail": "برېښليک پته بدلول يا ليرې کول",
-       "changeemail-header": "د Ú¯Ú¼Ù\88Ù\86 Ø¨Ø±Û\90Ú\9aÙ\84Ù\8aÚ© Ù¾ØªÙ\87 Ø¨Ø¯Ù\84Ù\88Ù\84",
+       "changeemail-header": "د Ú¯Ú¼Ù\88Ù\86 Ø¯ Ø¨Ø±Û\90Ú\9aÙ\86اÙ\84Ù\8aÚ© Ø¨Ø¯Ù\84Ù\88Ù\84Ù\88 Ù\84پارÙ\87 Ø¯Ø§ Ù¾Ù\88رÙ\85 Ù¾Ù\88رÙ\87 Ú©Ú\93Ù\8a. Ú©Ù\87 ØªØ§Ø³Ù\88 ØºÙ\88اÚ\93ئ Ø¯ Ø®Ù¾Ù\84 Ù\87ر Ú\89Ù\88Ù\84 Ø­Ø³Ø§Ø¨ Ú\85Ø®Ù\87 Ø¯ Ø¨Ø±Û\8cÚ\9aÙ\86اÙ\84Ù\8aÚ© Ù¾ØªÙ\87 Ù\84رÛ\90 Ú©Ú\93Ù\8aØ\8c Ù\86Ù\88 Ø¯ Ø¨Ø±Ù\8aÚ\9aÙ\86اÙ\84Ù\8aÚ© Ú\81اÙ\8a Ù\85Ù\88 Ø¯ Ù¾Ù\88رÙ\85 Ø³Ù¾Ø§Ø±Ù\86Û\90 Ù¾Ù\87 Ù\88خت Ú©Û\90 Ø®Ø§Ù\84Ù\8a Ù¾Ø±Ù\8aÚ\96دÙ\8a.",
        "changeemail-no-info": "دې مخ ته د لاسرسي لپاره بايد غونډال کې ورننوځۍ.",
        "changeemail-oldemail": "اوسنۍ برېښليک پته:",
        "changeemail-newemail": "نوې برېښليک پته:",
+       "changeemail-newemail-help": "که تاسو غواړئ خپل بریښنالیک لرې کړئ نو دا ساحه باید پریښودل شي. تاسو به د هیر شوي شفر بیاپټولو توان نه لرئ او د دې ويکي نه بریښنالیکونه به مو ترلاسه نکړئ که چیرې مو برېښناليک لرې کړای شو.",
        "changeemail-none": "(هېڅ)",
        "changeemail-password": "ستاسې د{{SITENAME}} پټنوم:",
        "changeemail-submit": "برېښليک بدلول",
        "changeemail-throttled": "تاسې څو واره هڅه کړې چې غونډال ته ورننوځۍ.\nلطفاً د بيا هڅې نه مخکې $1 شېبې تم شۍ.",
+       "changeemail-nochange": "مهرباني وکړئ یو بل نوی برېښناليک پته ولیکئ.",
+       "resettokens": "د ټوکنونو بیاکتنه",
+       "resettokens-text": "تاسو کولی شئ  ټوکنونه بیا ځای پرځای کړئ کوم چې دلته ستاسو د حساب سره تړلی ځینې مشخصو معلوماتو ته دلا سرسۍ اجازه ورکوي.\n\nتاسو باید دا کار وکړئ که چیرې تاسو په ناڅاپي توګه له چا سره شریک کړي یا ستاسو حساب ورسره موافق وي.",
        "resettokens-tokens": "ټوکنونه:",
        "resettokens-token-label": "$1 (اوسنی ارزښت: $2)",
        "resettokens-done": "د رایو بیا راګرځول.",
        "newarticletext": "تاسې د يوې داسې تړنې څارنه کړې چې لا تر اوسه پورې نه شته.\nکه همدا مخ ليکل غواړۍ، نو په لانديني چوکاټ کې خپل متن وټاپئ (د لا نورو مالوماتو لپاره د [$1 لارښود مخ] وگورئ).\nکه چېرته تاسې دلته په تېروتنه راغلي ياست، نو يواځې د خپل د کتنمل '''مخ پر شا''' تڼۍ مو وټوکئ.",
        "anontalkpagetext": "----''دا د يوه ورکنومي کارن چې کارن-نوم نه لري او يا خپل کارن-نوم نه کاروي، د سکالو يوه پاڼه ده. نو د يوه کس د پېژندلو پخاطر موږ د هماغه کارن د انټرنېټ شمېره يا IP پته دلته ثبتوؤ. داسې يوه IP پته د ډېرو کارنانو لخوا هم کارېدلی شي. که تاسې يو ورکنومی کارن ياست او تاسې ته دا څرگندېږي چې تاسې ته نااړونده پېغامونه او تبصرې اشاره شوي، نو د نورو بې نومو کارنانو او ستاسې ترمېنځ د ټکنتوب د مخ نيونې لپاره لطفاً [[Special:CreateAccount|يو گڼون جوړ کړۍ]] او يا هم [[Special:UserLogin|غونډال ته ورننوځۍ]].''",
        "noarticletext": "دم مهال په دې مخ کې څه نشته.\nتاسې کولای شی چې په نورو مخونو کې [[Special:Search/{{PAGENAME}}|د دې مخ د سرليک پلټنه]]،\n<span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} د اړوندو يادښتونو پلټنه] ،\nاو يا [{{fullurl:{{FULLPAGENAME}}|action=edit}} همدا مخ جوړ کړئ]</span>.",
-       "noarticletext-nopermission": "دم مهال په دې مخ کې متن نشته.\nتاسې کولای شی چې [[Special:Search/{{PAGENAME}}|همدا سرليک په نورو مخونو کې وپلټۍ]], يا هم <span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} اړونده يادښتونه وپلټۍ]</span>، خو تاسې د دې مخ د جوړولو اجازه نه لرۍ.",
+       "noarticletext-nopermission": "دم مهال په دې مخ کې متن نشته.\nتاسې کولای شی چې [[Special:Search/{{PAGENAME}}|همدا سرليک په نورو مخونو کې وپلټۍ]]، يا هم <span class=\"plainlinks\">[{{fullurl:{{#Special:Log}}|page={{FULLPAGENAMEE}}}} اړونده يادښتونه وپلټۍ]</span>، خو تاسې د دې مخ د جوړولو اجازه نه لرۍ.",
        "userpage-userdoesnotexist": "د \"<nowiki>$1</nowiki>\" گڼون نه دی ثبت شوی.\nلطفاً ځان ډاډه کړئ چې آيا تاسې په رښتيا همدا مخ جوړول/سمول غواړئ.",
        "userpage-userdoesnotexist-view": "د \"$1\" گڼون نه دی ثبت شوی.",
        "blocked-notice-logextract": "دم مهال په دې کارن بنديز لگېدلی.\nد بنديز يادښت تازه مالومات په لاندې توگه دي:",
        "longpageerror": "'''تېروتنه: کوم متن چې مو ليکلی {{PLURAL:$1|يو کيلوبايټه|$1 کيلوبايټه}} اوږد دی، چې دا پخپله د حد اکثر نه {{PLURAL:$2|يو کيلوبايټه|$2 کيلوبايټه}} اوږد دی.'''\nستاسې متن نه شي خوندي کېدلای.",
        "protectedpagewarning": "'''گواښنه: همدا مخ تړل شوی او يوازې هغه کارنان په دې مخ کې بدلونونه راوستلای شي چې د پازوالۍ د آسانتياوو نه برخمن دي.'''\nستاسې د مالوماتو لپاره د وروستني يادښت متن دلته په دې توگه راوړل شوی:",
        "semiprotectedpagewarning": "'''پاملرنه:''' دا مخ تړل شوی او يواځې ثبت شوي کارنان کولای شي چې په دې مخ کې بدلونونه راولي.\nستاسې د مالوماتو لپاره د وروستني يادښت متن دلته په دې توگه راوړل شوی:",
-       "cascadeprotectedwarning": "'''گواښنه:''' همدا مخ تړل شوی دی او يوازې هغه کارنان په دې مخ کې بدلونونه راوستلای شي چې د پازوالۍ د آسانتياوو نه برخمن دي، دا په دې خاطر چې همدا مخ د {{PLURAL:$1|لانديني مخ|لاندينيو مخونو}} په ځوړاوبيزې ژغورنې کې ورگډ دی:",
+       "cascadeprotectedwarning": "'''گواښنه:''' همدا مخ تړل شوی دی او يوازې هغه کارنان په دې مخ کې بدلونونه راوستلای شي چې د [[Special:ListGroupRights|د پازوالۍ د آسانتياوو]] نه برخمن دي، دا په دې خاطر چې همدا مخ د {{PLURAL:$1|لانديني مخ|لاندينيو مخونو}} په ځوړاوبيزې ژغورنې کې ورگډ دی:",
        "titleprotectedwarning": "'''گواښنه: همدا مخ تړل شوی دی او د دې د جوړولو لپاره تاسې ته د [[Special:ListGroupRights|ځانگړو رښتو]] د ترلاسه کولو اړتيا ده.'''\nستاسې د مالوماتو لپاره د وروستني يادښت متن دلته په دې توگه راوړل شوی:",
        "templatesused": "په دې مخ کارېدلې {{PLURAL:$1|کينډۍ|کينډۍ}}:",
        "templatesusedpreview": "يه دې مخليدنه کارېدلې {{PLURAL:$1|کينډۍ|کينډۍ}}:",
        "history-feed-description": "ددي مخ د بياکتنې تاريخ په ويکي کي",
        "history-feed-item-nocomment": "$1 په $2",
        "history-feed-empty": "ستاسې غوښتلی مخ نه شته.\nکېدای شي چې دا له ويکي نه ړنگ شوی وي، او يا هم په بل نوم بدل شوی وي.\nتاسې په دې ويکي د اړوندو نوؤ مخونو لپاره [[Special:Search|د پلټنې هڅه وکړۍ]].",
+       "history-edit-tags": "د غوره بڼې سمول نښانونه",
        "rev-deleted-comment": "(د سمون لنډيز لرې شو)",
        "rev-deleted-user": "(کارن-نوم ليري شوی)",
+       "rev-deleted-event": "(د ننوتنې مالومات ړنګ شوي)",
+       "rev-deleted-user-contribs": "[د کارن-نوم یا ای پی پته لرې کړه - له مرستو څخه پټ شوی ترمیم]",
        "rev-deleted-text-permission": "د دې مخ بڼه <strong>ړنگه شوه</strong>.\nد دې مخ اړونده تفصيل په [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} ړنگون يادښت] کې موندلی شی.",
+       "rev-suppressed-text-permission": "د دې مخ بڼه <strong>ړنگه شوه</strong>.\nد دې مخ اړونده تفصيل په [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} ړنگون يادښت] کې موندلی شی.",
+       "rev-suppressed-text-unhide": "د دې مخ بیاکتنه روانه <strong>ماتول ده</strong>.\nتفصيلات په دې ځای کې موندل کيداى شي[{{fullurl:{{#Special:Log}}/suppress|page={{FULLPAGENAMEE}}}} د ماتولو يادښت].\nتاسو لا هم کولی شئ [$1 دا بیاکتنه وګورئ] که تاسو غواړئ چې پرمخ بوځي.",
+       "rev-deleted-text-view": "ددې مخ سمون ''' ړنګ شوی '''.\nتاسو کولی شئ دا وګورئ؛ دا کېدای شي اړوند معلومات [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}}ړنګ شوی] په کې شامل وي.",
+       "rev-suppressed-text-view": "د دې مخ بڼه <strong>ړنگه شوه</strong>.\nد دې مخ اړونده تفصيل په [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} ړنگون يادښت] کې موندلی شی.",
+       "rev-deleted-no-diff": "د دې مخ بڼه <strong>ړنگه شوه</strong>.\nد دې مخ اړونده تفصيل په [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} ړنگون يادښت] کې موندلی شی.",
+       "rev-suppressed-no-diff": "تاسو دا توپیر نه شو لیدلی ځکه چې د بیاکتنې څخه یو یې <strong>ړنګ شویدی</strong>.",
+       "rev-deleted-unhide-diff": "د دې مخ بیاکتنه روانه <strong>ماتول ده</strong>.\nتفصيلات په دې ځای کې موندل کيداى شي[{{fullurl:{{#Special:Log}}/suppress|page={{FULLPAGENAMEE}}}} د ماتولو يادښت].\nتاسو لا هم کولی شئ [$1 دا بیاکتنه وګورئ] که تاسو غواړئ چې پرمخ بوځي.",
+       "rev-suppressed-unhide-diff": "د دې مخ بیاکتنه روانه <strong>ماتول ده</strong>.\nتفصيلات په دې ځای کې موندل کيداى شي[{{fullurl:{{#Special:Log}}/suppress|page={{FULLPAGENAMEE}}}} د ماتولو يادښت].\nتاسو لا هم کولی شئ [$1 دا بیاکتنه وګورئ] که تاسو غواړئ چې پرمخ بوځي.",
+       "rev-deleted-diff-view": "ددې مخ سمون ''' ړنګ شوی '''.\nتاسو کولی شئ دا وګورئ؛ دا کېدای شي اړوند معلومات [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}}ړنګ شوی] په کې شامل وي.",
+       "rev-suppressed-diff-view": "د دې مخ بڼه <strong>ړنگه شوه</strong>.\nد دې مخ اړونده تفصيل په [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} ړنگون يادښت] کې موندلی شی.",
        "rev-delundel": "ښکارېدنه بدلول",
        "rev-showdeleted": "ښکاره کول",
        "revisiondelete": "د ړنگولو/ناړنگولو مخکتنې",
        "revdelete-nooldid-title": "ناباوره پيښنليک ته اشاره",
+       "revdelete-nooldid-text": "تاسو یا د کوم هدف بیا کتنه نده مشخص کړې چې دا فعالیت ترسره کړي، یا مشخص بیاکتنه شتون نلري، یا تاسو د اوسني بیاکتنې پټولو هڅه کوۍ.",
        "revdelete-no-file": "ځانگړې شوې دوتنه نشته.",
+       "revdelete-show-file-confirm": "ایا ته باوري یې چې دا دوتنه د خراب شوي څخه بیاکتنې ته واړوی\"<nowiki>$1</nowiki>\" له$2 په $3؟",
        "revdelete-show-file-submit": "هو",
        "revdelete-selected-text": "د [[:$2]] {{PLURAL:$1|ټاکلې بڼه|ټاکلې بڼې}}:",
        "revdelete-selected-file": "د [[:$2]] {{PLURAL:$1|ټاکلې دوتنې بڼه|ټاکلې دوتنې بڼې}}",
        "logdelete-selected": "{{PLURAL:$1|ټاکلي يادښت پېښه|ټاکلي يادښت پېښې}}:",
        "revdelete-text-text": "ړنگې شوې بڼې به لا تر اوسه پورې د مخ پېښليک کې ښکاري، خو د هغو ځينو برخو ته به عام خلک لاسرسی و نه لري.",
+       "revdelete-text-file": "ړنگې شوې بڼې به لا تر اوسه پورې د مخ پېښليک کې ښکاري، خو د هغو ځينو برخو ته به عام خلک لاسرسی و نه لري.",
+       "logdelete-text": "ړنگې شوې بڼې به لا تر اوسه پورې د مخ پېښليک کې ښکاري، خو د هغو ځينو برخو ته به عام خلک لاسرسی و نه لري.",
+       "revdelete-text-others": "نور پازوالان به لا هم د پټ راز محتوياتو ته لاسرسی ومومي او دا یې له منځه یوسي، مګر که نه بل ډول مشخص شوی.",
+       "revdelete-confirm": "لطفا دا تایید کړئ چې تاسو دا کار کول غواړئ، دا چې تاسو پایلې په پام کې لرئ او تاسو یې سره مطابقت کوئ[[{{MediaWiki:Policy-url}}|پالیسۍ]].",
        "revdelete-legend": "د ښکارېدنې محدوديتونه ټاکل",
        "revdelete-hide-text": "د مخکتنې متن",
        "revdelete-hide-image": "د دوتنې مېنځپانگه پټول",
        "userrights-user-editname": "يو کارن نوم ورکړئ:",
        "editusergroup": "{{GENDER:$1|کارن}} ډلې سمول",
        "editinguser": "د <strong>[[User:$1|$1]]</strong> {{GENDER:$1|کارن}} رښتې بدلول $2",
-       "userrights-editusergroup": "کارن ډلې سمول",
+       "userrights-editusergroup": "{{GENDER:$1|کارن}} ډلې سمول",
        "userrights-viewusergroup": "د{{GENDER:$1|کارن}} ګروپونه ښکاره کړي",
        "saveusergroups": "{{GENDER:$1|کارن}} ډلې خوندي کول",
        "userrights-groupsmember": "غړی د:",
        "action-userrights-interwiki": "په نورو ويکي گانو د کارنانو رښتې سمول",
        "action-siteadmin": "توکبنسټ کولپول يا نه کولپول",
        "action-sendemail": "برېښليکونه لېږل",
+       "action-editmyoptions": "خپل غوره توبونه سمول",
        "action-editmywatchlist": "خپل کتنلړ سمول",
        "action-viewmywatchlist": "خپل کتنلړ کتل",
        "action-viewmyprivateinfo": "خپل شخصي مالومات کتل",
        "rcfilters-savedqueries-add-new-title": "د امستنې اوسنۍ فيلټر خوندي کړي",
        "rcfilters-filterlist-title": "چاڼگران",
        "rcfilters-highlightmenu-title": "يو رنګ وټاکۍ",
+       "rcfilters-filter-user-experience-level-unregistered-label": "ناثبت",
        "rcfilters-filter-user-experience-level-newcomer-label": "نوي راغلي",
        "rcfilters-filter-user-experience-level-learner-label": "زده کوونکي",
-       "rcnotefrom": "دلته لاندې د <strong>$2</strong> څخه راپدېخوا پېښ شوي بدلونونه راغلي (تر <strong>$1</strong> پورې ښکاري).",
+       "rcnotefrom": "دلته لاندې د <strong>$3, $4</strong> (څخه <strong>$1</strong> {{PLURAL:$5|راپدېخوا پېښ شوي بدلونونه|ښکاري}}).",
        "rclistfrom": "نوي بدلونونه چې له $3، $2 څخه پيلېږي ښکاره کول",
        "rcshowhideminor": "وړې سمونې $1",
        "rcshowhideminor-show": "ښکاره کول",
        "recentchangeslinked-page": "د مخ نوم:",
        "recentchangeslinked-to": "د ورکړل شوي مخ پر ځای د اړونده تړلي مخونو بدلونونه ښکاره کول",
        "recentchanges-page-added-to-category": "[[:$1]] وېشنيزې کې ورگډ شو",
-       "recentchanges-page-added-to-category-bundled": "[[:$1]] او {{PLURAL:$2|يو مخ|$2 مخونه}} وېشنيزې کې ورگډ شول",
+       "recentchanges-page-added-to-category-bundled": "[[:$1]] له وېشنيزې وغورځول شول، [[Special:WhatLinksHere/$1|په نورو مخونو کې دا مخ موجود دی.]]",
        "recentchanges-page-removed-from-category": "[[:$1]] له وېشنيزې وغورځول شو",
-       "recentchanges-page-removed-from-category-bundled": "[[:$1]] او {{PLURAL:$2|يو مخ|$2 مخونه}} له وېشنيزې وغورځول شول",
+       "recentchanges-page-removed-from-category-bundled": "[[:$1]] له وېشنيزې وغورځول شول، [[Special:WhatLinksHere/$1|په نورو مخونو کې دا مخ موجود دی.]]",
        "autochange-username": "د مېډياويکي خپلکاره بدلون",
        "upload": "دوتنه پورته کول",
        "uploadbtn": "دوتنه پورته کول",
        "reuploaddesc": "پورته کېدنه ناگارل او بېرته د پورته کېدنې فورمې ته ورگرځېدل",
        "upload-tryagain": "د بدلون موندلې دوتنې څرگندونې سپارل",
+       "upload-tryagain-nostash": "د بیا رالېږل شوې دوتنې وړاندې کول او تعدیل شوی بیان وړاندې کړئ",
        "uploadnologin": "غونډال کې نه ياست ننوتي",
        "uploadnologintext": "د دوتنې پورته کولو لپاره بايد $1",
        "uploaderror": "د پورته کولو ستونزه",
        "upload-form-label-infoform-categories": "وېشنيزې",
        "upload-form-label-infoform-date": "نېټه",
        "backend-fail-notexists": "د $1 په نوم دوتنه نشته.",
+       "backend-fail-invalidpath": "\"$1\" د اعتبار وړ لاره نه ده.",
        "backend-fail-delete": "د \"$1\" دوتنه ړنګه نه شوه.",
+       "backend-fail-describe": "د $1 دوتنې لپاره مېټاډاټا نشو بدلولی",
        "backend-fail-alreadyexists": "د $1 دوتنه له پخوا نه شته.",
        "backend-fail-store": "په \"$2\" باندې د \"$1\" دوتنه نه زېرمل کېږي.",
        "backend-fail-copy": "د \"$1\" دوتنه و \"$2\" ته نه لمېسل کېږي.",
        "sharedupload": "دا دوتنه د $1 لخوا څخه ده او کېدای شي چې نورې پروژې به يې هم کاروي.",
        "sharedupload-desc-there": "دا دوتنه د $1 څخه ده او کېدای شي چې په نورو پروژو به هم کارېږي.\nد نورو مالوماتو لپاره لطفاً [د $2 دوتنې د څرگندونو مخ] وگورئ.",
        "sharedupload-desc-here": "دا دوتنه د $1 لخوا خپرېږې او کېدای شي چې دا په نورو پروژو هم کارېدلې وي.\nد دوتنې د کارېدنې لا نور مالومات د [$2 دوتنې د څرگندنو په مخ] کې لاندې ښودل شوی.",
+       "sharedupload-desc-edit": "دا دوتنه د $1 لخوا خپرېږې او کېدای شي چې دا په نورو پروژو هم کارېدلې وي.\nکېدای شي تاسو به غواړئ چې څرگندونې يې د دې دوتنې [د $2 دوتنې د څرگندنو په مخ] کې سمې کړئ.",
        "sharedupload-desc-create": "دا دوتنه د $1 لخوا خپرېږې او کېدای شي چې دا په نورو پروژو هم کارېدلې وي.\nکېدای شي تاسو به غواړئ چې څرگندونې يې د دې دوتنې [د $2 دوتنې د څرگندنو په مخ] کې سمې کړئ.",
        "filepage-nofile": "په دې نوم کومه دوتنه نشته.",
        "filepage-nofile-link": "په دې نوم کومه دوتنه نشته، خو تاسې يې [$1 پورته کولی شی].",
        "fewestrevisions": "لږ مخليدل شوي مخونه",
        "nbytes": "$1 {{PLURAL:$1|بايټ|بايټونه}}",
        "ncategories": "$1 {{PLURAL:$1|وېشنيزه|وېشنيزې}}",
-       "ninterwikis": "$1 {{PLURAL:$1|ويکي خپلمنځي|ويکي خپلمنځي}}",
+       "ninterwikis": "$1 {{PLURAL:$1|انټرویکی|انټرویکی}}",
        "nlinks": "$1 {{PLURAL:$1|تړنه|تړنې}}",
        "nmembers": "$1 {{PLURAL:$1|غړی|غړي}}",
        "nmemberschanged": "$1 → $2 {{PLURAL:$2|غړی|غړي}}",
        "booksources-search": "پلټل",
        "booksources-text": "دا لاندې د هغه وېبځايونو د تړنو لړليک دی چېرته چې نوي او زاړه کتابونه پلورل کېږي، او يا هم کېدای شي چې د هغه کتاب په هکله مالومات ولري کوم چې تاسو ورپسې لټېږۍ:",
        "booksources-invalid-isbn": "دا ISBN چې تاسې ورکړی سم نه ښکاري؛ د تېروتنو لپاره د لمېسلو اصلي سرچينه وگورئ.",
+       "magiclink-tracking-isbn": "مخونه د اي اس بي ان جادوګر لينکونو سره",
        "specialloguserlabel": "ترسره کوونکی:",
-       "speciallogtitlelabel": "موخه (سرليک يا کارن):",
+       "speciallogtitlelabel": "موخه (سرليک يا {{ns:user}}:کارن نوم د کارن لپاره):",
        "log": "يادښتونه",
        "logeventslist-submit": "ښکاره کول",
        "all-logs-page": "ټول عام يادښتونه",
        "addedwatchtext-short": "د \"$1\" مخ ستاسې کتنلړ کې ورگډ شو.",
        "removewatch": "له کتنلړ نه غورځول",
        "removedwatchtext": "د \"[[:$1]]\" مخ [[Special:Watchlist|ستاسې کتنلړ]] نه لرې شو.",
+       "removedwatchtext-talk": "د \"[[:$1]]\" په نوم يو مخ ستاسې [[Special:Watchlist|کتنلړ]] کې ورگډ شو.\nپه راتلونکې کې چې په دغه مخ او د دې د خبرواترو مخ کې کوم بدلونونه راځي نو هغه به ستاسې کتنلړ کې ښکاري.",
        "removedwatchtext-short": "د \"$1\" مخ ستاسې له کتنلړ څخه لرې شو.",
        "watch": "کتل",
        "watchthispage": "همدا مخ کتل",
        "wlshowhideanons": "ورکنومي کارنان",
        "wlshowhidepatr": "څارل شوي سمونونه",
        "wlshowhidemine": "زما سمونونه",
+       "wlshowhidecategorization": "د مخ وېشنيزې",
        "watchlist-options": "د کتنلړ خوښنې",
        "watching": "د کتلو په حال کې...",
        "unwatching": "د نه کتلو په حال کې...",
        "version-libraries-license": "منښتليک",
        "version-libraries-description": "څرگندونه",
        "version-libraries-authors": "ليکوالان",
-       "redirect": "ورگرځېدنې د دوتنې، کارن، مخ يا بڼې پېژند له مخې",
+       "redirect": "د دوتنې ورگرځېدنې، کارن، مخ يا بڼې پېژند له مخې",
        "redirect-summary": "دا ځانګړی مخ د یوې دوتنې (د فیلمین لخوا ورکړ شوی)، یو مخ (د بیاکتنې پیژند یا د پاڼې پېژندل شوی اي ډي)، د کاروونکي پاڼه (د شمېره کاروونکي اي ډي ورکړه)، او یا د ننوتلو ننوتل (د ننوتنې اي ډي ورکړل شوی). کارول:[[{{#Special:Redirect}}/file/Example.jpg]], [[{{#Special:Redirect}}/page/64308]], [[{{#Special:Redirect}}/revision/328429]], [[{{#Special:Redirect}}/user/101]], or [[{{#Special:Redirect}}/logid/186]].",
        "redirect-submit": "ورځه",
        "redirect-lookup": "وګوري:",
index 31a07bd..bf4a9a8 100644 (file)
        "rcfilters-savedqueries-apply-and-setdefault-label": "Criar filtro padrão",
        "rcfilters-savedqueries-cancel-label": "Cancelar",
        "rcfilters-savedqueries-add-new-title": "Gravar configurações atuais de filtros",
+       "rcfilters-savedqueries-already-saved": "Esses filtros já foram salvos",
        "rcfilters-restore-default-filters": "Restaurar filtros padrão",
        "rcfilters-clear-all-filters": "Limpar todos os filtros",
        "rcfilters-show-new-changes": "Veja as novas mudanças",
index bdc02ec..41fe87e 100644 (file)
        "ok": "Ṭhik gea",
        "retrievedfrom": "\"$1\" khon ñam ạgui",
        "youhavenewmessages": "Amaḱ do $1 ($2) menaḱa",
+       "youhavenewmessagesfromusers": "{{PLURAL:$4|ᱟᱢ ᱫᱚ}} $1 ᱠᱷᱚᱱ {{PLURAL:$3|ᱟᱨᱢᱤᱫ ᱵᱮᱵᱷᱟᱨᱤᱭᱟᱹ|$3 ᱵᱷᱮᱵᱷᱟᱨᱩᱭᱟᱹ}} ($2) ᱾",
        "newmessageslinkplural": "{{PLURAL:$1|ᱢᱤᱫ ᱱᱟᱶᱟ ᱢᱮᱥᱮᱡᱽ|999=ᱱᱟᱶᱟ ᱢᱮᱥᱮᱡᱽᱠᱚ}}",
        "newmessagesdifflinkplural": "ᱢᱩᱪᱟᱹᱫ {{PLURAL:$1|ᱵᱚᱫᱚᱞ|999=ᱵᱚᱫᱚᱞᱠᱚ}}",
        "youhavenewmessagesmulti": "Amaḱ nãwã mesagko do $1 menaḱa",
        "editundo": "ruạṛ",
        "diff-empty": "(ᱵᱷᱮᱜᱮᱫ ᱵᱟᱹᱱᱩᱜ)",
        "diff-multi-sameuser": "({{PLURAL:$1|ᱢᱤᱫ ᱛᱟᱞᱟ-ᱢᱟᱞᱟ ᱫᱚᱦᱲᱟ|$1 ᱛᱟᱞᱟ-ᱢᱟᱞᱟ ᱫᱚᱦᱲᱟᱠᱚ}} ᱥᱚᱢᱟᱱ ᱵᱮᱵᱷᱟᱨᱤᱭᱟᱹ ᱫᱟᱨᱟᱭᱛᱮ ᱵᱟᱭ ᱧᱮᱞᱚᱜ-ᱟ)",
+       "diff-multi-otherusers": "({{PLURAL:$1|ᱢᱤᱫ ᱛᱟᱞᱟ-ᱢᱟᱞᱟ ᱫᱚᱦᱲᱟ|$1 ᱛᱟᱞᱟ-ᱢᱟᱞᱟ ᱫᱚᱦᱲᱟᱠᱚ}} {{PLURAL:$2|ᱢᱤᱫ ᱮᱴᱟᱜ ᱵᱮᱵᱷᱟᱨᱤᱭᱟᱹ|$2 ᱵᱮᱵᱷᱟᱨᱤᱭᱟᱹᱠᱚ}} ᱵᱟᱠᱚ ᱧᱮᱞᱚᱜ-ᱟ)",
        "searchresults": "Se̠ndra pho̠l",
        "searchresults-title": "\"$1\"  renaḱ Sẽndra  phol",
        "prevn": "Laha reaḱ {{PLURAL:$1|$1}}",
        "filehist-comment": "Roṛ",
        "imagelinks": "Phayel bebohar",
        "linkstoimage": "Latar reaḱ {{PLURAL:$1 sakam $1 sakam}} khon noa rẽtre joṛao menaḱa:",
+       "linkstoimage-more": "$1 ᱠᱷᱚᱱ ᱵᱟᱹᱲᱛᱤ {{PLURAL:$1|ᱥᱟᱦᱴᱟ ᱡᱚᱯᱲᱟᱣᱠᱚ|ᱥᱟᱦᱴᱟ ᱡᱚᱯᱲᱟᱣ}} ᱢᱮᱱᱟᱜ-ᱟ ᱱᱚᱣᱟ ᱨᱮᱫ ᱥᱟᱶ ᱾\nᱱᱚᱶᱟ ᱞᱤᱥᱴᱤ ᱩᱫᱩᱜᱮᱜ-ᱟᱭ {{PLURAL:$1|ᱮᱛᱚᱦᱚᱵ ᱥᱟᱦᱴᱟ ᱡᱚᱲᱟᱣ|ᱮᱛᱚᱦᱚᱵ $1 ᱥᱟᱦᱴᱟ ᱡᱚᱲᱟᱣᱠᱚ}} ᱥᱩᱢᱩᱝ ᱱᱚᱶᱟ ᱨᱮᱫ ᱥᱟᱶ ᱾\nᱢᱤᱫ [[Special:WhatLinksHere/$2|ᱡᱚᱛᱚ ᱞᱤᱥᱴᱤ]] ᱢᱮᱱᱟᱜ-ᱟ ᱾",
        "nolinkstoimage": "Nonḍe do noa são joṛao sakam banuka",
        "linkstoimage-redirect": "$1 (ᱨᱮᱫ ᱢᱚᱦᱰᱟᱜ-ᱟ) $2",
        "sharedupload-desc-here": "Noa rẽt do nonḍe khon-  $1 ar paseć eṭaḱaḱ porjekṭko beoharakana.\nNoa reaḱ pasnao katha [$2 rẽt pasnao sakam] latare emena",
        "speciallogtitlelabel": "ᱡᱚᱥ (ᱧᱩᱛᱩᱢ ᱟᱨᱵᱟᱝ {{ns:user}}:ᱵᱮᱵᱷᱟᱨᱤᱭᱟᱹ ᱞᱟᱹᱜᱩᱫ ᱵᱮᱵᱷᱟᱨᱤᱭᱟᱹ ᱧᱩᱛᱩᱢ):",
        "log": "Cạbiko",
        "all-logs-page": "ᱡᱚᱛᱚ ᱫᱤᱥᱣᱟᱹ ᱞᱚᱜᱽ ᱠᱚ",
+       "logempty": "ᱞᱚᱜᱽ ᱨᱮ ᱚᱱᱟᱞᱮᱠᱟᱱ ᱡᱤᱱᱤᱥ ᱵᱟᱹᱱᱩᱜ-ᱟ ᱾",
        "allpages": "joto sakam",
        "allarticles": "Sanam sakam",
        "allpagessubmit": "Calaḱme",
        "sp-contributions-search": "Kạmiko emoḱ lạgitte sendrayme",
        "sp-contributions-username": "IP ṭhikạna se laṛcaṛićaḱ n̕utum",
        "sp-contributions-toponly": "Khạli nahaḱ nãwã aroyen joṛao kamiko udukme",
+       "sp-contributions-newonly": "ᱥᱩᱢᱩᱝ ᱟᱹᱨᱩᱠᱚ ᱥᱚᱫᱚᱨᱢᱮ ᱡᱟᱦᱟᱸ ᱥᱟᱦᱟᱴᱟ ᱫᱚ ᱥᱤᱨᱡᱟᱹᱣᱟᱜ ᱠᱟᱱᱟ",
        "sp-contributions-submit": "Sendra",
        "whatlinkshere": "Cet́ link ko no̠nḍe do",
        "whatlinkshere-title": "Oka sakam ko do \"$1\"-re joṛao menaḱa",
        "tags-active-no": "ᱵᱟᱝ",
        "logentry-delete-delete": "$3 ᱥᱟᱦᱴᱟ $1 {{GENDER:$2|ᱜᱮᱫ ᱠᱮᱜ-ᱟᱭ}}",
        "logentry-delete-restore": "$1 {{GENDER:$2|ᱨᱟᱠᱷᱟ ᱫᱚᱲᱦᱟ}} ᱠᱮᱜ-ᱟ ᱥᱟᱦᱴᱟ $3 ($4)",
+       "logentry-delete-revision": "$1 {{GENDER:$2|ᱵᱚᱫᱚᱞᱠᱮᱜ-ᱟᱭ}} ᱧᱮᱞᱚᱜᱟᱜ {{PLURAL:$5|ᱫᱚᱦᱲᱟᱭᱮᱱᱟᱜ|$5 ᱫᱚᱦᱲᱟᱭᱮᱱᱟᱜ ᱠᱚ}} $3: $4 ᱥᱟᱦᱴᱟ ᱪᱮᱛᱟᱱᱨᱮ",
        "revdelete-content-hid": "ᱩᱱᱩᱫᱩᱜ ᱫᱟᱱᱟᱝ",
        "logentry-move-move": "$1 beoharić $3 sakam do $4 ńutumre {{GENDER:$2|ạcạr}} akada",
        "logentry-move-move-noredirect": "$1 {{GENDER:$2|ᱩᱪᱟᱹᱲᱠᱮᱜ-ᱟᱭ}} ᱥᱟᱦᱴᱟ $3 to $4 ᱢᱚᱦᱰᱟ ᱵᱤᱱ ᱵᱟᱹᱜᱤ ᱠᱟᱛᱮ",
index 2583c81..2d18707 100644 (file)
        "rcfilters-filter-newpages-label": "လွင်ႈၵေႃႇသၢင်ႈ ၼႃႈလိၵ်ႈ",
        "rcfilters-filter-newpages-description": "မႄးထတ်း ဢၼ်ႁဵတ်းပဵၼ် ၼႃႈလိၵ်ႈဢၼ်မႂ်ႇ",
        "rcfilters-filter-categorization-label": "လႅၵ်ႈလၢႆႈ တွၼ်ႈၵၼ်",
+       "rcfilters-filtergroup-lastRevision": "ၵၢၼ်ၶူၼ်ႉၶႆႈ ၵမ်းလိုၼ်းသုတ်း",
+       "rcfilters-filter-lastrevision-label": "ၵၢၼ်ၶူၼ်ႉၶႆႈ ၵမ်းလိုၼ်းသုတ်း",
+       "rcfilters-filter-lastrevision-description": "ၸိူဝ်းဢၼ်မီးလွင်ႈလႅၵ်ႈလၢႆႈၸူး ၼႃႈလိၵ်ႈ ဢၼ်ပႆႇႁိုင်ၼၼ်ႉၵူၺ်း",
+       "rcfilters-filter-previousrevision-label": "ဢမ်ႇၸႂ်ႈၵၢၼ်ၶူၼ်ႉၶႆႈ ၵမ်းလိုၼ်းသုတ်း",
+       "rcfilters-filter-previousrevision-description": "ၸိူဝ်းလႅၵ်ႈလၢႆႈတင်းသဵင်ႈ ဢၼ်ဢမ်ႇၸႂ်ႈ \"လွင်ႈၶူၼ်ႉၶႆႈၵမ်းလိုၼ်းသုတ်း\"။",
        "rcnotefrom": "ၽၢႆႇတႂ်ႈ {{PLURAL:$5|ၼႆႉ ပဵၼ်လွင်ႈလႅၵ်ႈလၢႆႈ|ၸိူဝ်းၼႆႉ ပဵၼ်လွင်ႈလႅၵ်ႈလၢႆႈ}} ဝႆႉ ၸဵမ်မိူဝ်ႈ <strong>$3, $4</strong> (တေႃႇထိုင် <strong>$1</strong> ဢၼ်ၼႄဝႆႉ).",
        "rclistfrom": "ၼႄ လွင်ႈ​လႅၵ်ႈလၢႆႈဢၼ်မႂ်ႇ တႄႇတီႈ $2, $3",
        "rcshowhideminor": "$1 လွင်ႈမူၼ်ႉမႄး ဢိတ်းဢီႈ",
index 975bb87..ea77fe1 100644 (file)
@@ -71,6 +71,7 @@
        "tog-watchlisthideminor": "Сакриј мање измене са списка надгледања",
        "tog-watchlisthideliu": "Сакриј измене пријављених корисника са списка надгледања",
        "tog-watchlistreloadautomatically": "Аутоматски освежи списак надгледања кад год се филтер измени (потребан JavaScript)",
+       "tog-watchlistunwatchlinks": "Додај дугме за укључење/искључење надгледања свакој страни на списку надгледања (потребан Јаваскрипт за ефекат укључи/искључи)",
        "tog-watchlisthideanons": "Сакриј измене анонимних корисника са списка надгледања",
        "tog-watchlisthidepatrolled": "Сакриј патролиране измене са списка надгледања",
        "tog-watchlisthidecategorization": "Сакриј категоризацију страница",
        "anonpreviewwarning": "<em>Нисте пријављени. Ако објавите страницу, Ваша IP адреса ће бити јавно видљива у њеној историји измена и другде.</em>",
        "missingsummary": "'''Подсетник:''' Нисте унели опис измене.\nАко поново кликнете на „$1”, Ваша измена ће бити сачувана без описа.",
        "selfredirect": "<strong>Упозорење:</strong> Преусмеравате ову страницу на њу саму.\nМожда вам је одредишна страница за преусмерење погрешна или уређујете погрешну страницу.\nАко још једном притиснете „$1”, преусмерење ће свеједно бити направљено.",
-       "missingcommenttext": "УнеÑ\81иÑ\82е ÐºÐ¾Ð¼ÐµÐ½Ñ\82аÑ\80 Ð¸Ñ\81под.",
+       "missingcommenttext": "Ð\9cолимо Ñ\83неÑ\81иÑ\82е ÐºÐ¾Ð¼ÐµÐ½Ñ\82аÑ\80.",
        "missingcommentheader": "<strong>Напомена:</strong> Нисте унели наслов теме овог коментара.\nАко поново кликнете на „$1”, измена ће бити сачувана без наслова.",
        "summary-preview": "Преглед описа измене:",
        "subject-preview": "Преглед теме:",
        "page_last": "последња",
        "histlegend": "Избор разлика: изаберите кутијице измена за упоређивање и притисните ентер или дугме на дну.<br />\nОбјашњење: <strong>({{int:cur}})</strong> = разлика с тренутном изменом, <strong>({{int:last}})</strong> = разлика с претходном изменом, <strong>{{int:minoreditletter}}</strong> = мала измена",
        "history-fieldset-title": "Преглед измена",
-       "history-show-deleted": "Само обрисане измјене",
+       "history-show-deleted": "Само обрисане измене",
        "histfirst": "најстарије",
        "histlast": "најновије",
        "historysize": "({{PLURAL:$1|1 бајт|$1 бајта|$1 бајтова}})",
        "timezoneregion-europe": "Европа",
        "timezoneregion-indian": "Индијски океан",
        "timezoneregion-pacific": "Тихи океан",
-       "allowemail": "Омогући примање имејла од других корисника",
+       "allowemail": "Ð\9eмогÑ\83Ñ\9bи Ð¿Ñ\80имаÑ\9aе Ð¸Ð¼ÐµÑ\98лова Ð¾Ð´ Ð´Ñ\80Ñ\83гиÑ\85 ÐºÐ¾Ñ\80иÑ\81ника",
        "prefs-searchoptions": "Претрага",
        "prefs-namespaces": "Именски простори",
        "default": "подразумевано",
        "rcfilters-grouping-title": "Груписање",
        "rcfilters-activefilters": "Активни филтери",
        "rcfilters-advancedfilters": "Напредни филтери",
-       "rcfilters-limit-title": "Приказати измјена",
-       "rcfilters-limit-shownum": "Прикажи посљедњих $1 измјена",
+       "rcfilters-limit-title": "Приказати измена",
+       "rcfilters-limit-shownum": "Прикажи последњих $1 измена",
        "rcfilters-days-title": "Претходних неколико дана",
        "rcfilters-hours-title": "Претходних неколико сати",
        "rcfilters-days-show-days": "$1 {{PLURAL:$1|дан|дана}}",
        "rcfilters-days-show-hours": "$1 {{PLURAL:$1|сат|сата}}",
        "rcfilters-highlighted-filters-list": "Истакнуто: $1",
        "rcfilters-quickfilters": "Сачувани филтери",
-       "rcfilters-quickfilters-placeholder-title": "Ð\92езе Ñ\98оÑ\88 Ñ\83век Ð½Ð¸Ñ\81Ñ\83 Ñ\83памÑ\9bене",
-       "rcfilters-quickfilters-placeholder-description": "Ð\94а Ð±Ð¸Ñ\81Ñ\82е Ñ\81аÑ\87Ñ\83вали Ñ\81воÑ\98а Ð¿Ð¾Ð´ÐµÑ\88аваÑ\9aа Ñ\84илÑ\82еÑ\80а Ð¸ Ñ\83поÑ\82Ñ\80ебÑ\99авали Ð¸Ñ\85 ÐºÐ°Ñ\81ниÑ\98е, ÐºÐ»Ð¸ÐºÐ½Ð¸Ñ\82е Ð½Ð° Ð±Ñ\83кмаÑ\80к Ð¸ÐºÐ¾Ð½Ñ\83 Ñ\83 Ð¿Ð¾Ð´Ñ\80Ñ\83Ñ\87Ñ\98Ñ\83 Ð\90кÑ\82ивни Ñ\84илÑ\82еÑ\80и, испод.",
+       "rcfilters-quickfilters-placeholder-title": "Ð\88оÑ\88 Ñ\83век Ð½ÐµÐ¼Ð° Ñ\83памÑ\9bениÑ\85 Ñ\84илÑ\82еÑ\80а",
+       "rcfilters-quickfilters-placeholder-description": "Ð\94а Ð±Ð¸Ñ\81Ñ\82е Ñ\81аÑ\87Ñ\83вали Ñ\81воÑ\98а Ð¿Ð¾Ð´ÐµÑ\88аваÑ\9aа Ñ\84илÑ\82еÑ\80а Ð¸ Ñ\83поÑ\82Ñ\80ебÑ\99авали Ð¸Ñ\85 ÐºÐ°Ñ\81ниÑ\98е, ÐºÐ»Ð¸ÐºÐ½Ð¸Ñ\82е Ð½Ð° Ð¸ÐºÐ¾Ð½Ñ\83 Ð·Ð° Ð¾Ð·Ð½Ð°ÐºÑ\83 Ñ\83 Ð¿Ð¾Ð´Ñ\80Ñ\83Ñ\87Ñ\98Ñ\83 Ð°ÐºÑ\82ивниÑ\85 Ñ\84илÑ\82еÑ\80а, испод.",
        "rcfilters-savedqueries-defaultlabel": "Сачувани филтери",
        "rcfilters-savedqueries-rename": "Преименуј",
        "rcfilters-savedqueries-setdefault": "Постави као подразумевано",
        "rcfilters-savedqueries-apply-and-setdefault-label": "Направи подразумевани филтер",
        "rcfilters-savedqueries-cancel-label": "Откажи",
        "rcfilters-savedqueries-add-new-title": "Сачувај тренутне поставке филтера",
+       "rcfilters-savedqueries-already-saved": "Ови филтери су већ упамћени",
        "rcfilters-restore-default-filters": "Враћање подразумеваних филтера",
        "rcfilters-clear-all-filters": "Уклони све филтере",
        "rcfilters-show-new-changes": "Погледајте најновије измене",
-       "rcfilters-search-placeholder": "Филтер скорашњих измјена (претражите или почните куцати)",
+       "rcfilters-search-placeholder": "Филтрирај скорашње измене (употребите мени или потражите име филтра)",
        "rcfilters-invalid-filter": "Невалидан филтер",
        "rcfilters-empty-filter": "Нема активних филтера. Сви доприноси су приказани.",
        "rcfilters-filterlist-title": "Филтери",
        "rcfilters-filterlist-whatsthis": "Како ово функционише?",
-       "rcfilters-filterlist-feedbacklink": "Дајте повратне информације о новим (бета) филтерима",
+       "rcfilters-filterlist-feedbacklink": "Дајте повратне информације о новим (бета) алатима за филтрирање",
        "rcfilters-highlightbutton-title": "Истакни резултате",
        "rcfilters-highlightmenu-title": "Одабери боју",
        "rcfilters-highlightmenu-help": "Изаберите боју да бисте истакнули ово својство",
        "rcfilters-state-message-subset": "Овај филтер нема ефекта јер су његови резултати укључени са онима {{PLURAL:$2|следећег, ширег филтера|следећих, ширих филтера}} (покушајте са означавањем да бисте их распознали): $1",
        "rcfilters-state-message-fullcoverage": "Одабир свих филтера у групи је исто као и одабир ниједног, тако да овај филтер нема ефекта. Група укључује: $1",
        "rcfilters-filtergroup-authorship": "Ауторство доприноса",
-       "rcfilters-filter-editsbyself-label": "Ваше измјене",
+       "rcfilters-filter-editsbyself-label": "Ваше измене",
        "rcfilters-filter-editsbyself-description": "Ваши доприноси.",
-       "rcfilters-filter-editsbyother-label": "Измјене других",
-       "rcfilters-filter-editsbyother-description": "Све измјене осим Ваших.",
+       "rcfilters-filter-editsbyother-label": "Измене других",
+       "rcfilters-filter-editsbyother-description": "Све измене осим Ваших.",
        "rcfilters-filtergroup-userExpLevel": "Корисничка регистрација и искуство",
        "rcfilters-filter-user-experience-level-registered-label": "Регистровани",
        "rcfilters-filter-user-experience-level-registered-description": "Пријављени уредници.",
        "rcfilters-filter-user-experience-level-unregistered-label": "Нерегистровани",
        "rcfilters-filter-user-experience-level-unregistered-description": "Уредници који нису пријављени.",
        "rcfilters-filter-user-experience-level-newcomer-label": "Новајлије",
-       "rcfilters-filter-user-experience-level-newcomer-description": "Регистровани уредници са мање од 10 измјена и 4 дана активности.",
+       "rcfilters-filter-user-experience-level-newcomer-description": "Регистровани уредници са мање од 10 измена и 4 дана активности.",
        "rcfilters-filter-user-experience-level-learner-label": "Ученици",
        "rcfilters-filter-user-experience-level-learner-description": "Регистровани уредници са више искуства од „новајлија”, али мање од „искусних корисника”.",
        "rcfilters-filter-user-experience-level-experienced-label": "Искусни корисници",
-       "rcfilters-filter-user-experience-level-experienced-description": "Регистровани уредници са више од 500 измјена и 30 дана активности.",
+       "rcfilters-filter-user-experience-level-experienced-description": "Регистровани уредници са више од 500 измена и 30 дана активности.",
        "rcfilters-filtergroup-automated": "Аутоматизовани доприноси",
        "rcfilters-filter-bots-label": "Бот",
-       "rcfilters-filter-bots-description": "Измјене направљене аутоматизованим алатима.",
-       "rcfilters-filter-humans-label": "Човјек (није бот)",
-       "rcfilters-filter-humans-description": "Измјене које су направили људи-уредници.",
+       "rcfilters-filter-bots-description": "Измене направљене аутоматизованим алатима.",
+       "rcfilters-filter-humans-label": "Човек (није бот)",
+       "rcfilters-filter-humans-description": "Измене које су направили људи-уредници.",
        "rcfilters-filtergroup-reviewstatus": "Патролираност",
        "rcfilters-filter-patrolled-label": "Патролирано",
-       "rcfilters-filter-patrolled-description": "Измјене означене као патролиране.",
+       "rcfilters-filter-patrolled-description": "Измене означене као патролиране.",
        "rcfilters-filter-unpatrolled-label": "Непатролирано",
-       "rcfilters-filter-unpatrolled-description": "Измјене које нису означене као патролиране.",
+       "rcfilters-filter-unpatrolled-description": "Измене које нису означене као патролиране.",
        "rcfilters-filtergroup-significance": "Значај",
-       "rcfilters-filter-minor-label": "Мање измјене",
-       "rcfilters-filter-minor-description": "Измјене које је аутор означио као мање.",
-       "rcfilters-filter-major-label": "Не-мање измјене",
-       "rcfilters-filter-major-description": "Измјене које нису означене као мање.",
+       "rcfilters-filter-minor-label": "Мање измене",
+       "rcfilters-filter-minor-description": "Измене које је аутор означио као мање.",
+       "rcfilters-filter-major-label": "Не-мање измене",
+       "rcfilters-filter-major-description": "Измене које нису означене као мање.",
        "rcfilters-filtergroup-watchlist": "Странице на списку надгледања",
        "rcfilters-filter-watchlist-watched-label": "На списку надгледања",
-       "rcfilters-filter-watchlist-watched-description": "Измјене страница на Вашем списку надгледања",
-       "rcfilters-filter-watchlist-watchednew-label": "Нове измјене на списку надгледања",
-       "rcfilters-filter-watchlist-watchednew-description": "Измјене страница на списку надгледања које нисте посјетили од када су направљене измјене.",
+       "rcfilters-filter-watchlist-watched-description": "Измене страница на Вашем списку надгледања.",
+       "rcfilters-filter-watchlist-watchednew-label": "Нове измене на списку надгледања",
+       "rcfilters-filter-watchlist-watchednew-description": "Измене страница на списку надгледања које нисте посетили од када су направљене измене.",
        "rcfilters-filter-watchlist-notwatched-label": "Није на списку надгледања",
-       "rcfilters-filter-watchlist-notwatched-description": "Све осим измјена страница на Вашем списку надгледања.",
-       "rcfilters-filtergroup-changetype": "Тип измјене",
-       "rcfilters-filter-pageedits-label": "Измјене страница",
-       "rcfilters-filter-pageedits-description": "Измјене вики садржаја, расправа, описа категорија…",
+       "rcfilters-filter-watchlist-notwatched-description": "Све осим измена страница на Вашем списку надгледања.",
+       "rcfilters-filtergroup-watchlistactivity": "Стање на списку надгледања",
+       "rcfilters-filter-watchlistactivity-unseen-label": "Непогледане измене",
+       "rcfilters-filter-watchlistactivity-unseen-description": "Измене страница које нисте посетили од када су направљене измене.",
+       "rcfilters-filter-watchlistactivity-seen-label": "Погледане измене",
+       "rcfilters-filter-watchlistactivity-seen-description": "Измене страница које сте посетили од када су направљене измене.",
+       "rcfilters-filtergroup-changetype": "Врста измене",
+       "rcfilters-filter-pageedits-label": "Измене страница",
+       "rcfilters-filter-pageedits-description": "Измене вики садржаја, расправа, описа категорија…",
        "rcfilters-filter-newpages-label": "Стварање страница",
-       "rcfilters-filter-newpages-description": "Измјене којима се стварају нове странице.",
-       "rcfilters-filter-categorization-label": "Измјене категорија",
+       "rcfilters-filter-newpages-description": "Измене којима се стварају нове странице.",
+       "rcfilters-filter-categorization-label": "Измене категорија",
        "rcfilters-filter-categorization-description": "Записи о страницама додатим или уклоњеним из категорија.",
-       "rcfilters-filter-logactions-label": "РадÑ\9aе Ð·Ð°Ð±Ð¸Ñ\99ежене у дневницима",
+       "rcfilters-filter-logactions-label": "РадÑ\9aе Ð·Ð°Ð±ÐµÐ»ежене у дневницима",
        "rcfilters-filter-logactions-description": "Административне акције, стварање налога, брисање страница, отпремања…",
        "rcfilters-hideminor-conflicts-typeofchange-global": "Филтер за „мање” измене је у сукобу са једним или више филтера типа измена, зато што одређени типови измена не могу да се означе као „мање”. Сукобљени филтери су означени у подручју Активни филтери, изнад.",
        "rcfilters-hideminor-conflicts-typeofchange": "Одређени типови измена не могу да се означе као „мање”, тако да је овај филтер у сукобу са следећим филтерима типа измена: $1",
        "rcfilters-typeofchange-conflicts-hideminor": "Овај филтер типа измене је у сукобу са филтером за „мање” измене. Одређени типови измена не могу да се означе као „мање”.",
-       "rcfilters-filtergroup-lastRevision": "Посљедње измјене",
-       "rcfilters-filter-lastrevision-label": "Посљедња измјена",
+       "rcfilters-filtergroup-lastRevision": "Последње измене",
+       "rcfilters-filter-lastrevision-label": "Последња измена",
        "rcfilters-filter-lastrevision-description": "Само најновија измена на страници.",
-       "rcfilters-filter-previousrevision-label": "Није посљедња измјена",
-       "rcfilters-filter-previousrevision-description": "Све измјене које нису „посљедње измјене”.",
+       "rcfilters-filter-previousrevision-label": "Није последња измена",
+       "rcfilters-filter-previousrevision-description": "Све измене које нису „последње измене”.",
        "rcfilters-filter-excluded": "Изостављено",
        "rcfilters-tag-prefix-namespace-inverted": "<strong>:није</strong> $1",
        "rcfilters-exclude-button-off": "Изостави означено",
-       "rcfilters-view-tags": "Означене измјене",
+       "rcfilters-exclude-button-on": "Изостави одабрано",
+       "rcfilters-view-tags": "Означене измене",
        "rcfilters-view-namespaces-tooltip": "Филтер резултата према именском простору",
-       "rcfilters-view-tags-tooltip": "Филтер резултата према ознаци измјене",
-       "rcfilters-view-tags-help-icon-tooltip": "Сазнајте више о означеним измјенама",
+       "rcfilters-view-tags-tooltip": "Филтрирање резултата према ознаци измене",
+       "rcfilters-view-return-to-default-tooltip": "Повратак на главни мени",
+       "rcfilters-view-tags-help-icon-tooltip": "Сазнајте више о означеним изменама",
        "rcfilters-liveupdates-button": "Ажурирања уживо",
+       "rcfilters-liveupdates-button-title-on": "Искључи ажурирања уживо",
+       "rcfilters-liveupdates-button-title-off": "Прикажи нове измене уживо",
        "rcfilters-watchlist-markseen-button": "Означи све измене као виђене",
-       "rcfilters-watchlist-showupdated": "Промјене на страницама које нисте посјетили од када је измјена извршена су <strong>подебљане</strong>, са испуњеним ознакама.",
+       "rcfilters-watchlist-edit-watchlist-button": "Промените Вашу листу надгледаних страница",
+       "rcfilters-watchlist-showupdated": "Измене на страницама које нисте посетили од када је измена извршена су <strong>подебљане</strong>, са испуњеним ознакама.",
        "rcfilters-preference-label": "Сакриј побољшану верзију скорашњих измена",
        "rcfilters-preference-help": "Поништава редизајн интерфејса из 2017. и све алатке додате тада и после.",
        "rcnotefrom": "Испод {{PLURAL:$5|је измена|су измене}} од <strong>$3, $4</strong> (до <strong>$1</strong> приказано).",
        "undeleteviewlink": "погледај",
        "undeleteinvert": "Обрни избор",
        "undeletecomment": "Разлог:",
-       "cannotundelete": "Враћање једне или свих ставник није успјело:\n$1",
+       "cannotundelete": "Враћање једне или свих није успело:\n$1",
        "undeletedpage": "<strong>Страница $1 је враћена</strong>\n\nПогледајте [[Special:Log/delete|дневник брисања]] за записе о скорашњим брисањима и враћањима.",
        "undelete-header": "Погледајте [[Special:Log/delete|историјат брисања]] за недавно обрисане странице.",
        "undelete-search-title": "Претрага обрисаних страница",
        "pageinfo-robot-index": "Дозвољено",
        "pageinfo-robot-noindex": "Није дозвољено",
        "pageinfo-watchers": "Број надгледача странице",
-       "pageinfo-visiting-watchers": "Број надгледача странице који су посјетили скорашње измјене",
+       "pageinfo-visiting-watchers": "Број надгледача странице који су посетили скорашње измене",
        "pageinfo-few-watchers": "Мање од $1 {{PLURAL:$1|пратиоца|пратиоца|пратилаца}}",
        "pageinfo-redirects-name": "Број преусмерења на ову страницу",
        "pageinfo-subpages-name": "Подстранице ове странице",
        "tag-filter-submit": "Филтрирај",
        "tag-list-wrapper": "([[Special:Tags|$1 {{PLURAL:$1|ознака|ознаке|ознака}}]]: $2)",
        "tag-mw-contentmodelchange": "промена модела садржаја",
+       "tag-mw-contentmodelchange-description": "Измене које мењају модел садржаја странице",
        "tags-title": "Ознаке",
        "tags-intro": "На овој страници је наведен списак ознака с којима програм може да означи измене и његово значење.",
        "tags-tag": "Назив ознаке",
index c4e1368..01f2e83 100644 (file)
@@ -26,7 +26,8 @@
                        "Mega Aleksandar",
                        "Asmen",
                        "Obsuser",
-                       "Zoranzoki21"
+                       "Zoranzoki21",
+                       "Prevodim"
                ]
        },
        "tog-underline": "Podvlačenje veza:",
        "page_last": "poslednja",
        "histlegend": "Izbor razlika: izaberite kutijice izmena za upoređivanje i pritisnite enter ili dugme na dnu.<br />\nObjašnjenje: <strong>({{int:cur}})</strong> = razlika s trenutnom izmenom, <strong>({{int:last}})</strong> = razlika s prethodnom izmenom, <strong>{{int:minoreditletter}}</strong> = mala izmena",
        "history-fieldset-title": "Pregled izmena",
-       "history-show-deleted": "Samo obrisane",
+       "history-show-deleted": "Samo obrisane izmene",
        "histfirst": "najstarije",
        "histlast": "najnovije",
        "historysize": "({{PLURAL:$1|1 bajt|$1 bajta|$1 bajtova}})",
        "timezoneregion-europe": "Evropa",
        "timezoneregion-indian": "Indijski okean",
        "timezoneregion-pacific": "Tihi okean",
-       "allowemail": "Omogući primanje imejla od drugih korisnika",
+       "allowemail": "Omogući primanje imejlova od drugih korisnika",
        "prefs-searchoptions": "Pretraga",
        "prefs-namespaces": "Imenski prostori",
        "default": "podrazumevano",
        "rcfilters-other-review-tools": "Ostali alati za pregled:",
        "rcfilters-activefilters": "Aktivni filteri",
        "rcfilters-advancedfilters": "Napredni filteri",
-       "rcfilters-limit-title": "Prikazati izmjena",
+       "rcfilters-limit-title": "Prikazati izmena",
        "rcfilters-limit-shownum": "Prikaži posljednjih $1 izmjena",
        "rcfilters-days-show-days": "$1 {{PLURAL:$1|dana|dana}}",
        "rcfilters-days-show-hours": "$1 {{PLURAL:$1|sat|sata}}",
+       "rcfilters-quickfilters-placeholder-description": "Da biste sačuvali svoja podešavanja filtera i upotrebljavali ih kasnije, kliknite na ikonu za oznaku u području aktivnih filtera, ispod.",
        "rcfilters-search-placeholder": "Filter skorašnjih izmjena (pretražite ili počnite kucati)",
        "rcfilters-filtergroup-authorship": "Autorstvo doprinosa",
+       "rcfilters-filter-editsbyself-label": "Vaše izmene",
+       "rcfilters-filter-editsbyother-label": "Izmene drugih",
+       "rcfilters-filter-editsbyother-description": "Sve izmene osim Vaših.",
        "rcfilters-filter-user-experience-level-registered-label": "Registrovani",
        "rcfilters-filter-user-experience-level-registered-description": "Prijavljeni urednici.",
        "rcfilters-filter-user-experience-level-unregistered-label": "Neregistrovani",
        "rcfilters-filter-user-experience-level-learner-label": "Učenici",
        "rcfilters-filter-user-experience-level-learner-description": "Više dana aktivnosti i izmjena od „novajlija”, ali manje od „iskusnih korisnika”.",
        "rcfilters-filter-user-experience-level-experienced-label": "Iskusni korisnici",
-       "rcfilters-filter-user-experience-level-experienced-description": "Preko 30 dana aktivnosti i 500 izmjena.",
-       "rcfilters-filter-humans-label": "Čovjek (nije bot)",
+       "rcfilters-filter-user-experience-level-experienced-description": "Registrovani urednici sa više od 500 izmena i 30 dana aktivnosti.",
+       "rcfilters-filter-bots-description": "Izmene napravljene automatizovanim alatima.",
+       "rcfilters-filter-humans-label": "Čovek (nije bot)",
+       "rcfilters-filter-humans-description": "Izmene koje su napravili ljudi-urednici.",
        "rcfilters-filter-patrolled-label": "Patrolirano",
+       "rcfilters-filter-patrolled-description": "Izmene označene kao patrolirane.",
        "rcfilters-filter-unpatrolled-label": "Nepatrolirano",
-       "rcfilters-filter-minor-label": "Manje izmjene",
-       "rcfilters-filter-pageedits-label": "Izmjene stranica",
-       "rcfilters-filter-pageedits-description": "Izmjene viki sadržaja, rasprava, opisa kategorija...",
+       "rcfilters-filter-unpatrolled-description": "Izmene koje nisu označene kao patrolirane.",
+       "rcfilters-filter-minor-label": "Manje izmene",
+       "rcfilters-filter-minor-description": "Izmene koje je autor označio kao manje.",
+       "rcfilters-filter-major-label": "Ne-manje izmene",
+       "rcfilters-filter-major-description": "Izmene koje nisu označene kao manje.",
+       "rcfilters-filter-watchlist-watched-description": "Izmene stranica koje su na Vašem spisku nadgledanja.",
+       "rcfilters-filter-watchlist-watchednew-label": "Nove izmene na spisku nadgledanja",
+       "rcfilters-filter-watchlist-watchednew-description": "Izmene stranica na spisku nadgledanja koje niste posetili od kada su napravljene izmene.",
+       "rcfilters-filter-watchlist-notwatched-description": "Sve osim izmena stranica na Vašem spisku nadgledanja.",
+       "rcfilters-filtergroup-changetype": "Vrsta izmene",
+       "rcfilters-filter-pageedits-label": "Izmene stranica",
+       "rcfilters-filter-pageedits-description": "Izmene viki sadržaja, rasprava, opisa kategorija...",
        "rcfilters-filter-newpages-label": "Stvaranje stranica",
-       "rcfilters-filter-newpages-description": "Izmjene kojima se stvaraju nove stranice.",
-       "rcfilters-filter-logactions-label": "Radnje zabilježene u dnevnicima",
-       "rcfilters-view-advanced-filters-label": "Napredni filteri",
+       "rcfilters-filter-newpages-description": "Izmene kojima se stvaraju nove stranice.",
+       "rcfilters-filter-categorization-label": "Izmene kategorija",
+       "rcfilters-filter-logactions-label": "Radnje zabeležene u dnevnicima",
+       "rcfilters-filtergroup-lastRevision": "Poslednje izmene",
+       "rcfilters-filter-lastrevision-label": "Poslednja izmena",
+       "rcfilters-filter-previousrevision-label": "Nije poslednja izmena",
+       "rcfilters-filter-previousrevision-description": "Sve izmene koje nisu „poslednje izmene”.",
+       "rcfilters-view-tags": "Označene izmene",
        "rcfilters-view-namespaces-tooltip": "Filter rezultata prema imenskom prostoru",
-       "rcfilters-view-tags-tooltip": "Filter rezultata prema oznaci izmjene",
+       "rcfilters-view-tags-tooltip": "Filtriranje rezultata prema oznaci izmene",
+       "rcfilters-view-tags-help-icon-tooltip": "Saznajte više o označenim izmenama",
        "rcfilters-liveupdates-button": "Ažuriranja uživo",
        "rcfilters-watchlist-markseen-button": "Označi sve izmene kao viđene",
+       "rcfilters-watchlist-showupdated": "Izmene na stranicama koje niste posetili od kada je izmena izvršena su <strong>podebljane</strong>, sa ispunjenim oznakama.",
        "rcfilters-preference-label": "Sakrij poboljšanu verziju skorašnjih izmena",
        "rcfilters-preference-help": "Poništava redizajn interfejsa iz 2017. i sve alatke dodate tada i posle.",
        "rcnotefrom": "Ispod {{PLURAL:$5|je izmena|su izmene}} od <strong>$3, $4</strong> (do <strong>$1</strong> prikazano).",
        "undeleteviewlink": "pogledaj",
        "undeleteinvert": "Obrni izbor",
        "undeletecomment": "Razlog:",
-       "cannotundelete": "Vraćanje nije uspelo:\n$1",
+       "cannotundelete": "Vraćanje jedne ili svih nije uspelo:\n$1",
        "undeletedpage": "<strong>Stranica $1 je vraćena</strong>\n\nPogledajte [[Special:Log/delete|dnevnik brisanja]] za zapise o skorašnjim brisanjima i vraćanjima.",
        "undelete-header": "Pogledajte [[Special:Log/delete|istorijat brisanja]] za nedavno obrisane stranice.",
        "undelete-search-title": "Pretraga obrisanih stranica",
        "pageinfo-robot-index": "Dozvoljeno",
        "pageinfo-robot-noindex": "Nije dozvoljeno",
        "pageinfo-watchers": "Broj nadgledača stranicе",
-       "pageinfo-visiting-watchers": "Broj nadgledača stranice koji su posjetili skorašnje izmjene",
+       "pageinfo-visiting-watchers": "Broj nadgledača stranice koji su posetili skorašnje izmene",
        "pageinfo-few-watchers": "Manje od $1 {{PLURAL:$1|pratioca|pratilaca}}",
        "pageinfo-redirects-name": "Broj preusmerenja na ovu stranicu",
        "pageinfo-subpages-name": "Podstranice ove stranice",
        "tag-filter": "Filter za [[Special:Tags|oznake]]:",
        "tag-filter-submit": "Filtriraj",
        "tag-list-wrapper": "([[Special:Tags|{{PLURAL:$1|Oznaka|Oznake}}]]: $2)",
+       "tag-mw-contentmodelchange-description": "Izmene koje menjaju model sadržaja stranice",
        "tags-title": "Oznake",
        "tags-intro": "Na ovoj stranici je naveden spisak oznaka s kojima program može da označi izmene i njegovo značenje.",
        "tags-tag": "Naziv oznake",
index e7d3c4e..0a647ad 100644 (file)
        "rcfilters-savedqueries-apply-and-setdefault-label": "Skapa standardfilter",
        "rcfilters-savedqueries-cancel-label": "Avbryt",
        "rcfilters-savedqueries-add-new-title": "Spara filterinställningar",
+       "rcfilters-savedqueries-already-saved": "Dessa filter har redan sparats",
        "rcfilters-restore-default-filters": "Återställ standardfilter",
        "rcfilters-clear-all-filters": "Rensa alla filter",
        "rcfilters-show-new-changes": "Visa de nyaste ändringarna",
        "uploadstash-refresh": "Uppdatera listan över filer",
        "uploadstash-thumbnail": "visa miniatyr",
        "uploadstash-exception": "Kunde inte lagra uppladdning i stash ($1): \"$2\".",
+       "uploadstash-bad-path": "Sökvägen finns inte",
+       "uploadstash-bad-path-invalid": "Sökvägen är ogiltig.",
+       "uploadstash-bad-path-unknown-type": "Okänd typ \"$1\".",
+       "uploadstash-bad-path-unrecognized-thumb-name": "Okänt miniatyrnamn.",
+       "uploadstash-bad-path-no-handler": "Ingen hantering hittades för MIME $1 till filen $2.",
+       "uploadstash-bad-path-bad-format": "Nyckeln \"$1\" är inte i korrekt format.",
+       "uploadstash-file-not-found": "Nyckeln \"$1\" hittades inte i stash.",
+       "uploadstash-file-not-found-no-thumb": "Kunde inte hämta miniatyrbild.",
+       "uploadstash-file-not-found-no-local-path": "Ingen lokal sökväg för nedskalat objekt.",
+       "uploadstash-file-not-found-no-object": "Kunde inte skapa lokalt filobjekt för miniatyr.",
+       "uploadstash-file-not-found-no-remote-thumb": "Misslyckades att hämta miniatyrbild: $1\nURL = $2",
+       "uploadstash-file-not-found-missing-content-type": "Header för content-type saknas.",
+       "uploadstash-file-not-found-not-exists": "Kan inte hitta sökvägen eller filen består inte av ren text.",
+       "uploadstash-file-too-large": "Kan inte behandla en fil som är större än $1 byte.",
+       "uploadstash-not-logged-in": "Ingen användare är inloggad, filer måste tillhöra användare.",
+       "uploadstash-wrong-owner": "Denna fil ($1) tillhör inte aktuell användare.",
+       "uploadstash-no-such-key": "Ingen sådan nyckel ($1), kan inte ta bort.",
+       "uploadstash-no-extension": "Tillägget är null.",
+       "uploadstash-zero-length": "Filens längd är noll.",
        "invalid-chunk-offset": "Ogiltig segmentsförskjutning",
        "img-auth-accessdenied": "Åtkomst nekad",
        "img-auth-nopathinfo": "PATH_INFO saknas.\nDin server är inte inställd för att ge denna information.\nDen kan vara CGI-baserad och stöder inte img_auth.\n[https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization Se bildbehörighet.]",
index e21a647..c82fc91 100644 (file)
        "htmlform-user-not-valid": "<strong>$1</strong> 不是有效的使用者名稱。",
        "logentry-delete-delete": "$1 刪除頁面 $3",
        "logentry-delete-delete_redir": "$1 透過覆寫{{GENDER:$2|刪除了}}重新導向 $3",
-       "logentry-delete-restore": "$1{{GENDER:$2|還原}}頁面 $3($4)",
+       "logentry-delete-restore": "$1 {{GENDER:$2|還原}}頁面 $3($4)",
        "logentry-delete-restore-nocount": "$1 {{GENDER:$2|已還原}}頁面 $3",
        "restore-count-revisions": "{{PLURAL:$1|1 修訂|$1 修訂}}",
        "restore-count-files": "{{PLURAL:$1|1 檔案|$1 檔案}}",
index 0dcfe2d..89c6e9a 100644 (file)
@@ -7,6 +7,7 @@
  * @file
  *
  * @author Alchimista
+ * @author Athena
  * @author Cecílio
  * @author MCruz
  * @author Malafaya
@@ -20,8 +21,8 @@ $namespaceNames = [
        NS_MEDIA            => 'Media',
        NS_SPECIAL          => 'Special',
        NS_TALK             => 'Cumbersa',
-       NS_USER             => 'Outelizador',
-       NS_USER_TALK        => 'Cumbersa_outelizador',
+       NS_USER             => 'Outelizador(a)',
+       NS_USER_TALK        => 'Cumbersa_outelizador(a)',
        NS_PROJECT_TALK     => '$1_cumbersa',
        NS_FILE             => 'Fexeiro',
        NS_FILE_TALK        => 'Cumbersa_fexeiro',
@@ -53,11 +54,16 @@ $namespaceAliases = [
        'Categoria_Discussão' => NS_CATEGORY_TALK,
 ];
 
+$namespaceGenderAliases = [
+       NS_USER => [ 'male' => 'Outelizador', 'female' => 'Outelizadora' ],
+       NS_USER_TALK => [ 'male' => 'Cumbersa_outelizador', 'female' => 'Cumbersa_outelizadora' ],
+]; // T180052
+
 $specialPageAliases = [
-       'CreateAccount'             => [ 'Criar Cuonta' ],
-       'Lonelypages'               => [ 'Páiginas Uorfanas' ],
-       'Uncategorizedcategories'   => [ 'Catadories sien catadories' ],
-       'Uncategorizedimages'       => [ 'Eimaiges sien catadories' ],
+       'CreateAccount'             => [ 'Criar_Cuonta' ],
+       'Lonelypages'               => [ 'Páiginas_Uorfanas' ],
+       'Uncategorizedcategories'   => [ 'Catadories_sien_catadories' ],
+       'Uncategorizedimages'       => [ 'Eimaiges_sien_catadories' ],
        'Userlogin'                 => [ 'Antrar' ],
        'Userlogout'                => [ 'Salir' ],
 ];
index b504bde..e5b4c13 100644 (file)
@@ -25,7 +25,7 @@ class CheckComposerLockUpToDate extends Maintenance {
                        $lockLocation = "$IP/vendor/composer.lock";
                        if ( !file_exists( $lockLocation ) ) {
                                $this->error(
-                                       'Could not find composer.lock file. Have you run "composer install"?',
+                                       'Could not find composer.lock file. Have you run "composer install --no-dev"?',
                                        1
                                );
                        }
@@ -53,7 +53,7 @@ class CheckComposerLockUpToDate extends Maintenance {
                if ( $found ) {
                        $this->error(
                                'Error: your composer.lock file is not up to date. ' .
-                                       'Run "composer update" to install newer dependencies',
+                                       'Run "composer update --no-dev" to install newer dependencies',
                                1
                        );
                } else {
index eb9797f..04ad255 100644 (file)
@@ -60,8 +60,6 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance {
                $updatedValues = $this->buildUpdateCondition( $dbw );
 
                while ( $blockEnd <= $end ) {
-                       $cond = "rc_id BETWEEN $blockStart AND $blockEnd";
-
                        $dbw->update(
                                'recentchanges',
                                [ $updatedValues ],
diff --git a/maintenance/userOptions.inc b/maintenance/userOptions.inc
deleted file mode 100644 (file)
index 8ac7f91..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-<?php
-/**
- * Helper class for userOptions.php script.
- *
- * 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
- */
-
-// Options we will use
-$options = [ 'list', 'nowarn', 'quiet', 'usage', 'dry' ];
-$optionsWithArgs = [ 'old', 'new' ];
-
-require_once __DIR__ . '/commandLine.inc';
-
-/**
- * @ingroup Maintenance
- */
-class UserOptions {
-       public $mQuick;
-       public $mQuiet;
-       public $mDry;
-       public $mAnOption;
-       public $mOldValue;
-       public $mNewValue;
-
-       private $mMode, $mReady;
-
-       /**
-        * Constructor. Will show usage and exit if script options are not correct
-        * @param array $opts
-        * @param array $args
-        */
-       function __construct( $opts, $args ) {
-               if ( !$this->checkOpts( $opts, $args ) ) {
-                       self::showUsageAndExit();
-               } else {
-                       $this->mReady = $this->initializeOpts( $opts, $args );
-               }
-       }
-
-       /**
-        * This is used to check options. Only needed on construction
-        *
-        * @param array $opts
-        * @param array $args
-        *
-        * @return bool
-        */
-       private function checkOpts( $opts, $args ) {
-               // The three possible ways to run the script:
-               $list = isset( $opts['list'] );
-               $usage = isset( $opts['usage'] ) && ( count( $args ) <= 1 );
-               $change = isset( $opts['old'] ) && isset( $opts['new'] ) && ( count( $args ) <= 1 );
-
-               // We want only one of them
-               $isValid = ( ( $list + $usage + $change ) == 1 );
-
-               return $isValid;
-       }
-
-       /**
-        * load script options in the object
-        *
-        * @param array $opts
-        * @param array $args
-        *
-        * @return bool
-        */
-       private function initializeOpts( $opts, $args ) {
-               $this->mQuick = isset( $opts['nowarn'] );
-               $this->mQuiet = isset( $opts['quiet'] );
-               $this->mDry = isset( $opts['dry'] );
-
-               // Set object properties, specially 'mMode' used by run()
-               if ( isset( $opts['list'] ) ) {
-                       $this->mMode = 'LISTER';
-               } elseif ( isset( $opts['usage'] ) ) {
-                       $this->mMode = 'USAGER';
-                       $this->mAnOption = isset( $args[0] ) ? $args[0] : false;
-               } elseif ( isset( $opts['old'] ) && isset( $opts['new'] ) ) {
-                       $this->mMode = 'CHANGER';
-                       $this->mOldValue = $opts['old'];
-                       $this->mNewValue = $opts['new'];
-                       $this->mAnOption = $args[0];
-               } else {
-                       die( "There is a bug in the software, this should never happen\n" );
-               }
-
-               return true;
-       }
-
-       /**
-        * Dumb stuff to run a mode.
-        * @return bool
-        */
-       public function run() {
-               if ( !$this->mReady ) {
-                       return false;
-               }
-
-               $this->{$this->mMode}();
-
-               return true;
-       }
-
-       /**
-        * List default options and their value
-        */
-       private function LISTER() {
-               $def = User::getDefaultOptions();
-               ksort( $def );
-               $maxOpt = 0;
-               foreach ( $def as $opt => $value ) {
-                       $maxOpt = max( $maxOpt, strlen( $opt ) );
-               }
-               foreach ( $def as $opt => $value ) {
-                       printf( "%-{$maxOpt}s: %s\n", $opt, $value );
-               }
-       }
-
-       /**
-        * List options usage
-        */
-       private function USAGER() {
-               $ret = [];
-               $defaultOptions = User::getDefaultOptions();
-
-               // We list user by user_id from one of the replica DBs
-               $dbr = wfGetDB( DB_REPLICA );
-               $result = $dbr->select( 'user',
-                       [ 'user_id' ],
-                       [],
-                       __METHOD__
-               );
-
-               foreach ( $result as $id ) {
-                       $user = User::newFromId( $id->user_id );
-
-                       // Get the options and update stats
-                       if ( $this->mAnOption ) {
-                               if ( !array_key_exists( $this->mAnOption, $defaultOptions ) ) {
-                                       print "Invalid user option. Use --list to see valid choices\n";
-                                       exit;
-                               }
-
-                               $userValue = $user->getOption( $this->mAnOption );
-                               if ( $userValue <> $defaultOptions[$this->mAnOption] ) {
-                                       // @codingStandardsIgnoreStart Ignore silencing errors is discouraged warning
-                                       @$ret[$this->mAnOption][$userValue]++;
-                                       // @codingStandardsIgnoreEnd
-                               }
-                       } else {
-
-                               foreach ( $defaultOptions as $name => $defaultValue ) {
-                                       $userValue = $user->getOption( $name );
-                                       if ( $userValue <> $defaultValue ) {
-                                               // @codingStandardsIgnoreStart Ignore silencing errors is discouraged warning
-                                               @$ret[$name][$userValue]++;
-                                               // @codingStandardsIgnoreEnd
-                                       }
-                               }
-                       }
-               }
-
-               foreach ( $ret as $optionName => $usageStats ) {
-                       print "Usage for <$optionName> (default: '{$defaultOptions[$optionName]}'):\n";
-                       foreach ( $usageStats as $value => $count ) {
-                               print " $count user(s): '$value'\n";
-                       }
-                       print "\n";
-               }
-       }
-
-       /**
-        * Change our users options
-        */
-       private function CHANGER() {
-               $this->warn();
-
-               // We list user by user_id from one of the replica DBs
-               $dbr = wfGetDB( DB_REPLICA );
-               $result = $dbr->select( 'user',
-                       [ 'user_id' ],
-                       [],
-                       __METHOD__
-               );
-
-               foreach ( $result as $id ) {
-                       $user = User::newFromId( $id->user_id );
-
-                       $curValue = $user->getOption( $this->mAnOption );
-                       $username = $user->getName();
-
-                       if ( $curValue == $this->mOldValue ) {
-                               if ( !$this->mQuiet ) {
-                                       print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' " .
-                                               "to '{$this->mNewValue}'): ";
-                               }
-
-                               // Change value
-                               $user->setOption( $this->mAnOption, $this->mNewValue );
-
-                               // Will not save the settings if run with --dry
-                               if ( !$this->mDry ) {
-                                       $user->saveSettings();
-                               }
-                               if ( !$this->mQuiet ) {
-                                       print " OK\n";
-                               }
-                       } elseif ( !$this->mQuiet ) {
-                               print "Not changing '$username' using <{$this->mAnOption}> = '$curValue'\n";
-                       }
-               }
-       }
-
-       /**
-        * Return an array of option names
-        * @return array
-        */
-       public static function getDefaultOptionsNames() {
-               $def = User::getDefaultOptions();
-               $ret = [];
-               foreach ( $def as $optname => $defaultValue ) {
-                       array_push( $ret, $optname );
-               }
-
-               return $ret;
-       }
-
-       public static function showUsageAndExit() {
-               print <<<USAGE
-
-This script pass through all users and change one of their options.
-The new option is NOT validated.
-
-Usage:
-       php userOptions.php --list
-       php userOptions.php [user option] --usage
-       php userOptions.php [options] <user option> --old <old value> --new <new value>
-
-Switchs:
-       --list : list available user options and their default value
-
-       --usage : report all options statistics or just one if you specify it.
-
-       --old <old value> : the value to look for
-       --new <new value> : new value to update users with
-
-Options:
-       --nowarn: hides the 5 seconds warning
-       --quiet : do not print what is happening
-       --dry   : do not save user settings back to database
-
-USAGE;
-               exit( 0 );
-       }
-
-       /**
-        * The warning message and countdown
-        * @return bool
-        */
-       public function warn() {
-               if ( $this->mQuick ) {
-                       return true;
-               }
-
-               print <<<WARN
-The script is about to change the skin for ALL USERS in the database.
-Users with option <$this->mAnOption> = '$this->mOldValue' will be made to use '$this->mNewValue'.
-
-Abort with control-c in the next five seconds....
-WARN;
-               wfCountDown( 5 );
-
-               return true;
-       }
-}
index 53db48c..7cf16b6 100644 (file)
  * @author Antoine Musso <hashar at free dot fr>
  */
 
-// This is a command line script, load tools and parse args
-require_once 'userOptions.inc';
+require_once __DIR__ . '/Maintenance.php';
 
-// Load up our tool system, exit with usage() if options are not fine
-$uo = new UserOptions( $options, $args );
+/**
+ * @ingroup Maintenance
+ */
+class UserOptionsMaintenance extends Maintenance {
+
+       function __construct() {
+               parent::__construct();
+
+               $this->addDescription( 'Pass through all users and change one of their options.
+The new option is NOT validated.' );
+
+               $this->addOption( 'list', 'List available user options and their default value' );
+               $this->addOption( 'usage', 'Report all options statistics or just one if you specify it' );
+               $this->addOption( 'old', 'The value to look for', false, true );
+               $this->addOption( 'new', 'Rew value to update users with', false, true );
+               $this->addOption( 'nowarn', 'Hides the 5 seconds warning' );
+               $this->addOption( 'dry', 'Do not save user settings back to database' );
+               $this->addArg( 'option name', 'Name of the option to change or provide statistics about', false );
+       }
+
+       /**
+        * Do the actual work
+        */
+       public function execute() {
+               if ( $this->hasOption( 'list' ) ) {
+                       $this->listAvailableOptions();
+               } elseif ( $this->hasOption( 'usage' ) ) {
+                       $this->showUsageStats();
+               } elseif ( $this->hasOption( 'old' )
+                       && $this->hasOption( 'new' )
+                       && $this->hasArg( 0 )
+               ) {
+                       $this->updateOptions();
+               } else {
+                       $this->maybeHelp( /* force = */ true );
+               }
+       }
+
+       /**
+        * List default options and their value
+        */
+       private function listAvailableOptions() {
+               $def = User::getDefaultOptions();
+               ksort( $def );
+               $maxOpt = 0;
+               foreach ( $def as $opt => $value ) {
+                       $maxOpt = max( $maxOpt, strlen( $opt ) );
+               }
+               foreach ( $def as $opt => $value ) {
+                       $this->output( sprintf( "%-{$maxOpt}s: %s\n", $opt, $value ) );
+               }
+       }
+
+       /**
+        * List options usage
+        */
+       private function showUsageStats() {
+               $option = $this->getArg( 0 );
+
+               $ret = [];
+               $defaultOptions = User::getDefaultOptions();
+
+               // We list user by user_id from one of the replica DBs
+               $dbr = wfGetDB( DB_REPLICA );
+               $result = $dbr->select( 'user',
+                       [ 'user_id' ],
+                       [],
+                       __METHOD__
+               );
+
+               foreach ( $result as $id ) {
+                       $user = User::newFromId( $id->user_id );
+
+                       // Get the options and update stats
+                       if ( $option ) {
+                               if ( !array_key_exists( $option, $defaultOptions ) ) {
+                                       $this->error( "Invalid user option. Use --list to see valid choices\n", 1 );
+                               }
+
+                               $userValue = $user->getOption( $option );
+                               if ( $userValue <> $defaultOptions[$option] ) {
+                                       // @codingStandardsIgnoreStart Ignore silencing errors is discouraged warning
+                                       @$ret[$option][$userValue]++;
+                                       // @codingStandardsIgnoreEnd
+                               }
+                       } else {
+
+                               foreach ( $defaultOptions as $name => $defaultValue ) {
+                                       $userValue = $user->getOption( $name );
+                                       if ( $userValue != $defaultValue ) {
+                                               // @codingStandardsIgnoreStart Ignore silencing errors is discouraged warning
+                                               @$ret[$name][$userValue]++;
+                                               // @codingStandardsIgnoreEnd
+                                       }
+                               }
+                       }
+               }
+
+               foreach ( $ret as $optionName => $usageStats ) {
+                       $this->output( "Usage for <$optionName> (default: '{$defaultOptions[$optionName]}'):\n" );
+                       foreach ( $usageStats as $value => $count ) {
+                               $this->output( " $count user(s): '$value'\n" );
+                       }
+                       print "\n";
+               }
+       }
+
+       /**
+        * Change our users options
+        */
+       private function updateOptions() {
+               $dryRun = $this->hasOption( 'dry' );
+               $option = $this->getArg( 0 );
+               $from = $this->getOption( 'old' );
+               $to = $this->getOption( 'new' );
+
+               if ( !$dryRun ) {
+                       $this->warn( $option, $from, $to );
+               }
+
+               // We list user by user_id from one of the replica DBs
+               // @todo: getting all users in one query does not scale
+               $dbr = wfGetDB( DB_REPLICA );
+               $result = $dbr->select( 'user',
+                       [ 'user_id' ],
+                       [],
+                       __METHOD__
+               );
+
+               foreach ( $result as $id ) {
+                       $user = User::newFromId( $id->user_id );
+
+                       $curValue = $user->getOption( $option );
+                       $username = $user->getName();
+
+                       if ( $curValue == $from ) {
+                               $this->output( "Setting {$option} for $username from '{$from}' to '{$to}'): " );
+
+                               // Change value
+                               $user->setOption( $option, $to );
+
+                               // Will not save the settings if run with --dry
+                               if ( !$dryRun ) {
+                                       $user->saveSettings();
+                               }
+                               $this->output( " OK\n" );
+                       } else {
+                               $this->output( "Not changing '$username' using <{$option}> = '$curValue'\n" );
+                       }
+               }
+       }
+
+       /**
+        * The warning message and countdown
+        *
+        * @param string $option
+        * @param string $from
+        * @param string $to
+        */
+       private function warn( $option, $from, $to ) {
+               if ( $this->hasOption( 'nowarn' ) ) {
+                       return;
+               }
+
+               $this->output( <<<WARN
+The script is about to change the options for ALL USERS in the database.
+Users with option <$option> = '$from' will be made to use '$to'.
 
-$uo->run();
+Abort with control-c in the next five seconds....
+WARN
+               );
+               $this->countDown( 5 );
+       }
+}
 
-print "Done.\n";
+$maintClass = 'UserOptionsMaintenance';
+require RUN_MAINTENANCE_IF_MAIN;
index cad530b..73ec1a7 100644 (file)
@@ -11,6 +11,7 @@
 
 #pagehistory li.selected {
        background-color: #f8f9fa;
+       color: #252525;
        border: 1px dashed #a2a9b1;
 }
 
index 6931c7d..58e00f9 100644 (file)
@@ -69,16 +69,16 @@ a.stub {
 }
 
 /* Expand URLs for printing */
-.mw-body-content a.external.text:after,
-.mw-body-content a.external.autonumber:after {
+.mw-parser-output a.external.text:after,
+.mw-parser-output a.external.autonumber:after {
        content: ' (' attr( href ) ')';
        word-break: break-all;
        word-wrap: break-word;
 }
 
 /* Expand protocol-relative URLs for printing */
-.mw-body-content a.external.text[ href^='//' ]:after,
-.mw-body-content a.external.autonumber[ href^='//' ]:after {
+.mw-parser-output a.external.text[ href^='//' ]:after,
+.mw-parser-output a.external.autonumber[ href^='//' ]:after {
        content: ' (https:' attr( href ) ')';
 }
 
index 3a6efe2..d959540 100644 (file)
                this.getItemByName( filterName ).clearHighlightColor();
        };
 
-       /**
-        * Clear highlight for all filter items
-        */
-       mw.rcfilters.dm.FiltersViewModel.prototype.clearAllHighlightColors = function () {
-               this.getItems().forEach( function ( filterItem ) {
-                       filterItem.clearHighlightColor();
-               } );
-       };
-
        /**
         * Return a version of the given string that is without any
         * view triggers.
index 7b54833..44b6c8c 100644 (file)
@@ -41,7 +41,6 @@
                // Highlight
                this.cssClass = config.cssClass;
                this.highlightColor = config.defaultHighlightColor;
-               this.highlightEnabled = !!config.defaultHighlightColor;
        };
 
        /* Initialization */
index 23f6007..1d7934f 100644 (file)
                // Return parameter representation
                return this.filtersModel.getMinimizedParamRepresentation( $.extend( true, {},
                        this.filtersModel.getParametersFromFilters( savedFilters ),
-                       data.highlights,
-                       { highlight: data.params.highlight }
+                       data.highlights
                ) );
        };
 
index 28b94e4..d519648 100644 (file)
         * Reset to default filters
         */
        mw.rcfilters.Controller.prototype.resetToDefaults = function () {
-               this.filtersModel.updateStateFromParams( this._getDefaultParams() );
-
-               this.updateChangesList();
+               if ( this.applyParamChange( this._getDefaultParams() ) ) {
+                       // Only update the changes list if there was a change to actual filters
+                       this.updateChangesList();
+               }
        };
 
        /**
         * Empty all selected filters
         */
        mw.rcfilters.Controller.prototype.emptyFilters = function () {
-               var highlightedFilterNames = this.filtersModel
-                       .getHighlightedItems()
+               var highlightedFilterNames = this.filtersModel.getHighlightedItems()
                        .map( function ( filterItem ) { return { name: filterItem.getName() }; } );
 
-               this.filtersModel.updateStateFromParams( {} );
-
-               this.updateChangesList();
+               if ( this.applyParamChange( {} ) ) {
+                       // Only update the changes list if there was a change to actual filters
+                       this.updateChangesList();
+               }
 
                if ( highlightedFilterNames ) {
                        this._trackHighlight( 'clearAll', highlightedFilterNames );
                        return;
                }
 
-               // Apply parameters to model
-               this.filtersModel.updateStateFromParams( params );
-
-               this.updateChangesList();
+               if ( this.applyParamChange( params ) ) {
+                       // Update changes list only if there was a difference in filter selection
+                       this.updateChangesList();
+               }
 
                // Log filter grouping
                this.trackFilterGroupings( 'savedfilters' );
                }
        };
 
+       /**
+        * Apply a change of parameters to the model state, and check whether
+        * the new state is different than the old state.
+        *
+        * @param  {Object} newParamState New parameter state to apply
+        * @return {boolean} New applied model state is different than the previous state
+        */
+       mw.rcfilters.Controller.prototype.applyParamChange = function ( newParamState ) {
+               var after,
+                       before = this.filtersModel.getSelectedState();
+
+               this.filtersModel.updateStateFromParams( newParamState );
+
+               after = this.filtersModel.getSelectedState();
+
+               return !OO.compare( before, after );
+       };
+
        /**
         * Mark all changes as seen on Watchlist
         */
index 2a64aa3..d82ffe0 100644 (file)
@@ -9,7 +9,7 @@
  * compatibility ( browsers able to understand gradient syntax support also SVG ).
  * http://pauginer.tumblr.com/post/36614680636/invisible-gradient-technique */
 
-.mw-body-content a.external,
+.mw-parser-output a.external,
 .link-https {
        background: url( images/external-ltr.png ) center right no-repeat;
        /* @embed */
@@ -19,7 +19,7 @@
        padding-right: 15px;
 }
 
-.mw-body-content a.external[ href^='mailto:' ],
+.mw-parser-output a.external[ href^='mailto:' ],
 .link-mailto {
        background: url( images/mail.png ) center right no-repeat;
        /* @embed */
@@ -27,7 +27,7 @@
        padding-right: 15px;
 }
 
-.mw-body-content a.external[ href^='ftp://' ],
+.mw-parser-output a.external[ href^='ftp://' ],
 .link-ftp {
        background: url( images/ftp-ltr.png ) center right no-repeat;
        /* @embed */
@@ -35,8 +35,8 @@
        padding-right: 15px;
 }
 
-.mw-body-content a.external[ href^='irc://' ],
-.mw-body-content a.external[ href^='ircs://' ],
+.mw-parser-output a.external[ href^='irc://' ],
+.mw-parser-output a.external[ href^='ircs://' ],
 .link-irc {
        background: url( images/chat-ltr.png ) center right no-repeat;
        /* @embed */
        padding-right: 15px;
 }
 
-.mw-body-content a.external[ href$='.ogg' ],
-.mw-body-content a.external[ href$='.OGG' ],
-.mw-body-content a.external[ href$='.mid' ],
-.mw-body-content a.external[ href$='.MID' ],
-.mw-body-content a.external[ href$='.midi' ],
-.mw-body-content a.external[ href$='.MIDI' ],
-.mw-body-content a.external[ href$='.mp3' ],
-.mw-body-content a.external[ href$='.MP3' ],
-.mw-body-content a.external[ href$='.wav' ],
-.mw-body-content a.external[ href$='.WAV' ],
-.mw-body-content a.external[ href$='.wma' ],
-.mw-body-content a.external[ href$='.WMA' ],
+.mw-parser-output a.external[ href$='.ogg' ],
+.mw-parser-output a.external[ href$='.OGG' ],
+.mw-parser-output a.external[ href$='.mid' ],
+.mw-parser-output a.external[ href$='.MID' ],
+.mw-parser-output a.external[ href$='.midi' ],
+.mw-parser-output a.external[ href$='.MIDI' ],
+.mw-parser-output a.external[ href$='.mp3' ],
+.mw-parser-output a.external[ href$='.MP3' ],
+.mw-parser-output a.external[ href$='.wav' ],
+.mw-parser-output a.external[ href$='.WAV' ],
+.mw-parser-output a.external[ href$='.wma' ],
+.mw-parser-output a.external[ href$='.WMA' ],
 .link-audio {
        background: url( images/audio-ltr.png ) center right no-repeat;
        /* @embed */
        padding-right: 15px;
 }
 
-.mw-body-content a.external[ href$='.ogm' ],
-.mw-body-content a.external[ href$='.OGM' ],
-.mw-body-content a.external[ href$='.avi' ],
-.mw-body-content a.external[ href$='.AVI' ],
-.mw-body-content a.external[ href$='.mpeg' ],
-.mw-body-content a.external[ href$='.MPEG' ],
-.mw-body-content a.external[ href$='.mpg' ],
-.mw-body-content a.external[ href$='.MPG' ],
+.mw-parser-output a.external[ href$='.ogm' ],
+.mw-parser-output a.external[ href$='.OGM' ],
+.mw-parser-output a.external[ href$='.avi' ],
+.mw-parser-output a.external[ href$='.AVI' ],
+.mw-parser-output a.external[ href$='.mpeg' ],
+.mw-parser-output a.external[ href$='.MPEG' ],
+.mw-parser-output a.external[ href$='.mpg' ],
+.mw-parser-output a.external[ href$='.MPG' ],
 .link-video {
        background: url( images/video.png ) center right no-repeat;
        /* @embed */
        padding-right: 15px;
 }
 
-.mw-body-content a.external[ href$='.pdf' ],
-.mw-body-content a.external[ href$='.PDF' ],
-.mw-body-content a.external[ href*='.pdf#' ],
-.mw-body-content a.external[ href*='.PDF#' ],
-.mw-body-content a.external[ href*='.pdf?' ],
-.mw-body-content a.external[ href*='.PDF?' ],
+.mw-parser-output a.external[ href$='.pdf' ],
+.mw-parser-output a.external[ href$='.PDF' ],
+.mw-parser-output a.external[ href*='.pdf#' ],
+.mw-parser-output a.external[ href*='.PDF#' ],
+.mw-parser-output a.external[ href*='.pdf?' ],
+.mw-parser-output a.external[ href*='.PDF?' ],
 .link-document {
        background: url( images/document-ltr.png ) center right no-repeat;
        /* @embed */
 }
 
 /* Interwiki styling */
-.mw-body-content a.extiw,
-.mw-body-content a.extiw:active {
+.mw-parser-output a.extiw,
+.mw-parser-output a.extiw:active {
        color: #36b;
 }
 
 /* External link color */
-.mw-body-content a.external {
+.mw-parser-output a.external {
        color: #36b;
 }
index 366c5a9..3599f34 100644 (file)
@@ -53,33 +53,33 @@ a.new:visited,
 }
 
 /* Interwiki Styling */
-.mw-body-content a.extiw,
-.mw-body-content a.extiw:active {
+.mw-parser-output a.extiw,
+.mw-parser-output a.extiw:active {
        color: #36b;
 }
 
-.mw-body-content a.extiw:visited {
+.mw-parser-output a.extiw:visited {
        color: #636;
 }
 
-.mw-body-content a.extiw:active {
+.mw-parser-output a.extiw:active {
        color: #b63;
 }
 
 /* External links */
-.mw-body-content a.external {
+.mw-parser-output a.external {
        color: #36b;
 }
 
-.mw-body-content a.external:visited {
+.mw-parser-output a.external:visited {
        color: #636; /* T5112 */
 }
 
-.mw-body-content a.external:active {
+.mw-parser-output a.external:active {
        color: #b63;
 }
 
-.mw-body-content a.external.free {
+.mw-parser-output a.external.free {
        word-wrap: break-word;
 }
 
index 3e0d2b9..8cd25d8 100644 (file)
@@ -22,6 +22,7 @@ textarea {
 
 .editOptions {
        background-color: #eaecf0;
+       color: #252525;
        border: 1px solid #c8ccd1;
        border-top: 0;
        padding: 1em 1em 1.5em 1em;
index 47f8045..9750452 100644 (file)
        user-select: none;
 }
 
-@indicator-size: unit( 12 / 16 / 0.8, em );
+@size-indicator: unit( 12 / 16 / 0.8, em );
 
 .mw-widget-dateInputWidget {
        &-handle {
                .oo-ui-unselectable();
 
-               > .oo-ui-labelElement-label {
-                       padding: 0;
-               }
-
                > .oo-ui-indicatorElement-indicator {
                        display: none;
                }
                position: absolute;
                top: 0;
                right: 0;
-               width: @indicator-size;
+               width: @size-indicator;
                height: 100%;
                margin: 0 0.775em;
        }
 
        > .oo-ui-textInputWidget {
                z-index: 2;
-
-               & input {
-                       padding-left: 1em;
-               }
        }
 
        &-calendar {
                background-color: #fff;
                position: absolute;
                margin-top: -2px;
-               box-shadow: 0 0.15em 0 0 rgba( 0, 0, 0, 0.15 );
+               border-radius: 2px;
+               box-shadow: 0 2px 2px 0 rgba( 0, 0, 0, 0.25 );
                z-index: 1;
 
                &:focus {
-                       box-shadow: inset 0 0 0 1px #36c, 0 0.15em 0 0 rgba( 0, 0, 0, 0.15 );
+                       box-shadow: inset 0 0 0 1px #36c, 0 2px 2px 0 rgba( 0, 0, 0, 0.25 );
                        z-index: 3;
                }
        }
@@ -68,8 +61,8 @@
 
        &.oo-ui-flaggedElement-invalid {
                .mw-widget-dateInputWidget-handle {
-                       border-color: #f00;
-                       box-shadow: inset 0 0 0 0 #f00;
+                       border-color: #d33;
+                       box-shadow: none;
                }
        }
 
index 18cf723..74b5abc 100644 (file)
@@ -5,6 +5,32 @@
  * @license The MIT License (MIT); see LICENSE.txt
  */
 
+// Variables taken from OOUI's WikimediaUI theme
+@oo-ui-font-size-browser: 16; // assumed browser default of `16px`
+@oo-ui-font-size-base: 0.8em; // equals `12.8px` at browser default of `16px`
+
+@background-color-base: #fff;
+
+@color-base--emphasized: #000;
+
+@border-base: 1px solid #a2a9b1;
+@border-color-base--focus: #36c;
+@border-color-input--hover: #72777d;
+@border-radius-base: 2px;
+
+@padding-input-text: @padding-top-base @padding-horizontal-input-text @padding-bottom-base;
+@padding-horizontal-input-text: 8 / @oo-ui-font-size-browser / @oo-ui-font-size-base;
+@padding-top-base: 8 / @oo-ui-font-size-browser / @oo-ui-font-size-base; // equals `0.625em`≈`8px`
+@padding-bottom-base: 7 / @oo-ui-font-size-browser / @oo-ui-font-size-base; // equals `0.547em`≈`7px`
+
+@box-shadow-widget: inset 0 0 0 1px transparent;
+@box-shadow-widget--focus: inset 0 0 0 1px #36c;
+
+@line-height-widget-singleline: 1.172em; // Firefox needs a value, Chrome the unit; equals `15px` at base `font-size: 12.8px`
+
+@transition-ease-out-sine-medium: 200ms cubic-bezier( 0.39, 0.575, 0.565, 1 );
+
+// Mixins taken from OOUI
 .oo-ui-box-sizing( @type: border-box ) {
        -webkit-box-sizing: @type;
        -moz-box-sizing: @type;
        }
 }
 
+.oo-ui-transition( @value1, @value2: X, ... ) {
+       @value: ~`"@{arguments}".replace( /[\[\]]|\,\sX/g, '' )`; // stylelint-disable-line function-comma-space-after, function-whitespace-after, string-quotes, value-keyword-case
+       -webkit-transition: @value;
+       -moz-transition: @value;
+       transition: @value;
+}
+
+// DateInputWidget rules
 .mw-widget-dateInputWidget {
        &.oo-ui-textInputWidget {
                display: inline-block;
                position: relative;
                width: 21em;
                margin-top: 0.25em;
-               .oo-ui-inline-spacing( 0.5em );
+               // .oo-ui-inline-spacing( 0.5em ); already inherited from `.oo-ui-inputWidget`
                margin-bottom: 0.25em;
                margin-left: 0;
        }
        // Note that this block applies to both the PHP widget and the JS widget
        &-handle,
        &.oo-ui-textInputWidget input {
-               background-color: #fff;
                display: inline-block;
                position: relative;
-               .oo-ui-box-sizing( border-box );
-               width: 100%;
                cursor: pointer;
-               padding: 0.5em 1em;
-               border: 1px solid #a2a9b1;
-               border-radius: 2px;
-               outline: 0;
-               line-height: 1.275;
                /**
                 * Ensures non-infused and infused widget have the same height.
                 * Equal to line height + top padding + bottom padding
                 */
-               height: 2.275em;
+               max-height: 2.458em;
+       }
+
+       // Ensure `.mw-widget-dateInputWidget-handle` similar appearance to OOUI's `.oo-ui-textInputWidget`
+       &-handle {
+               background-color: @background-color-base;
+               color: @color-base--emphasized;
+               .oo-ui-box-sizing( border-box );
+               width: 100%;
+               border: @border-base;
+               border-radius: @border-radius-base;
+               padding: @padding-input-text;
+               line-height: @line-height-widget-singleline;
+       }
+
+       &.oo-ui-widget-enabled {
+               .mw-widget-dateInputWidget-handle {
+                       box-shadow: @box-shadow-widget; // necessary for smooth transition
+                       .oo-ui-transition(
+                               border-color @transition-ease-out-sine-medium,
+                               box-shadow @transition-ease-out-sine-medium
+                       );
+
+                       &:hover {
+                               border-color: @border-color-input--hover;
+                       }
+
+                       &:focus {
+                               outline: 0;
+                               border-color: @border-color-base--focus;
+                               box-shadow: @box-shadow-widget--focus;
+                       }
+
+                       & > .oo-ui-labelElement-label {
+                               cursor: pointer;
+                       }
+               }
+       }
+
+       &-active {
+               &.oo-ui-textInputWidget input {
+                       cursor: text;
+               }
        }
 }
index 633798d..481980f 100644 (file)
@@ -15,6 +15,7 @@
        margin-bottom: 0.5em;
        border: solid 1px #ddd;
        background-color: #fcfcfc;
+       color: #252525;
        /* Click handler in mediawiki.notification.js */
        cursor: pointer;
 
index ca31fbc..f7bf7a6 100644 (file)
@@ -64,6 +64,7 @@ $wgAutoloadClasses += [
        'LessFileCompilationTest' => "$testDir/phpunit/LessFileCompilationTest.php",
 
        # tests/phpunit/includes
+       'RevisionDbTestBase' => "$testDir/phpunit/includes/RevisionDbTestBase.php",
        'RevisionTestModifyableContent' => "$testDir/phpunit/includes/RevisionTestModifyableContent.php",
        'RevisionTestModifyableContentHandler' => "$testDir/phpunit/includes/RevisionTestModifyableContentHandler.php",
        'TestLogger' => "$testDir/phpunit/includes/TestLogger.php",
index 1204dbd..ff574d1 100644 (file)
@@ -1912,6 +1912,33 @@ a <div>foo</div>
 <p>b</p>
 !! end
 
+!! test
+No p-wrappable content
+!! wikitext
+<span><div>x</div></span>
+<span><s><div>x</div></s></span>
+<small><em></em></small><span><s><div>x</div></s></span>
+!! html+tidy
+<div><span>x</span></div>
+<div><span><s>x</s></span></div>
+<div><span><s>x</s></span></div>
+!! html/parsoid
+<span><div>x</div></span>
+<span><s><div>x</div></s></span>
+<small><em></em></small><span><s><div>x</div></s></span>
+!! end
+
+# T177612: Parsoid-only test
+!! test
+Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
+!! wikitext
+{{echo|<span><div>x</div></span>}}
+x
+!! html/parsoid
+<span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
+<p>x</p>
+!! end
+
 !! test
 Block tag on one line (<blockquote>)
 !! wikitext
@@ -4806,8 +4833,11 @@ foo//example.com/Foo
 </p>
 !! end
 
+## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
 !! test
 External links: with no contents
+!! options
+parsoid=wt2html,wt2wt
 !! wikitext
 [http://en.wikipedia.org/wiki/Foo]
 
@@ -4911,7 +4941,7 @@ External links: Free with trailing quotes (T113666)
 news:'a'b''c''d e
 !! html/php
 <p><b>News:</b> Stuff here
-</p><p><a rel="nofollow" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e
+</p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
 </p>
 !! html/parsoid
 <p><b>News:</b> Stuff here</p>
@@ -5557,8 +5587,8 @@ External link containing a single quote. (T65947)
 
 [//foo.org/bar'baz bang]
 !! html/php
-<p><a rel="nofollow" class="external autonumber" href="//foo.org/bar'baz">[1]</a>
-</p><p><a rel="nofollow" class="external text" href="//foo.org/bar'baz">bang</a>
+<p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
+</p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
 </p>
 !! html/parsoid
 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
@@ -5676,7 +5706,7 @@ Examples from RFC 2732, section 2:
 
 !! html/php
 <p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a>
-</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
+</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
 </p>
 <ul><li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
@@ -5684,7 +5714,7 @@ Examples from RFC 2732, section 2:
 <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
 <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
 <li> <a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
-<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
+<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
 </p>
 <ul><li> <a rel="nofollow" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
 <li> <a rel="nofollow" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
@@ -5697,7 +5727,7 @@ Examples from RFC 2732, section 2:
 !! html/parsoid
 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p>
 
-<p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
+<p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
 <li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
 <li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
@@ -5705,7 +5735,7 @@ Examples from RFC 2732, section 2:
 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
 
-<p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
+<p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
 <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
 <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
@@ -5739,7 +5769,7 @@ Examples from RFC 2732, section 2:
 
 !! html/php
 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
-</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
+</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
 </p>
 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
@@ -5747,7 +5777,7 @@ Examples from RFC 2732, section 2:
 <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
 <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
-<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
+<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
 </p>
 <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
 <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
@@ -5760,7 +5790,7 @@ Examples from RFC 2732, section 2:
 !! html/parsoid
 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
 
-<p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
+<p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
 <li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
 <li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
@@ -5768,7 +5798,7 @@ Examples from RFC 2732, section 2:
 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
 
-<p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
+<p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
 <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
 <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
@@ -5935,11 +5965,11 @@ parsoid=html2wt
 !! wikitext
 [[Foo|Bar]]
 [[Foo|Bar]]
-[[wikipedia:Foo|Bar]]
-[[wikipedia:Foo|Bar]]
+[[:en:Foo|Bar]]
+[[:en:Foo|Bar]]
 
-[[wikipedia:European_Robin|European Robin]]
-[[wikipedia:European_Robin|European Robin]]
+[[:en:European_Robin|European Robin]]
+[[:en:European_Robin|European Robin]]
 !! end
 
 !! test
@@ -7973,7 +8003,7 @@ Link containing double-single-quotes '' (T6598)
 !! wikitext
 [[Lista d''e paise d''o munno]]
 !! html/php
-<p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&amp;action=edit&amp;redlink=1" class="new" title="Lista d''e paise d''o munno (page does not exist)">Lista d''e paise d''o munno</a>
+<p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&amp;action=edit&amp;redlink=1" class="new" title="Lista d&#39;&#39;e paise d&#39;&#39;o munno (page does not exist)">Lista d''e paise d''o munno</a>
 </p>
 !! html/parsoid
 <p><a rel="mw:WikiLink" href="./Lista_d''e_paise_d''o_munno" title="Lista d''e paise d''o munno">Lista d''e paise d''o munno</a></p>
@@ -8038,9 +8068,9 @@ Link with double quotes in title part (literal) and alternate part (interpreted)
 [[''Pentecoste''|''Pentecoste'']]
 !! html/php
 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Denys_Savchenko_%27%27Pentecoste%27%27.jpg" class="new" title="File:Denys Savchenko &#39;&#39;Pentecoste&#39;&#39;.jpg">File:Denys Savchenko <i>Pentecoste</i>.jpg</a>
-</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">''Pentecoste''</a>
-</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">Pentecoste</a>
-</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)"><i>Pentecoste</i></a>
+</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">''Pentecoste''</a>
+</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">Pentecoste</a>
+</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)"><i>Pentecoste</i></a>
 </p>
 !! html/parsoid
 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Denys_Savchenko_''Pentecoste''.jpg"><img resource="./File:Denys_Savchenko_''Pentecoste''.jpg" src="./Special:FilePath/Denys_Savchenko_''Pentecoste''.jpg" height="220" width="220"/></a></span></p>
@@ -8333,7 +8363,7 @@ language=kaa
 !! wikitext
 [[Something]]'nice
 !! html
-<p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag'an)">Something'nice</a>
+<p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag&#39;an)">Something'nice</a>
 </p>
 !! end
 
@@ -8517,6 +8547,31 @@ parsoid=html2wt,html2html
 Aðrir mótmælenda<nowiki/>[[söfnuður]]
 !! end
 
+!! test
+Parsoid link bracket escaping
+!! options
+parsoid=html2wt,html2html
+!! html/parsoid
+<p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
+<p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
+<p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
+<p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
+<p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
+<p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
+!! wikitext
+[[Test]]
+
+[<nowiki/>[[Test]]]
+
+[[[[Test]]]]
+
+[[[<nowiki/>[[Test]]]]]
+
+[[[[[[Test]]]]]]
+
+[[[[[<nowiki/>[[Test]]]]]]]
+!! end
+
 !! test
 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
 !! wikitext
@@ -8584,8 +8639,11 @@ parsoid=wt2html,wt2wt,html2html
 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
 !! end
 
+## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
 !! test
 Interwiki link encoding conversion (T3636)
+!! options
+parsoid=wt2html,wt2wt
 !! wikitext
 *[[Wikipedia:ro:Olteni&#0355;a]]
 *[[Wikipedia:ro:Olteni&#355;a]]
@@ -8598,6 +8656,11 @@ Interwiki link encoding conversion (T3636)
 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
 </ul>
+!! html/parsoid
+<ul>
+<li><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
+<li><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
+</ul>
 !! end
 
 !! test
@@ -9411,7 +9474,7 @@ Handling html with a div self-closing tag
 !! html/parsoid
 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
-<div title="" data-parsoid='{"stx":"html","selfClose":true,"brokenHTMLTag":true}'></div>
+<div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
@@ -10935,10 +10998,10 @@ Magic links: RFC (T2479)
 !! wikitext
 RFC 822
 !! html/php
-<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
 </p>
 !! html/parsoid
-<p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
+<p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
 !! end
 
 !! test
@@ -10946,10 +11009,10 @@ Magic links: RFC (T67278)
 !! wikitext
 This is RFC 822 but thisRFC 822 is not RFC 822linked.
 !! html/php
-<p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
+<p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
 </p>
 !! html/parsoid
-<p>This is <a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
+<p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
 !! end
 
 !! test
@@ -10959,12 +11022,12 @@ RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
 RFC
 822
 !! html/php
-<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
 RFC
 822
 </p>
 !! html/parsoid
-<p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
+<p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
 RFC
 822</p>
 !! end
@@ -11060,14 +11123,14 @@ Magic links: use appropriate serialization for "almost" magic links.
 !! wikitext
 X[[Special:BookSources/0978739256|foo]]
 
-X[//tools.ietf.org/html/rfc1234 foo]
+X[https://tools.ietf.org/html/rfc1234 foo]
 !! html/php
 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
-</p><p>X<a rel="nofollow" class="external text" href="//tools.ietf.org/html/rfc1234">foo</a>
+</p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
 </p>
 !! html/parsoid
 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
-<p>X<a rel="mw:ExtLink" href="//tools.ietf.org/html/rfc1234">foo</a></p>
+<p>X<a rel="mw:ExtLink" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
 !! end
 
 !! test
@@ -11324,6 +11387,15 @@ Templates with templated name
 <ul about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|inner list}} ","href":"./Template:Inner_list"},"params":{},"i":0}}]}'><li> item 1</li></ul>
 !! end
 
+## Regression test; the output here isn't really that interesting.
+!! test
+Templates with templated name and top level template args
+!! wikitext
+{{1{{2{{{3}}}|4=5}}}}
+!! html/parsoid
+<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1{{2{{{3}}}|4=5}}"},"params":{},"i":0}}]}'>{{1{{2{{{3}}}|4=5}}}}</p>
+!! end
+
 # Parsoid markup is deliberate "broken". This is an edge case.
 # See long comment in TemplateHandler.js:convertAttribsToString.
 !! test
@@ -14762,6 +14834,28 @@ Alt image option should handle most kinds of wikitext without barfing
 <figure class="mw-default-size" typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"This is the image caption"},{"ck":"alt","ak":"alt=This is a [[link]] and a {{echo|&#39;&#39;bold template&#39;&#39;}}."}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["alt",{"html":"alt=This is a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[65,73,2,2]}&#39;>link&lt;/a> and a &lt;i about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"dsr\":[80,106,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;#39;&amp;#39;bold template&amp;#39;&amp;#39;\"}},\"i\":0}}]}&#39;>bold template&lt;/i>."}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img alt="This is a link and a bold template." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"alt":"This is a link and a bold template.","resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"alt":"alt=This is a [[link]] and a {{echo|&#39;&#39;bold template&#39;&#39;}}.","resource":"Image:Foobar.jpg"}}'/></a><figcaption>This is the image caption</figcaption></figure>
 !! end
 
+!! test
+Image with nested tables in caption
+!! wikitext
+[[File:Foobar.jpg|thumb|Foo<br />
+{|
+|
+{|
+|z
+|}
+|}
+]]
+!! html/parsoid
+<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Foo&lt;br/>\n{|\n|\n{|\n|z\n|}\n|}\n"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption data-parsoid='{"dsr":[null,50,null,null]}'>Foo<br data-parsoid='{"stx":"html","selfClose":true}'/>
+<table>
+<tbody><tr><td>
+<table>
+<tbody><tr><td>z</td></tr>
+</tbody></table></td></tr>
+</tbody></table>
+</figcaption></figure>
+!! end
+
 ###################
 # Conflicting image format options.
 # First option specified should 'win'.
@@ -15070,10 +15164,10 @@ T3887: A RFC with a thumbnail
 !! wikitext
 [[File:Foobar.jpg|thumb|This is RFC 12354]]
 !! html/php
-<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
+<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>  <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
 
 !! html/parsoid
-<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="//tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="https://tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
 !! end
 
 !! test
@@ -15615,9 +15709,9 @@ T93580: 2. <ref> inside inline images
 
 <references />
 !! html/parsoid
-<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,78,5,6]}&#39;/>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
 
-<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
+<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
 !! end
 
 !! test
@@ -15627,9 +15721,9 @@ T93580: 3. Templated <ref> inside inline images
 
 <references />
 !! html/parsoid
-<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion  mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Transclusion mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;/>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
+<p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion  mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
 
-<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
+<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
 !! end
 
 ###
@@ -15817,7 +15911,7 @@ Link to category
 !! wikitext
 [[:Category:MediaWiki User's Guide]]
 !! html
-<p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
+<p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
 </p>
 !! end
 
@@ -16794,7 +16888,7 @@ section 5
 <h2><span class="mw-headline" id="text_.26_text">text &amp; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: text &amp; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <p>section 3
 </p>
-<h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text ' text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text &#039; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <p>section 4
 </p>
 <h2><span class="mw-headline" id="text_.22_text">text " text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: text &quot; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
@@ -18272,18 +18366,16 @@ Nested template calls
 ### Sanitizer
 ###
 
-# HTML+Tidy effectively strips out the empty tags completely
-# But since Parsoid doesn't it wraps the <s></s> tags in p-tags
-# which Tidy would have done for the PHP parser had there been content inside it.
+# HTML+Tidy strips out empty tags completely. Parsoid doesn't.
+# FIXME: Wikitext for this first test doesn't match its title.
 !! test
 Sanitizer: Closing of open tags
 !! wikitext
 <s></s><table></table>
-!! html
-<s></s><table></table>
+!! html/php+tidy
 
 !! html/parsoid
-<p><s></s></p><table></table>
+<s></s><table></table>
 !! end
 
 !! test
@@ -19993,7 +20085,7 @@ parsoid=wt2html
 '''''
 !! html/php
 !! html/parsoid
-<p><b><i></i></b></p>
+<b><i></i></b>
 !! end
 
 # same html as previous, but wikitext adjusted to match parsoid html2wt
@@ -20886,7 +20978,7 @@ Double RFC
 !! wikitext
 RFC RFC 1234
 !! html
-<p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
+<p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
 </p>
 !! end
 
@@ -20904,10 +20996,10 @@ RFC code coverage
 !! wikitext
 RFC   983&#x20;987
 !! html
-<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
 </p>
 !! html+tidy
-<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
 !! end
 
 !! test
@@ -22298,7 +22390,7 @@ parsoid={
 |}
 !! end
 
-# Tests LanguageVariantText._fromSelser
+# Tests LanguageVariantText._fromSelSer
 !! test
 LanguageConverter selser (4)
 !! options
@@ -22672,6 +22764,21 @@ a:b=>c xyz
 </p>
 !! end
 
+!! test
+T179579: Nowiki and lc interaction
+!! options
+parsoid=wt2html
+language=sr
+!! wikitext
+-{</nowiki>123}-
+
+-{123<nowiki>|</nowiki>456}-
+!! html/parsoid
+<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
+
+<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"123&lt;span typeof=\"mw:Nowiki\" data-parsoid=&#39;{\"dsr\":[23,41,8,9]}&#39;>|&lt;/span>456"}}' data-parsoid='{"fl":[],"src":"-{123&lt;nowiki>|&lt;/nowiki>456}-"}'></span></p>
+!! end
+
 !! test
 T2529: Uncovered bullet
 !! wikitext
@@ -24448,9 +24555,7 @@ parsoid=wt2html,wt2wt
 !! wikitext
 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
 !! html/parsoid
-<p><b><small></small></b></p>
-<figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure>
-<p></p>
+<b><small><figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure></small></b>
 !! end
 
 #### ----------------------------------------------------------------
@@ -25649,9 +25754,9 @@ Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
-<p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
-<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
-X<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
+<p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
+<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
+X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
 !! wikitext
 RFC 123<nowiki/>4
 RFC 123<nowiki/>y
@@ -25663,18 +25768,18 @@ Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
 !! options
 parsoid=html2wt
 !! html/parsoid
-<p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
-<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
--<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
+<p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
+<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
+-<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
 </p>
 !! wikitext
 RFC 123?foo
 RFC 123&foo
 -RFC 123-
 !! html/php
-<p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>?foo
-<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
--<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>-
+<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
+<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
+-<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
 </p>
 !! end
 
@@ -27935,9 +28040,9 @@ Edited RFC links not serializable as RFC links should serialize as extlinks
 !! options
 parsoid=html2wt
 !! html/parsoid
-<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
+<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
 !! wikitext
-[//tools.ietf.org/html/rfc123 New RFC]
+[https://tools.ietf.org/html/rfc123 New RFC]
 !! end
 
 !! test
@@ -28081,7 +28186,7 @@ Magic links inside image captions (autolinked)
 <div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
 <div class="thumbcaption">
 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
-<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a></div>
+<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div>
 </div>
 </div>
 <div class="thumb tright">
@@ -28100,7 +28205,7 @@ Magic links inside image captions (autolinked)
 </div>
 !! html/parsoid
 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
-<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></figcaption></figure>
+<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></figcaption></figure>
 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></figcaption></figure>
 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./Special:BookSources/123456789X" rel="mw:WikiLink">ISBN 123456789x</a></figcaption></figure>
 !! end
@@ -29427,7 +29532,7 @@ wgFragmentMode=[ 'html5', 'legacy' ]
 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
-<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_'"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
+<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
 </ul>
 </div>
 
@@ -29436,8 +29541,8 @@ wgFragmentMode=[ 'html5', 'legacy' ]
 <h2><span id=".D0.A2.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <h2><span id=".D0.A2.D0.B5.D1.81.D1.82_2"></span><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <h2><span id=".D1.82.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
-<h2><span id="Hey_.3C_.23_.22_.3E_.25_:_.27"></span><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
-<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_'">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
+<h2><span id="Hey_.3C_.23_.22_.3E_.25_:_.27"></span><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
 </p><p>💩 <span id="💩"></span>
 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
 </p>
@@ -29483,7 +29588,7 @@ wgFragmentMode=[ 'legacy', 'html5' ]
 <h2><span id="Тест"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <h2><span id="Тест_2"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <h2><span id="тест"></span><span class="mw-headline" id=".D1.82.D0.B5.D1.81.D1.82">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
-<h2><span id="Hey_&lt;_#_&quot;_&gt;_%_:_'"></span><span class="mw-headline" id="Hey_.3C_.23_.22_.3E_.25_:_.27">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<h2><span id="Hey_&lt;_#_&quot;_&gt;_%_:_'"></span><span class="mw-headline" id="Hey_.3C_.23_.22_.3E_.25_:_.27">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#.D0.A2.D0.B5.D1.81.D1.82">#Тест</a> <a href="#.D1.82.D0.B5.D1.81.D1.82">#тест</a> <a href="#Hey_.3C_.23_.22_.3E_.25_:_.27">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
@@ -29521,7 +29626,7 @@ wgFragmentMode=[ 'html5' ]
 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
-<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_'"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
+<li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
 </ul>
 </div>
 
@@ -29530,8 +29635,8 @@ wgFragmentMode=[ 'html5' ]
 <h2><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <h2><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
 <h2><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
-<h2><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
-<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_'">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
+<h2><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
+<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
 </p><p>💩 <span id="💩"></span>
 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
 </p>
index 106ab68..6f09d4c 100644 (file)
@@ -38,16 +38,13 @@ $maintenance->setup();
 // to $maintenance->mSelf. Keep that here for b/c
 $self = $maintenance->getName();
 global $IP;
-# Start the autoloader, so that extensions can derive classes from core files
-require_once "$IP/includes/AutoLoader.php";
-# Grab profiling functions
-require_once "$IP/includes/profiler/ProfilerFunctions.php";
-
-# Start the profiler
+# Get profiler configuraton
 $wgProfiler = [];
 if ( file_exists( "$IP/StartProfiler.php" ) ) {
        require "$IP/StartProfiler.php";
 }
+# Start the autoloader, so that extensions can derive classes from core files
+require_once "$IP/includes/AutoLoader.php";
 
 $requireOnceGlobalsScope = function ( $file ) use ( $self ) {
        foreach ( array_keys( $GLOBALS ) as $varName ) {
diff --git a/tests/phpunit/includes/RevisionContentHandlerDbTest.php b/tests/phpunit/includes/RevisionContentHandlerDbTest.php
new file mode 100644 (file)
index 0000000..fa0153d
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * @group Database
+ * @group medium
+ * @group ContentHandler
+ */
+class RevisionContentHandlerDbTest extends RevisionDbTestBase {
+
+       protected function getContentHandlerUseDB() {
+               return true;
+       }
+
+}
diff --git a/tests/phpunit/includes/RevisionDbTestBase.php b/tests/phpunit/includes/RevisionDbTestBase.php
new file mode 100644 (file)
index 0000000..73559f3
--- /dev/null
@@ -0,0 +1,1225 @@
+<?php
+
+/**
+ * RevisionDbTestBase contains test cases for the Revision class that have Database interactions.
+ *
+ * @group Database
+ * @group medium
+ */
+abstract class RevisionDbTestBase extends MediaWikiTestCase {
+
+       /**
+        * @var WikiPage $testPage
+        */
+       private $testPage;
+
+       public function __construct( $name = null, array $data = [], $dataName = '' ) {
+               parent::__construct( $name, $data, $dataName );
+
+               $this->tablesUsed = array_merge( $this->tablesUsed,
+                       [
+                               'page',
+                               'revision',
+                               'ip_changes',
+                               'text',
+                               'archive',
+
+                               'recentchanges',
+                               'logging',
+
+                               'page_props',
+                               'pagelinks',
+                               'categorylinks',
+                               'langlinks',
+                               'externallinks',
+                               'imagelinks',
+                               'templatelinks',
+                               'iwlinks'
+                       ]
+               );
+       }
+
+       protected function setUp() {
+               global $wgContLang;
+
+               parent::setUp();
+
+               $this->mergeMwGlobalArrayValue(
+                       'wgExtraNamespaces',
+                       [
+                               12312 => 'Dummy',
+                               12313 => 'Dummy_talk',
+                       ]
+               );
+
+               $this->mergeMwGlobalArrayValue(
+                       'wgNamespaceContentModels',
+                       [
+                               12312 => DummyContentForTesting::MODEL_ID,
+                       ]
+               );
+
+               $this->mergeMwGlobalArrayValue(
+                       'wgContentHandlers',
+                       [
+                               DummyContentForTesting::MODEL_ID => 'DummyContentHandlerForTesting',
+                               RevisionTestModifyableContent::MODEL_ID => 'RevisionTestModifyableContentHandler',
+                       ]
+               );
+
+               $this->setMwGlobals( 'wgContentHandlerUseDB', $this->getContentHandlerUseDB() );
+
+               MWNamespace::clearCaches();
+               // Reset namespace cache
+               $wgContLang->resetNamespaces();
+               if ( !$this->testPage ) {
+                       /**
+                        * We have to create a new page for each subclass as the page creation may result
+                        * in different DB fields being filled based on configuration.
+                        */
+                       $this->testPage = $this->createPage( __CLASS__, __CLASS__ );
+               }
+       }
+
+       protected function tearDown() {
+               global $wgContLang;
+
+               parent::tearDown();
+
+               MWNamespace::clearCaches();
+               // Reset namespace cache
+               $wgContLang->resetNamespaces();
+       }
+
+       abstract protected function getContentHandlerUseDB();
+
+       private function makeRevisionWithProps( $props = null ) {
+               if ( $props === null ) {
+                       $props = [];
+               }
+
+               if ( !isset( $props['content'] ) && !isset( $props['text'] ) ) {
+                       $props['text'] = 'Lorem Ipsum';
+               }
+
+               if ( !isset( $props['comment'] ) ) {
+                       $props['comment'] = 'just a test';
+               }
+
+               if ( !isset( $props['page'] ) ) {
+                       $props['page'] = $this->testPage->getId();
+               }
+
+               $rev = new Revision( $props );
+
+               $dbw = wfGetDB( DB_MASTER );
+               $rev->insertOn( $dbw );
+
+               return $rev;
+       }
+
+       /**
+        * @param string $titleString
+        * @param string $text
+        * @param string|null $model
+        *
+        * @return WikiPage
+        */
+       private function createPage( $titleString, $text, $model = null ) {
+               if ( !preg_match( '/:/', $titleString ) &&
+                       ( $model === null || $model === CONTENT_MODEL_WIKITEXT )
+               ) {
+                       $ns = $this->getDefaultWikitextNS();
+                       $titleString = MWNamespace::getCanonicalName( $ns ) . ':' . $titleString;
+               }
+
+               $title = Title::newFromText( $titleString );
+               $wikipage = new WikiPage( $title );
+
+               // Delete the article if it already exists
+               if ( $wikipage->exists() ) {
+                       $wikipage->doDeleteArticle( "done" );
+               }
+
+               $content = ContentHandler::makeContent( $text, $title, $model );
+               $wikipage->doEditContent( $content, __METHOD__, EDIT_NEW );
+
+               return $wikipage;
+       }
+
+       private function assertRevEquals( Revision $orig, Revision $rev = null ) {
+               $this->assertNotNull( $rev, 'missing revision' );
+
+               $this->assertEquals( $orig->getId(), $rev->getId() );
+               $this->assertEquals( $orig->getPage(), $rev->getPage() );
+               $this->assertEquals( $orig->getTimestamp(), $rev->getTimestamp() );
+               $this->assertEquals( $orig->getUser(), $rev->getUser() );
+               $this->assertEquals( $orig->getContentModel(), $rev->getContentModel() );
+               $this->assertEquals( $orig->getContentFormat(), $rev->getContentFormat() );
+               $this->assertEquals( $orig->getSha1(), $rev->getSha1() );
+       }
+
+       /**
+        * @covers Revision::insertOn
+        */
+       public function testInsertOn_success() {
+               $parentId = $this->testPage->getLatest();
+
+               // If an ExternalStore is set don't use it.
+               $this->setMwGlobals( 'wgDefaultExternalStore', false );
+
+               $rev = new Revision( [
+                       'page' => $this->testPage->getId(),
+                       'title' => $this->testPage->getTitle(),
+                       'text' => 'Revision Text',
+                       'comment' => 'Revision comment',
+               ] );
+
+               $revId = $rev->insertOn( wfGetDB( DB_MASTER ) );
+
+               $this->assertInternalType( 'integer', $revId );
+               $this->assertInternalType( 'integer', $rev->getTextId() );
+               $this->assertSame( $revId, $rev->getId() );
+
+               $this->assertSelect(
+                       'text',
+                       [ 'old_id', 'old_text' ],
+                       "old_id = {$rev->getTextId()}",
+                       [ [ strval( $rev->getTextId() ), 'Revision Text' ] ]
+               );
+               $this->assertSelect(
+                       'revision',
+                       [
+                               'rev_id',
+                               'rev_page',
+                               'rev_text_id',
+                               'rev_user',
+                               'rev_minor_edit',
+                               'rev_deleted',
+                               'rev_len',
+                               'rev_parent_id',
+                               'rev_sha1',
+                       ],
+                       "rev_id = {$rev->getId()}",
+                       [ [
+                               strval( $rev->getId() ),
+                               strval( $this->testPage->getId() ),
+                               strval( $rev->getTextId() ),
+                               '0',
+                               '0',
+                               '0',
+                               '13',
+                               strval( $parentId ),
+                               's0ngbdoxagreuf2vjtuxzwdz64n29xm',
+                       ] ]
+               );
+       }
+
+       /**
+        * @covers Revision::insertOn
+        */
+       public function testInsertOn_exceptionOnNoPage() {
+               // If an ExternalStore is set don't use it.
+               $this->setMwGlobals( 'wgDefaultExternalStore', false );
+               $this->setExpectedException(
+                       MWException::class,
+                       "Cannot insert revision: page ID must be nonzero"
+               );
+
+               $rev = new Revision( [] );
+
+               $rev->insertOn( wfGetDB( DB_MASTER ) );
+       }
+
+       /**
+        * @covers Revision::newFromTitle
+        */
+       public function testNewFromTitle_withoutId() {
+               $latestRevId = $this->testPage->getLatest();
+
+               $rev = Revision::newFromTitle( $this->testPage->getTitle() );
+
+               $this->assertTrue( $this->testPage->getTitle()->equals( $rev->getTitle() ) );
+               $this->assertEquals( $latestRevId, $rev->getId() );
+       }
+
+       /**
+        * @covers Revision::newFromTitle
+        */
+       public function testNewFromTitle_withId() {
+               $latestRevId = $this->testPage->getLatest();
+
+               $rev = Revision::newFromTitle( $this->testPage->getTitle(), $latestRevId );
+
+               $this->assertTrue( $this->testPage->getTitle()->equals( $rev->getTitle() ) );
+               $this->assertEquals( $latestRevId, $rev->getId() );
+       }
+
+       /**
+        * @covers Revision::newFromTitle
+        */
+       public function testNewFromTitle_withBadId() {
+               $latestRevId = $this->testPage->getLatest();
+
+               $rev = Revision::newFromTitle( $this->testPage->getTitle(), $latestRevId + 1 );
+
+               $this->assertNull( $rev );
+       }
+
+       /**
+        * @covers Revision::newFromRow
+        */
+       public function testNewFromRow() {
+               $orig = $this->makeRevisionWithProps();
+
+               $dbr = wfGetDB( DB_REPLICA );
+               $revQuery = Revision::getQueryInfo();
+               $res = $dbr->select( $revQuery['tables'], $revQuery['fields'], [ 'rev_id' => $orig->getId() ],
+                  __METHOD__, [], $revQuery['joins'] );
+               $this->assertTrue( is_object( $res ), 'query failed' );
+
+               $row = $res->fetchObject();
+               $res->free();
+
+               $rev = Revision::newFromRow( $row );
+
+               $this->assertRevEquals( $orig, $rev );
+       }
+
+       public function provideNewFromArchiveRow() {
+               yield [
+                       function ( $f ) {
+                               return $f;
+                       },
+               ];
+               yield [
+                       function ( $f ) {
+                               return $f + [ 'ar_namespace', 'ar_title' ];
+                       },
+               ];
+               yield [
+                       function ( $f ) {
+                               unset( $f['ar_text_id'] );
+                               return $f;
+                       },
+               ];
+       }
+
+       /**
+        * @dataProvider provideNewFromArchiveRow
+        * @covers Revision::newFromArchiveRow
+        */
+       public function testNewFromArchiveRow( $selectModifier ) {
+               $page = $this->createPage(
+                       'RevisionStorageTest_testNewFromArchiveRow',
+                       'Lorem Ipsum',
+                       CONTENT_MODEL_WIKITEXT
+               );
+               $orig = $page->getRevision();
+               $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
+
+               $dbr = wfGetDB( DB_REPLICA );
+               $arQuery = Revision::getArchiveQueryInfo();
+               $arQuery['fields'] = $selectModifier( $arQuery['fields'] );
+               $res = $dbr->select(
+                       $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
+                       __METHOD__, [], $arQuery['joins']
+               );
+               $this->assertTrue( is_object( $res ), 'query failed' );
+
+               $row = $res->fetchObject();
+               $res->free();
+
+               $rev = Revision::newFromArchiveRow( $row );
+
+               $this->assertRevEquals( $orig, $rev );
+       }
+
+       /**
+        * @covers Revision::newFromArchiveRow
+        */
+       public function testNewFromArchiveRowOverrides() {
+               $page = $this->createPage(
+                       'RevisionStorageTest_testNewFromArchiveRow',
+                       'Lorem Ipsum',
+                       CONTENT_MODEL_WIKITEXT
+               );
+               $orig = $page->getRevision();
+               $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
+
+               $dbr = wfGetDB( DB_REPLICA );
+               $arQuery = Revision::getArchiveQueryInfo();
+               $res = $dbr->select(
+                       $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
+                       __METHOD__, [], $arQuery['joins']
+               );
+               $this->assertTrue( is_object( $res ), 'query failed' );
+
+               $row = $res->fetchObject();
+               $res->free();
+
+               $rev = Revision::newFromArchiveRow( $row, [ 'comment' => 'SOMEOVERRIDE' ] );
+
+               $this->assertNotEquals( $orig->getComment(), $rev->getComment() );
+               $this->assertEquals( 'SOMEOVERRIDE', $rev->getComment() );
+       }
+
+       /**
+        * @covers Revision::newFromId
+        */
+       public function testNewFromId() {
+               $orig = $this->testPage->getRevision();
+               $rev = Revision::newFromId( $orig->getId() );
+               $this->assertRevEquals( $orig, $rev );
+       }
+
+       /**
+        * @covers Revision::newFromPageId
+        */
+       public function testNewFromPageId() {
+               $rev = Revision::newFromPageId( $this->testPage->getId() );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       $rev
+               );
+       }
+
+       /**
+        * @covers Revision::newFromPageId
+        */
+       public function testNewFromPageIdWithLatestId() {
+               $rev = Revision::newFromPageId(
+                       $this->testPage->getId(),
+                       $this->testPage->getLatest()
+               );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       $rev
+               );
+       }
+
+       /**
+        * @covers Revision::newFromPageId
+        */
+       public function testNewFromPageIdWithNotLatestId() {
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $rev = Revision::newFromPageId(
+                       $this->testPage->getId(),
+                       $this->testPage->getRevision()->getPrevious()->getId()
+               );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision()->getPrevious(),
+                       $rev
+               );
+       }
+
+       /**
+        * @covers Revision::fetchRevision
+        */
+       public function testFetchRevision() {
+               // Hidden process cache assertion below
+               $this->testPage->getRevision()->getId();
+
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $id = $this->testPage->getRevision()->getId();
+
+               $res = Revision::fetchRevision( $this->testPage->getTitle() );
+
+               # note: order is unspecified
+               $rows = [];
+               while ( ( $row = $res->fetchObject() ) ) {
+                       $rows[$row->rev_id] = $row;
+               }
+
+               $this->assertEquals( 1, count( $rows ), 'expected exactly one revision' );
+               $this->assertArrayHasKey( $id, $rows, 'missing revision with id ' . $id );
+       }
+
+       /**
+        * @covers Revision::getPage
+        */
+       public function testGetPage() {
+               $page = $this->testPage;
+
+               $orig = $this->makeRevisionWithProps( [ 'page' => $page->getId() ] );
+               $rev = Revision::newFromId( $orig->getId() );
+
+               $this->assertEquals( $page->getId(), $rev->getPage() );
+       }
+
+       /**
+        * @covers Revision::isCurrent
+        */
+       public function testIsCurrent() {
+               $rev1 = $this->testPage->getRevision();
+
+               # @todo find out if this should be true
+               # $this->assertTrue( $rev1->isCurrent() );
+
+               $rev1x = Revision::newFromId( $rev1->getId() );
+               $this->assertTrue( $rev1x->isCurrent() );
+
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $rev2 = $this->testPage->getRevision();
+
+               # @todo find out if this should be true
+               # $this->assertTrue( $rev2->isCurrent() );
+
+               $rev1x = Revision::newFromId( $rev1->getId() );
+               $this->assertFalse( $rev1x->isCurrent() );
+
+               $rev2x = Revision::newFromId( $rev2->getId() );
+               $this->assertTrue( $rev2x->isCurrent() );
+       }
+
+       /**
+        * @covers Revision::getPrevious
+        */
+       public function testGetPrevious() {
+               $oldestRevision = $this->testPage->getOldestRevision();
+               $latestRevision = $this->testPage->getLatest();
+
+               $this->assertNull( $oldestRevision->getPrevious() );
+
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $newRevision = $this->testPage->getRevision();
+
+               $this->assertNotNull( $newRevision->getPrevious() );
+               $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
+       }
+
+       /**
+        * @covers Revision::getNext
+        */
+       public function testGetNext() {
+               $rev1 = $this->testPage->getRevision();
+
+               $this->assertNull( $rev1->getNext() );
+
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $rev2 = $this->testPage->getRevision();
+
+               $this->assertNotNull( $rev1->getNext() );
+               $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
+       }
+
+       /**
+        * @covers Revision::newNullRevision
+        */
+       public function testNewNullRevision() {
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $orig = $this->testPage->getRevision();
+
+               $dbw = wfGetDB( DB_MASTER );
+               $rev = Revision::newNullRevision( $dbw, $this->testPage->getId(), 'a null revision', false );
+
+               $this->assertNotEquals( $orig->getId(), $rev->getId(),
+                       'new null revision should have a different id from the original revision' );
+               $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
+                       'new null revision should have the same text id as the original revision' );
+               $this->assertEquals( __METHOD__, $rev->getContent()->getNativeData() );
+       }
+
+       /**
+        * @covers Revision::insertOn
+        */
+       public function testInsertOn() {
+               $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
+
+               $orig = $this->makeRevisionWithProps( [
+                       'user_text' => $ip
+               ] );
+
+               // Make sure the revision was copied to ip_changes
+               $dbr = wfGetDB( DB_REPLICA );
+               $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
+               $row = $res->fetchObject();
+
+               $this->assertEquals( IP::toHex( $ip ), $row->ipc_hex );
+               $this->assertEquals( $orig->getTimestamp(), $row->ipc_rev_timestamp );
+       }
+
+       public static function provideUserWasLastToEdit() {
+               yield 'actually the last edit' => [ 3, true ];
+               yield 'not the current edit, but still by this user' => [ 2, true ];
+               yield 'edit by another user' => [ 1, false ];
+               yield 'first edit, by this user, but another user edited in the mean time' => [ 0, false ];
+       }
+
+       /**
+        * @dataProvider provideUserWasLastToEdit
+        */
+       public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
+               $userA = User::newFromName( "RevisionStorageTest_userA" );
+               $userB = User::newFromName( "RevisionStorageTest_userB" );
+
+               if ( $userA->getId() === 0 ) {
+                       $userA = User::createNew( $userA->getName() );
+               }
+
+               if ( $userB->getId() === 0 ) {
+                       $userB = User::createNew( $userB->getName() );
+               }
+
+               $ns = $this->getDefaultWikitextNS();
+
+               $dbw = wfGetDB( DB_MASTER );
+               $revisions = [];
+
+               // create revisions -----------------------------
+               $page = WikiPage::factory( Title::newFromText(
+                       'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
+               $page->insertOn( $dbw );
+
+               $revisions[0] = new Revision( [
+                       'page' => $page->getId(),
+                       // we need the title to determine the page's default content model
+                       'title' => $page->getTitle(),
+                       'timestamp' => '20120101000000',
+                       'user' => $userA->getId(),
+                       'text' => 'zero',
+                       'content_model' => CONTENT_MODEL_WIKITEXT,
+                       'summary' => 'edit zero'
+               ] );
+               $revisions[0]->insertOn( $dbw );
+
+               $revisions[1] = new Revision( [
+                       'page' => $page->getId(),
+                       // still need the title, because $page->getId() is 0 (there's no entry in the page table)
+                       'title' => $page->getTitle(),
+                       'timestamp' => '20120101000100',
+                       'user' => $userA->getId(),
+                       'text' => 'one',
+                       'content_model' => CONTENT_MODEL_WIKITEXT,
+                       'summary' => 'edit one'
+               ] );
+               $revisions[1]->insertOn( $dbw );
+
+               $revisions[2] = new Revision( [
+                       'page' => $page->getId(),
+                       'title' => $page->getTitle(),
+                       'timestamp' => '20120101000200',
+                       'user' => $userB->getId(),
+                       'text' => 'two',
+                       'content_model' => CONTENT_MODEL_WIKITEXT,
+                       'summary' => 'edit two'
+               ] );
+               $revisions[2]->insertOn( $dbw );
+
+               $revisions[3] = new Revision( [
+                       'page' => $page->getId(),
+                       'title' => $page->getTitle(),
+                       'timestamp' => '20120101000300',
+                       'user' => $userA->getId(),
+                       'text' => 'three',
+                       'content_model' => CONTENT_MODEL_WIKITEXT,
+                       'summary' => 'edit three'
+               ] );
+               $revisions[3]->insertOn( $dbw );
+
+               $revisions[4] = new Revision( [
+                       'page' => $page->getId(),
+                       'title' => $page->getTitle(),
+                       'timestamp' => '20120101000200',
+                       'user' => $userA->getId(),
+                       'text' => 'zero',
+                       'content_model' => CONTENT_MODEL_WIKITEXT,
+                       'summary' => 'edit four'
+               ] );
+               $revisions[4]->insertOn( $dbw );
+
+               // test it ---------------------------------
+               $since = $revisions[$sinceIdx]->getTimestamp();
+
+               $wasLast = Revision::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
+
+               $this->assertEquals( $expectedLast, $wasLast );
+       }
+
+       /**
+        * @param string $text
+        * @param string $title
+        * @param string $model
+        * @param string $format
+        *
+        * @return Revision
+        */
+       private function newTestRevision( $text, $title = "Test",
+               $model = CONTENT_MODEL_WIKITEXT, $format = null
+       ) {
+               if ( is_string( $title ) ) {
+                       $title = Title::newFromText( $title );
+               }
+
+               $content = ContentHandler::makeContent( $text, $title, $model, $format );
+
+               $rev = new Revision(
+                       [
+                               'id' => 42,
+                               'page' => 23,
+                               'title' => $title,
+
+                               'content' => $content,
+                               'length' => $content->getSize(),
+                               'comment' => "testing",
+                               'minor_edit' => false,
+
+                               'content_format' => $format,
+                       ]
+               );
+
+               return $rev;
+       }
+
+       public function provideGetContentModel() {
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ],
+                       [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ],
+                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting::MODEL_ID ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetContentModel
+        * @covers Revision::getContentModel
+        */
+       public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
+               $rev = $this->newTestRevision( $text, $title, $model, $format );
+
+               $this->assertEquals( $expectedModel, $rev->getContentModel() );
+       }
+
+       public function provideGetContentFormat() {
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ],
+                       [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ],
+                       [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ],
+                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting::MODEL_ID ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetContentFormat
+        * @covers Revision::getContentFormat
+        */
+       public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
+               $rev = $this->newTestRevision( $text, $title, $model, $format );
+
+               $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
+       }
+
+       public function provideGetContentHandler() {
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ],
+                       [ 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ],
+                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetContentHandler
+        * @covers Revision::getContentHandler
+        */
+       public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
+               $rev = $this->newTestRevision( $text, $title, $model, $format );
+
+               $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
+       }
+
+       public function provideGetContent() {
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ],
+                       [
+                               serialize( 'hello world' ),
+                               'Hello',
+                               DummyContentForTesting::MODEL_ID,
+                               null,
+                               Revision::FOR_PUBLIC,
+                               serialize( 'hello world' )
+                       ],
+                       [
+                               serialize( 'hello world' ),
+                               'Dummy:Hello',
+                               null,
+                               null,
+                               Revision::FOR_PUBLIC,
+                               serialize( 'hello world' )
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetContent
+        * @covers Revision::getContent
+        */
+       public function testGetContent( $text, $title, $model, $format,
+               $audience, $expectedSerialization
+       ) {
+               $rev = $this->newTestRevision( $text, $title, $model, $format );
+               $content = $rev->getContent( $audience );
+
+               $this->assertEquals(
+                       $expectedSerialization,
+                       is_null( $content ) ? null : $content->serialize( $format )
+               );
+       }
+
+       /**
+        * @covers Revision::getContent
+        */
+       public function testGetContent_failure() {
+               $rev = new Revision( [
+                       'page' => $this->testPage->getId(),
+                       'content_model' => $this->testPage->getContentModel(),
+                       'text_id' => 123456789, // not in the test DB
+               ] );
+
+               $this->assertNull( $rev->getContent(),
+                       "getContent() should return null if the revision's text blob could not be loaded." );
+
+               // NOTE: check this twice, once for lazy initialization, and once with the cached value.
+               $this->assertNull( $rev->getContent(),
+                       "getContent() should return null if the revision's text blob could not be loaded." );
+       }
+
+       public function provideGetSize() {
+               return [
+                       [ "hello world.", CONTENT_MODEL_WIKITEXT, 12 ],
+                       [ serialize( "hello world." ), DummyContentForTesting::MODEL_ID, 12 ],
+               ];
+       }
+
+       /**
+        * @covers Revision::getSize
+        * @dataProvider provideGetSize
+        */
+       public function testGetSize( $text, $model, $expected_size ) {
+               $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSize', $model );
+               $this->assertEquals( $expected_size, $rev->getSize() );
+       }
+
+       public function provideGetSha1() {
+               return [
+                       [ "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ],
+                       [
+                               serialize( "hello world." ),
+                               DummyContentForTesting::MODEL_ID,
+                               Revision::base36Sha1( serialize( "hello world." ) )
+                       ],
+               ];
+       }
+
+       /**
+        * @covers Revision::getSha1
+        * @dataProvider provideGetSha1
+        */
+       public function testGetSha1( $text, $model, $expected_hash ) {
+               $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSha1', $model );
+               $this->assertEquals( $expected_hash, $rev->getSha1() );
+       }
+
+       /**
+        * Tests whether $rev->getContent() returns a clone when needed.
+        *
+        * @covers Revision::getContent
+        */
+       public function testGetContentClone() {
+               $content = new RevisionTestModifyableContent( "foo" );
+
+               $rev = new Revision(
+                       [
+                               'id' => 42,
+                               'page' => 23,
+                               'title' => Title::newFromText( "testGetContentClone_dummy" ),
+
+                               'content' => $content,
+                               'length' => $content->getSize(),
+                               'comment' => "testing",
+                               'minor_edit' => false,
+                       ]
+               );
+
+               /** @var RevisionTestModifyableContent $content */
+               $content = $rev->getContent( Revision::RAW );
+               $content->setText( "bar" );
+
+               /** @var RevisionTestModifyableContent $content2 */
+               $content2 = $rev->getContent( Revision::RAW );
+               // content is mutable, expect clone
+               $this->assertNotSame( $content, $content2, "expected a clone" );
+               // clone should contain the original text
+               $this->assertEquals( "foo", $content2->getText() );
+
+               $content2->setText( "bla bla" );
+               // clones should be independent
+               $this->assertEquals( "bar", $content->getText() );
+       }
+
+       /**
+        * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
+        * @covers Revision::getContent
+        */
+       public function testGetContentUncloned() {
+               $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT );
+               $content = $rev->getContent( Revision::RAW );
+               $content2 = $rev->getContent( Revision::RAW );
+
+               // for immutable content like wikitext, this should be the same object
+               $this->assertSame( $content, $content2 );
+       }
+
+       /**
+        * @covers Revision::loadFromId
+        */
+       public function testLoadFromId() {
+               $rev = $this->testPage->getRevision();
+               $this->assertRevEquals(
+                       $rev,
+                       Revision::loadFromId( wfGetDB( DB_MASTER ), $rev->getId() )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromPageId
+        */
+       public function testLoadFromPageId() {
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       Revision::loadFromPageId( wfGetDB( DB_MASTER ), $this->testPage->getId() )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromPageId
+        */
+       public function testLoadFromPageIdWithLatestRevId() {
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       Revision::loadFromPageId(
+                               wfGetDB( DB_MASTER ),
+                               $this->testPage->getId(),
+                               $this->testPage->getLatest()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromPageId
+        */
+       public function testLoadFromPageIdWithNotLatestRevId() {
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision()->getPrevious(),
+                       Revision::loadFromPageId(
+                               wfGetDB( DB_MASTER ),
+                               $this->testPage->getId(),
+                               $this->testPage->getRevision()->getPrevious()->getId()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromTitle
+        */
+       public function testLoadFromTitle() {
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       Revision::loadFromTitle( wfGetDB( DB_MASTER ), $this->testPage->getTitle() )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromTitle
+        */
+       public function testLoadFromTitleWithLatestRevId() {
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       Revision::loadFromTitle(
+                               wfGetDB( DB_MASTER ),
+                               $this->testPage->getTitle(),
+                               $this->testPage->getLatest()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromTitle
+        */
+       public function testLoadFromTitleWithNotLatestRevId() {
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision()->getPrevious(),
+                       Revision::loadFromTitle(
+                               wfGetDB( DB_MASTER ),
+                               $this->testPage->getTitle(),
+                               $this->testPage->getRevision()->getPrevious()->getId()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromTimestamp()
+        */
+       public function testLoadFromTimestamp() {
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       Revision::loadFromTimestamp(
+                               wfGetDB( DB_MASTER ),
+                               $this->testPage->getTitle(),
+                               $this->testPage->getRevision()->getTimestamp()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::getParentLengths
+        */
+       public function testGetParentLengths_noRevIds() {
+               $this->assertSame(
+                       [],
+                       Revision::getParentLengths(
+                               wfGetDB( DB_MASTER ),
+                               []
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::getParentLengths
+        */
+       public function testGetParentLengths_oneRevId() {
+               $text = '831jr091jr0921kr21kr0921kjr0921j09rj1';
+               $textLength = strlen( $text );
+
+               $this->testPage->doEditContent( new WikitextContent( $text ), __METHOD__ );
+               $rev[1] = $this->testPage->getLatest();
+
+               $this->assertSame(
+                       [ $rev[1] => strval( $textLength ) ],
+                       Revision::getParentLengths(
+                               wfGetDB( DB_MASTER ),
+                               [ $rev[1] ]
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::getParentLengths
+        */
+       public function testGetParentLengths_multipleRevIds() {
+               $textOne = '831jr091jr0921kr21kr0921kjr0921j09rj1';
+               $textOneLength = strlen( $textOne );
+               $textTwo = '831jr091jr092121j09rj1';
+               $textTwoLength = strlen( $textTwo );
+
+               $this->testPage->doEditContent( new WikitextContent( $textOne ), __METHOD__ );
+               $rev[1] = $this->testPage->getLatest();
+               $this->testPage->doEditContent( new WikitextContent( $textTwo ), __METHOD__ );
+               $rev[2] = $this->testPage->getLatest();
+
+               $this->assertSame(
+                       [ $rev[1] => strval( $textOneLength ), $rev[2] => strval( $textTwoLength ) ],
+                       Revision::getParentLengths(
+                               wfGetDB( DB_MASTER ),
+                               [ $rev[1], $rev[2] ]
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::getTitle
+        */
+       public function testGetTitle_fromExistingRevision() {
+               $this->assertTrue(
+                       $this->testPage->getTitle()->equals(
+                               $this->testPage->getRevision()->getTitle()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::getTitle
+        */
+       public function testGetTitle_fromRevisionWhichWillLoadTheTitle() {
+               $rev = new Revision( [ 'id' => $this->testPage->getLatest() ] );
+               $this->assertTrue(
+                       $this->testPage->getTitle()->equals(
+                               $rev->getTitle()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::getTitle
+        */
+       public function testGetTitle_forBadRevision() {
+               $rev = new Revision( [] );
+               $this->assertNull( $rev->getTitle() );
+       }
+
+       /**
+        * @covers Revision::isMinor
+        */
+       public function testIsMinor_true() {
+               // Use a sysop to ensure we can mark edits as minor
+               $sysop = $this->getTestSysop()->getUser();
+
+               $this->testPage->doEditContent(
+                       new WikitextContent( __METHOD__ ),
+                       __METHOD__,
+                       EDIT_MINOR,
+                       false,
+                       $sysop
+               );
+               $rev = $this->testPage->getRevision();
+
+               $this->assertSame( true, $rev->isMinor() );
+       }
+
+       /**
+        * @covers Revision::isMinor
+        */
+       public function testIsMinor_false() {
+               $this->testPage->doEditContent(
+                       new WikitextContent( __METHOD__ ),
+                       __METHOD__,
+                       0
+               );
+               $rev = $this->testPage->getRevision();
+
+               $this->assertSame( false, $rev->isMinor() );
+       }
+
+       /**
+        * @covers Revision::getTimestamp
+        */
+       public function testGetTimestamp() {
+               $testTimestamp = wfTimestampNow();
+
+               $this->testPage->doEditContent(
+                       new WikitextContent( __METHOD__ ),
+                       __METHOD__
+               );
+               $rev = $this->testPage->getRevision();
+
+               $this->assertInternalType( 'string', $rev->getTimestamp() );
+               $this->assertTrue( strlen( $rev->getTimestamp() ) == strlen( 'YYYYMMDDHHMMSS' ) );
+               $this->assertContains( substr( $testTimestamp, 0, 10 ), $rev->getTimestamp() );
+       }
+
+       /**
+        * @covers Revision::getUser
+        * @covers Revision::getUserText
+        */
+       public function testGetUserAndText() {
+               $sysop = $this->getTestSysop()->getUser();
+
+               $this->testPage->doEditContent(
+                       new WikitextContent( __METHOD__ ),
+                       __METHOD__,
+                       0,
+                       false,
+                       $sysop
+               );
+               $rev = $this->testPage->getRevision();
+
+               $this->assertSame( $sysop->getId(), $rev->getUser() );
+               $this->assertSame( $sysop->getName(), $rev->getUserText() );
+       }
+
+       /**
+        * @covers Revision::isDeleted
+        */
+       public function testIsDeleted_nothingDeleted() {
+               $rev = $this->testPage->getRevision();
+
+               $this->assertSame( false, $rev->isDeleted( Revision::DELETED_TEXT ) );
+               $this->assertSame( false, $rev->isDeleted( Revision::DELETED_COMMENT ) );
+               $this->assertSame( false, $rev->isDeleted( Revision::DELETED_RESTRICTED ) );
+               $this->assertSame( false, $rev->isDeleted( Revision::DELETED_USER ) );
+       }
+
+       /**
+        * @covers Revision::getVisibility
+        */
+       public function testGetVisibility_nothingDeleted() {
+               $rev = $this->testPage->getRevision();
+
+               $this->assertSame( 0, $rev->getVisibility() );
+       }
+
+       /**
+        * @covers Revision::getComment
+        */
+       public function testGetComment_notDeleted() {
+               $expectedSummary = 'goatlicious summary';
+
+               $this->testPage->doEditContent(
+                       new WikitextContent( __METHOD__ ),
+                       $expectedSummary
+               );
+               $rev = $this->testPage->getRevision();
+
+               $this->assertSame( $expectedSummary, $rev->getComment() );
+       }
+
+       /**
+        * @covers Revision::isUnpatrolled
+        */
+       public function testIsUnpatrolled_returnsRecentChangesId() {
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $rev = $this->testPage->getRevision();
+
+               $this->assertGreaterThan( 0, $rev->isUnpatrolled() );
+               $this->assertSame( $rev->getRecentChange()->getAttribute( 'rc_id' ), $rev->isUnpatrolled() );
+       }
+
+       /**
+        * @covers Revision::isUnpatrolled
+        */
+       public function testIsUnpatrolled_returnsZeroIfPatrolled() {
+               // This assumes that sysops are auto patrolled
+               $sysop = $this->getTestSysop()->getUser();
+               $this->testPage->doEditContent(
+                       new WikitextContent( __METHOD__ ),
+                       __METHOD__,
+                       0,
+                       false,
+                       $sysop
+               );
+               $rev = $this->testPage->getRevision();
+
+               $this->assertSame( 0, $rev->isUnpatrolled() );
+       }
+
+       /**
+        * This is a simple blanket test for all simple content getters and is methods to provide some
+        * coverage before the split of Revision into multiple classes for MCR work.
+        * @covers Revision::getContent
+        * @covers Revision::getSerializedData
+        * @covers Revision::getContentModel
+        * @covers Revision::getContentFormat
+        * @covers Revision::getContentHandler
+        */
+       public function testSimpleContentGetters() {
+               $expectedText = 'testSimpleContentGetters in Revision. Goats love MCR...';
+               $expectedSummary = 'goatlicious testSimpleContentGetters summary';
+
+               $this->testPage->doEditContent(
+                       new WikitextContent( $expectedText ),
+                       $expectedSummary
+               );
+               $rev = $this->testPage->getRevision();
+
+               $this->assertSame( $expectedText, $rev->getContent()->getNativeData() );
+               $this->assertSame( $expectedText, $rev->getSerializedData() );
+               $this->assertSame( $this->testPage->getContentModel(), $rev->getContentModel() );
+               $this->assertSame( $this->testPage->getContent()->getDefaultFormat(), $rev->getContentFormat() );
+               $this->assertSame( $this->testPage->getContentHandler(), $rev->getContentHandler() );
+       }
+
+}
diff --git a/tests/phpunit/includes/RevisionIntegrationTest.php b/tests/phpunit/includes/RevisionIntegrationTest.php
deleted file mode 100644 (file)
index 96ce766..0000000
+++ /dev/null
@@ -1,994 +0,0 @@
-<?php
-
-/**
- * @group ContentHandler
- * @group Database
- *
- * @group medium
- */
-class RevisionIntegrationTest extends MediaWikiTestCase {
-
-       /**
-        * @var WikiPage $testPage
-        */
-       private $testPage;
-
-       public function __construct( $name = null, array $data = [], $dataName = '' ) {
-               parent::__construct( $name, $data, $dataName );
-
-               $this->tablesUsed = array_merge( $this->tablesUsed,
-                       [
-                               'page',
-                               'revision',
-                               'ip_changes',
-                               'text',
-                               'archive',
-
-                               'recentchanges',
-                               'logging',
-
-                               'page_props',
-                               'pagelinks',
-                               'categorylinks',
-                               'langlinks',
-                               'externallinks',
-                               'imagelinks',
-                               'templatelinks',
-                               'iwlinks'
-                       ]
-               );
-       }
-
-       protected function setUp() {
-               global $wgContLang;
-
-               parent::setUp();
-
-               $this->mergeMwGlobalArrayValue(
-                       'wgExtraNamespaces',
-                       [
-                               12312 => 'Dummy',
-                               12313 => 'Dummy_talk',
-                       ]
-               );
-
-               $this->mergeMwGlobalArrayValue(
-                       'wgNamespaceContentModels',
-                       [
-                               12312 => DummyContentForTesting::MODEL_ID,
-                       ]
-               );
-
-               $this->mergeMwGlobalArrayValue(
-                       'wgContentHandlers',
-                       [
-                               DummyContentForTesting::MODEL_ID => 'DummyContentHandlerForTesting',
-                               RevisionTestModifyableContent::MODEL_ID => 'RevisionTestModifyableContentHandler',
-                       ]
-               );
-
-               MWNamespace::clearCaches();
-               // Reset namespace cache
-               $wgContLang->resetNamespaces();
-               if ( !$this->testPage ) {
-                       $this->testPage = WikiPage::factory( Title::newFromText( 'UTPage' ) );
-               }
-       }
-
-       protected function tearDown() {
-               global $wgContLang;
-
-               parent::tearDown();
-
-               MWNamespace::clearCaches();
-               // Reset namespace cache
-               $wgContLang->resetNamespaces();
-       }
-
-       private function makeRevisionWithProps( $props = null ) {
-               if ( $props === null ) {
-                       $props = [];
-               }
-
-               if ( !isset( $props['content'] ) && !isset( $props['text'] ) ) {
-                       $props['text'] = 'Lorem Ipsum';
-               }
-
-               if ( !isset( $props['comment'] ) ) {
-                       $props['comment'] = 'just a test';
-               }
-
-               if ( !isset( $props['page'] ) ) {
-                       $props['page'] = $this->testPage->getId();
-               }
-
-               $rev = new Revision( $props );
-
-               $dbw = wfGetDB( DB_MASTER );
-               $rev->insertOn( $dbw );
-
-               return $rev;
-       }
-
-       /**
-        * @param string $titleString
-        * @param string $text
-        * @param string|null $model
-        *
-        * @return WikiPage
-        */
-       private function createPage( $titleString, $text, $model = null ) {
-               if ( !preg_match( '/:/', $titleString ) &&
-                       ( $model === null || $model === CONTENT_MODEL_WIKITEXT )
-               ) {
-                       $ns = $this->getDefaultWikitextNS();
-                       $titleString = MWNamespace::getCanonicalName( $ns ) . ':' . $titleString;
-               }
-
-               $title = Title::newFromText( $titleString );
-               $wikipage = new WikiPage( $title );
-
-               // Delete the article if it already exists
-               if ( $wikipage->exists() ) {
-                       $wikipage->doDeleteArticle( "done" );
-               }
-
-               $content = ContentHandler::makeContent( $text, $title, $model );
-               $wikipage->doEditContent( $content, __METHOD__, EDIT_NEW );
-
-               return $wikipage;
-       }
-
-       private function assertRevEquals( Revision $orig, Revision $rev = null ) {
-               $this->assertNotNull( $rev, 'missing revision' );
-
-               $this->assertEquals( $orig->getId(), $rev->getId() );
-               $this->assertEquals( $orig->getPage(), $rev->getPage() );
-               $this->assertEquals( $orig->getTimestamp(), $rev->getTimestamp() );
-               $this->assertEquals( $orig->getUser(), $rev->getUser() );
-               $this->assertEquals( $orig->getContentModel(), $rev->getContentModel() );
-               $this->assertEquals( $orig->getContentFormat(), $rev->getContentFormat() );
-               $this->assertEquals( $orig->getSha1(), $rev->getSha1() );
-       }
-
-       /**
-        * @covers Revision::insertOn
-        */
-       public function testInsertOn_success() {
-               $parentId = $this->testPage->getLatest();
-
-               // If an ExternalStore is set don't use it.
-               $this->setMwGlobals( 'wgDefaultExternalStore', false );
-
-               $rev = new Revision( [
-                       'page' => $this->testPage->getId(),
-                       'title' => $this->testPage->getTitle(),
-                       'text' => 'Revision Text',
-                       'comment' => 'Revision comment',
-               ] );
-
-               $revId = $rev->insertOn( wfGetDB( DB_MASTER ) );
-
-               $this->assertInternalType( 'integer', $revId );
-               $this->assertInternalType( 'integer', $rev->getTextId() );
-               $this->assertSame( $revId, $rev->getId() );
-
-               $this->assertSelect(
-                       'text',
-                       [ 'old_id', 'old_text' ],
-                       "old_id = {$rev->getTextId()}",
-                       [ [ strval( $rev->getTextId() ), 'Revision Text' ] ]
-               );
-               $this->assertSelect(
-                       'revision',
-                       [
-                               'rev_id',
-                               'rev_page',
-                               'rev_text_id',
-                               'rev_user',
-                               'rev_minor_edit',
-                               'rev_deleted',
-                               'rev_len',
-                               'rev_parent_id',
-                               'rev_sha1',
-                       ],
-                       "rev_id = {$rev->getId()}",
-                       [ [
-                               strval( $rev->getId() ),
-                               strval( $this->testPage->getId() ),
-                               strval( $rev->getTextId() ),
-                               '0',
-                               '0',
-                               '0',
-                               '13',
-                               strval( $parentId ),
-                               's0ngbdoxagreuf2vjtuxzwdz64n29xm',
-                       ] ]
-               );
-       }
-
-       /**
-        * @covers Revision::insertOn
-        */
-       public function testInsertOn_exceptionOnNoPage() {
-               // If an ExternalStore is set don't use it.
-               $this->setMwGlobals( 'wgDefaultExternalStore', false );
-               $this->setExpectedException(
-                       MWException::class,
-                       "Cannot insert revision: page ID must be nonzero"
-               );
-
-               $rev = new Revision( [] );
-
-               $rev->insertOn( wfGetDB( DB_MASTER ) );
-       }
-
-       /**
-        * @covers Revision::newFromTitle
-        */
-       public function testNewFromTitle_withoutId() {
-               $latestRevId = $this->testPage->getLatest();
-
-               $rev = Revision::newFromTitle( $this->testPage->getTitle() );
-
-               $this->assertTrue( $this->testPage->getTitle()->equals( $rev->getTitle() ) );
-               $this->assertEquals( $latestRevId, $rev->getId() );
-       }
-
-       /**
-        * @covers Revision::newFromTitle
-        */
-       public function testNewFromTitle_withId() {
-               $latestRevId = $this->testPage->getLatest();
-
-               $rev = Revision::newFromTitle( $this->testPage->getTitle(), $latestRevId );
-
-               $this->assertTrue( $this->testPage->getTitle()->equals( $rev->getTitle() ) );
-               $this->assertEquals( $latestRevId, $rev->getId() );
-       }
-
-       /**
-        * @covers Revision::newFromTitle
-        */
-       public function testNewFromTitle_withBadId() {
-               $latestRevId = $this->testPage->getLatest();
-
-               $rev = Revision::newFromTitle( $this->testPage->getTitle(), $latestRevId + 1 );
-
-               $this->assertNull( $rev );
-       }
-
-       /**
-        * @covers Revision::newFromRow
-        */
-       public function testNewFromRow() {
-               $orig = $this->makeRevisionWithProps();
-
-               $dbr = wfGetDB( DB_REPLICA );
-               $revQuery = Revision::getQueryInfo();
-               $res = $dbr->select( $revQuery['tables'], $revQuery['fields'], [ 'rev_id' => $orig->getId() ],
-                  __METHOD__, [], $revQuery['joins'] );
-               $this->assertTrue( is_object( $res ), 'query failed' );
-
-               $row = $res->fetchObject();
-               $res->free();
-
-               $rev = Revision::newFromRow( $row );
-
-               $this->assertRevEquals( $orig, $rev );
-       }
-
-       public function provideNewFromArchiveRow() {
-               yield [
-                       true,
-                       function ( $f ) {
-                               return $f;
-                       },
-               ];
-               yield [
-                       false,
-                       function ( $f ) {
-                               return $f;
-                       },
-               ];
-               yield [
-                       true,
-                       function ( $f ) {
-                               return $f + [ 'ar_namespace', 'ar_title' ];
-                       },
-               ];
-               yield [
-                       false,
-                       function ( $f ) {
-                               return $f + [ 'ar_namespace', 'ar_title' ];
-                       },
-               ];
-               yield [
-                       true,
-                       function ( $f ) {
-                               unset( $f['ar_text_id'] );
-                               return $f;
-                       },
-               ];
-               yield [
-                       false,
-                       function ( $f ) {
-                               unset( $f['ar_text_id'] );
-                               return $f;
-                       },
-               ];
-       }
-
-       /**
-        * @dataProvider provideNewFromArchiveRow
-        * @covers Revision::newFromArchiveRow
-        */
-       public function testNewFromArchiveRow( $contentHandlerUseDB, $selectModifier ) {
-               $this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
-
-               $page = $this->createPage(
-                       'RevisionStorageTest_testNewFromArchiveRow',
-                       'Lorem Ipsum',
-                       CONTENT_MODEL_WIKITEXT
-               );
-               $orig = $page->getRevision();
-               $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
-
-               $dbr = wfGetDB( DB_REPLICA );
-               $arQuery = Revision::getArchiveQueryInfo();
-               $arQuery['fields'] = $selectModifier( $arQuery['fields'] );
-               $res = $dbr->select(
-                       $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
-                       __METHOD__, [], $arQuery['joins']
-               );
-               $this->assertTrue( is_object( $res ), 'query failed' );
-
-               $row = $res->fetchObject();
-               $res->free();
-
-               $rev = Revision::newFromArchiveRow( $row );
-
-               $this->assertRevEquals( $orig, $rev );
-       }
-
-       /**
-        * @covers Revision::newFromArchiveRow
-        */
-       public function testNewFromArchiveRowOverrides() {
-               $page = $this->createPage(
-                       'RevisionStorageTest_testNewFromArchiveRow',
-                       'Lorem Ipsum',
-                       CONTENT_MODEL_WIKITEXT
-               );
-               $orig = $page->getRevision();
-               $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
-
-               $dbr = wfGetDB( DB_REPLICA );
-               $arQuery = Revision::getArchiveQueryInfo();
-               $res = $dbr->select(
-                       $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
-                       __METHOD__, [], $arQuery['joins']
-               );
-               $this->assertTrue( is_object( $res ), 'query failed' );
-
-               $row = $res->fetchObject();
-               $res->free();
-
-               $rev = Revision::newFromArchiveRow( $row, [ 'comment' => 'SOMEOVERRIDE' ] );
-
-               $this->assertNotEquals( $orig->getComment(), $rev->getComment() );
-               $this->assertEquals( 'SOMEOVERRIDE', $rev->getComment() );
-       }
-
-       /**
-        * @covers Revision::newFromId
-        */
-       public function testNewFromId() {
-               $orig = $this->testPage->getRevision();
-               $rev = Revision::newFromId( $orig->getId() );
-               $this->assertRevEquals( $orig, $rev );
-       }
-
-       /**
-        * @covers Revision::newFromPageId
-        */
-       public function testNewFromPageId() {
-               $rev = Revision::newFromPageId( $this->testPage->getId() );
-               $this->assertRevEquals(
-                       $this->testPage->getRevision(),
-                       $rev
-               );
-       }
-
-       /**
-        * @covers Revision::newFromPageId
-        */
-       public function testNewFromPageIdWithLatestId() {
-               $rev = Revision::newFromPageId(
-                       $this->testPage->getId(),
-                       $this->testPage->getLatest()
-               );
-               $this->assertRevEquals(
-                       $this->testPage->getRevision(),
-                       $rev
-               );
-       }
-
-       /**
-        * @covers Revision::newFromPageId
-        */
-       public function testNewFromPageIdWithNotLatestId() {
-               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
-               $rev = Revision::newFromPageId(
-                       $this->testPage->getId(),
-                       $this->testPage->getRevision()->getPrevious()->getId()
-               );
-               $this->assertRevEquals(
-                       $this->testPage->getRevision()->getPrevious(),
-                       $rev
-               );
-       }
-
-       /**
-        * @covers Revision::fetchRevision
-        */
-       public function testFetchRevision() {
-               // Hidden process cache assertion below
-               $this->testPage->getRevision()->getId();
-
-               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
-               $id = $this->testPage->getRevision()->getId();
-
-               $res = Revision::fetchRevision( $this->testPage->getTitle() );
-
-               # note: order is unspecified
-               $rows = [];
-               while ( ( $row = $res->fetchObject() ) ) {
-                       $rows[$row->rev_id] = $row;
-               }
-
-               $this->assertEquals( 1, count( $rows ), 'expected exactly one revision' );
-               $this->assertArrayHasKey( $id, $rows, 'missing revision with id ' . $id );
-       }
-
-       /**
-        * @covers Revision::getPage
-        */
-       public function testGetPage() {
-               $page = $this->testPage;
-
-               $orig = $this->makeRevisionWithProps( [ 'page' => $page->getId() ] );
-               $rev = Revision::newFromId( $orig->getId() );
-
-               $this->assertEquals( $page->getId(), $rev->getPage() );
-       }
-
-       /**
-        * @covers Revision::isCurrent
-        */
-       public function testIsCurrent() {
-               $rev1 = $this->testPage->getRevision();
-
-               # @todo find out if this should be true
-               # $this->assertTrue( $rev1->isCurrent() );
-
-               $rev1x = Revision::newFromId( $rev1->getId() );
-               $this->assertTrue( $rev1x->isCurrent() );
-
-               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
-               $rev2 = $this->testPage->getRevision();
-
-               # @todo find out if this should be true
-               # $this->assertTrue( $rev2->isCurrent() );
-
-               $rev1x = Revision::newFromId( $rev1->getId() );
-               $this->assertFalse( $rev1x->isCurrent() );
-
-               $rev2x = Revision::newFromId( $rev2->getId() );
-               $this->assertTrue( $rev2x->isCurrent() );
-       }
-
-       /**
-        * @covers Revision::getPrevious
-        */
-       public function testGetPrevious() {
-               $oldestRevision = $this->testPage->getOldestRevision();
-               $latestRevision = $this->testPage->getLatest();
-
-               $this->assertNull( $oldestRevision->getPrevious() );
-
-               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
-               $newRevision = $this->testPage->getRevision();
-
-               $this->assertNotNull( $newRevision->getPrevious() );
-               $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
-       }
-
-       /**
-        * @covers Revision::getNext
-        */
-       public function testGetNext() {
-               $rev1 = $this->testPage->getRevision();
-
-               $this->assertNull( $rev1->getNext() );
-
-               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
-               $rev2 = $this->testPage->getRevision();
-
-               $this->assertNotNull( $rev1->getNext() );
-               $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
-       }
-
-       /**
-        * @covers Revision::newNullRevision
-        */
-       public function testNewNullRevision() {
-               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
-               $orig = $this->testPage->getRevision();
-
-               $dbw = wfGetDB( DB_MASTER );
-               $rev = Revision::newNullRevision( $dbw, $this->testPage->getId(), 'a null revision', false );
-
-               $this->assertNotEquals( $orig->getId(), $rev->getId(),
-                       'new null revision should have a different id from the original revision' );
-               $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
-                       'new null revision should have the same text id as the original revision' );
-               $this->assertEquals( __METHOD__, $rev->getContent()->getNativeData() );
-       }
-
-       /**
-        * @covers Revision::insertOn
-        */
-       public function testInsertOn() {
-               $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
-
-               $orig = $this->makeRevisionWithProps( [
-                       'user_text' => $ip
-               ] );
-
-               // Make sure the revision was copied to ip_changes
-               $dbr = wfGetDB( DB_REPLICA );
-               $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
-               $row = $res->fetchObject();
-
-               $this->assertEquals( IP::toHex( $ip ), $row->ipc_hex );
-               $this->assertEquals( $orig->getTimestamp(), $row->ipc_rev_timestamp );
-       }
-
-       public static function provideUserWasLastToEdit() {
-               yield 'actually the last edit' => [ 3, true ];
-               yield 'not the current edit, but still by this user' => [ 2, true ];
-               yield 'edit by another user' => [ 1, false ];
-               yield 'first edit, by this user, but another user edited in the mean time' => [ 0, false ];
-       }
-
-       /**
-        * @dataProvider provideUserWasLastToEdit
-        */
-       public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
-               $userA = User::newFromName( "RevisionStorageTest_userA" );
-               $userB = User::newFromName( "RevisionStorageTest_userB" );
-
-               if ( $userA->getId() === 0 ) {
-                       $userA = User::createNew( $userA->getName() );
-               }
-
-               if ( $userB->getId() === 0 ) {
-                       $userB = User::createNew( $userB->getName() );
-               }
-
-               $ns = $this->getDefaultWikitextNS();
-
-               $dbw = wfGetDB( DB_MASTER );
-               $revisions = [];
-
-               // create revisions -----------------------------
-               $page = WikiPage::factory( Title::newFromText(
-                       'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
-               $page->insertOn( $dbw );
-
-               $revisions[0] = new Revision( [
-                       'page' => $page->getId(),
-                       // we need the title to determine the page's default content model
-                       'title' => $page->getTitle(),
-                       'timestamp' => '20120101000000',
-                       'user' => $userA->getId(),
-                       'text' => 'zero',
-                       'content_model' => CONTENT_MODEL_WIKITEXT,
-                       'summary' => 'edit zero'
-               ] );
-               $revisions[0]->insertOn( $dbw );
-
-               $revisions[1] = new Revision( [
-                       'page' => $page->getId(),
-                       // still need the title, because $page->getId() is 0 (there's no entry in the page table)
-                       'title' => $page->getTitle(),
-                       'timestamp' => '20120101000100',
-                       'user' => $userA->getId(),
-                       'text' => 'one',
-                       'content_model' => CONTENT_MODEL_WIKITEXT,
-                       'summary' => 'edit one'
-               ] );
-               $revisions[1]->insertOn( $dbw );
-
-               $revisions[2] = new Revision( [
-                       'page' => $page->getId(),
-                       'title' => $page->getTitle(),
-                       'timestamp' => '20120101000200',
-                       'user' => $userB->getId(),
-                       'text' => 'two',
-                       'content_model' => CONTENT_MODEL_WIKITEXT,
-                       'summary' => 'edit two'
-               ] );
-               $revisions[2]->insertOn( $dbw );
-
-               $revisions[3] = new Revision( [
-                       'page' => $page->getId(),
-                       'title' => $page->getTitle(),
-                       'timestamp' => '20120101000300',
-                       'user' => $userA->getId(),
-                       'text' => 'three',
-                       'content_model' => CONTENT_MODEL_WIKITEXT,
-                       'summary' => 'edit three'
-               ] );
-               $revisions[3]->insertOn( $dbw );
-
-               $revisions[4] = new Revision( [
-                       'page' => $page->getId(),
-                       'title' => $page->getTitle(),
-                       'timestamp' => '20120101000200',
-                       'user' => $userA->getId(),
-                       'text' => 'zero',
-                       'content_model' => CONTENT_MODEL_WIKITEXT,
-                       'summary' => 'edit four'
-               ] );
-               $revisions[4]->insertOn( $dbw );
-
-               // test it ---------------------------------
-               $since = $revisions[$sinceIdx]->getTimestamp();
-
-               $wasLast = Revision::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
-
-               $this->assertEquals( $expectedLast, $wasLast );
-       }
-
-       /**
-        * @param string $text
-        * @param string $title
-        * @param string $model
-        * @param string $format
-        *
-        * @return Revision
-        */
-       private function newTestRevision( $text, $title = "Test",
-               $model = CONTENT_MODEL_WIKITEXT, $format = null
-       ) {
-               if ( is_string( $title ) ) {
-                       $title = Title::newFromText( $title );
-               }
-
-               $content = ContentHandler::makeContent( $text, $title, $model, $format );
-
-               $rev = new Revision(
-                       [
-                               'id' => 42,
-                               'page' => 23,
-                               'title' => $title,
-
-                               'content' => $content,
-                               'length' => $content->getSize(),
-                               'comment' => "testing",
-                               'minor_edit' => false,
-
-                               'content_format' => $format,
-                       ]
-               );
-
-               return $rev;
-       }
-
-       public function provideGetContentModel() {
-               // NOTE: we expect the help namespace to always contain wikitext
-               return [
-                       [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ],
-                       [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ],
-                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting::MODEL_ID ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideGetContentModel
-        * @covers Revision::getContentModel
-        */
-       public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
-               $rev = $this->newTestRevision( $text, $title, $model, $format );
-
-               $this->assertEquals( $expectedModel, $rev->getContentModel() );
-       }
-
-       public function provideGetContentFormat() {
-               // NOTE: we expect the help namespace to always contain wikitext
-               return [
-                       [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ],
-                       [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ],
-                       [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ],
-                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting::MODEL_ID ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideGetContentFormat
-        * @covers Revision::getContentFormat
-        */
-       public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
-               $rev = $this->newTestRevision( $text, $title, $model, $format );
-
-               $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
-       }
-
-       public function provideGetContentHandler() {
-               // NOTE: we expect the help namespace to always contain wikitext
-               return [
-                       [ 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ],
-                       [ 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ],
-                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideGetContentHandler
-        * @covers Revision::getContentHandler
-        */
-       public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
-               $rev = $this->newTestRevision( $text, $title, $model, $format );
-
-               $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
-       }
-
-       public function provideGetContent() {
-               // NOTE: we expect the help namespace to always contain wikitext
-               return [
-                       [ 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ],
-                       [
-                               serialize( 'hello world' ),
-                               'Hello',
-                               DummyContentForTesting::MODEL_ID,
-                               null,
-                               Revision::FOR_PUBLIC,
-                               serialize( 'hello world' )
-                       ],
-                       [
-                               serialize( 'hello world' ),
-                               'Dummy:Hello',
-                               null,
-                               null,
-                               Revision::FOR_PUBLIC,
-                               serialize( 'hello world' )
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideGetContent
-        * @covers Revision::getContent
-        */
-       public function testGetContent( $text, $title, $model, $format,
-               $audience, $expectedSerialization
-       ) {
-               $rev = $this->newTestRevision( $text, $title, $model, $format );
-               $content = $rev->getContent( $audience );
-
-               $this->assertEquals(
-                       $expectedSerialization,
-                       is_null( $content ) ? null : $content->serialize( $format )
-               );
-       }
-
-       /**
-        * @covers Revision::getContent
-        */
-       public function testGetContent_failure() {
-               $rev = new Revision( [
-                       'page' => $this->testPage->getId(),
-                       'content_model' => $this->testPage->getContentModel(),
-                       'text_id' => 123456789, // not in the test DB
-               ] );
-
-               $this->assertNull( $rev->getContent(),
-                       "getContent() should return null if the revision's text blob could not be loaded." );
-
-               // NOTE: check this twice, once for lazy initialization, and once with the cached value.
-               $this->assertNull( $rev->getContent(),
-                       "getContent() should return null if the revision's text blob could not be loaded." );
-       }
-
-       public function provideGetSize() {
-               return [
-                       [ "hello world.", CONTENT_MODEL_WIKITEXT, 12 ],
-                       [ serialize( "hello world." ), DummyContentForTesting::MODEL_ID, 12 ],
-               ];
-       }
-
-       /**
-        * @covers Revision::getSize
-        * @dataProvider provideGetSize
-        */
-       public function testGetSize( $text, $model, $expected_size ) {
-               $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSize', $model );
-               $this->assertEquals( $expected_size, $rev->getSize() );
-       }
-
-       public function provideGetSha1() {
-               return [
-                       [ "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ],
-                       [
-                               serialize( "hello world." ),
-                               DummyContentForTesting::MODEL_ID,
-                               Revision::base36Sha1( serialize( "hello world." ) )
-                       ],
-               ];
-       }
-
-       /**
-        * @covers Revision::getSha1
-        * @dataProvider provideGetSha1
-        */
-       public function testGetSha1( $text, $model, $expected_hash ) {
-               $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSha1', $model );
-               $this->assertEquals( $expected_hash, $rev->getSha1() );
-       }
-
-       /**
-        * Tests whether $rev->getContent() returns a clone when needed.
-        *
-        * @covers Revision::getContent
-        */
-       public function testGetContentClone() {
-               $content = new RevisionTestModifyableContent( "foo" );
-
-               $rev = new Revision(
-                       [
-                               'id' => 42,
-                               'page' => 23,
-                               'title' => Title::newFromText( "testGetContentClone_dummy" ),
-
-                               'content' => $content,
-                               'length' => $content->getSize(),
-                               'comment' => "testing",
-                               'minor_edit' => false,
-                       ]
-               );
-
-               /** @var RevisionTestModifyableContent $content */
-               $content = $rev->getContent( Revision::RAW );
-               $content->setText( "bar" );
-
-               /** @var RevisionTestModifyableContent $content2 */
-               $content2 = $rev->getContent( Revision::RAW );
-               // content is mutable, expect clone
-               $this->assertNotSame( $content, $content2, "expected a clone" );
-               // clone should contain the original text
-               $this->assertEquals( "foo", $content2->getText() );
-
-               $content2->setText( "bla bla" );
-               // clones should be independent
-               $this->assertEquals( "bar", $content->getText() );
-       }
-
-       /**
-        * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
-        * @covers Revision::getContent
-        */
-       public function testGetContentUncloned() {
-               $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT );
-               $content = $rev->getContent( Revision::RAW );
-               $content2 = $rev->getContent( Revision::RAW );
-
-               // for immutable content like wikitext, this should be the same object
-               $this->assertSame( $content, $content2 );
-       }
-
-       /**
-        * @covers Revision::loadFromId
-        */
-       public function testLoadFromId() {
-               $rev = $this->testPage->getRevision();
-               $this->assertRevEquals(
-                       $rev,
-                       Revision::loadFromId( wfGetDB( DB_MASTER ), $rev->getId() )
-               );
-       }
-
-       /**
-        * @covers Revision::loadFromPageId
-        */
-       public function testLoadFromPageId() {
-               $this->assertRevEquals(
-                       $this->testPage->getRevision(),
-                       Revision::loadFromPageId( wfGetDB( DB_MASTER ), $this->testPage->getId() )
-               );
-       }
-
-       /**
-        * @covers Revision::loadFromPageId
-        */
-       public function testLoadFromPageIdWithLatestRevId() {
-               $this->assertRevEquals(
-                       $this->testPage->getRevision(),
-                       Revision::loadFromPageId(
-                               wfGetDB( DB_MASTER ),
-                               $this->testPage->getId(),
-                               $this->testPage->getLatest()
-                       )
-               );
-       }
-
-       /**
-        * @covers Revision::loadFromPageId
-        */
-       public function testLoadFromPageIdWithNotLatestRevId() {
-               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
-               $this->assertRevEquals(
-                       $this->testPage->getRevision()->getPrevious(),
-                       Revision::loadFromPageId(
-                               wfGetDB( DB_MASTER ),
-                               $this->testPage->getId(),
-                               $this->testPage->getRevision()->getPrevious()->getId()
-                       )
-               );
-       }
-
-       /**
-        * @covers Revision::loadFromTitle
-        */
-       public function testLoadFromTitle() {
-               $this->assertRevEquals(
-                       $this->testPage->getRevision(),
-                       Revision::loadFromTitle( wfGetDB( DB_MASTER ), $this->testPage->getTitle() )
-               );
-       }
-
-       /**
-        * @covers Revision::loadFromTitle
-        */
-       public function testLoadFromTitleWithLatestRevId() {
-               $this->assertRevEquals(
-                       $this->testPage->getRevision(),
-                       Revision::loadFromTitle(
-                               wfGetDB( DB_MASTER ),
-                               $this->testPage->getTitle(),
-                               $this->testPage->getLatest()
-                       )
-               );
-       }
-
-       /**
-        * @covers Revision::loadFromTitle
-        */
-       public function testLoadFromTitleWithNotLatestRevId() {
-               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
-               $this->assertRevEquals(
-                       $this->testPage->getRevision()->getPrevious(),
-                       Revision::loadFromTitle(
-                               wfGetDB( DB_MASTER ),
-                               $this->testPage->getTitle(),
-                               $this->testPage->getRevision()->getPrevious()->getId()
-                       )
-               );
-       }
-
-       /**
-        * @covers Revision::loadFromTimestamp()
-        */
-       public function testLoadFromTimestamp() {
-               $this->assertRevEquals(
-                       $this->testPage->getRevision(),
-                       Revision::loadFromTimestamp(
-                               wfGetDB( DB_MASTER ),
-                               $this->testPage->getTitle(),
-                               $this->testPage->getRevision()->getTimestamp()
-                       )
-               );
-       }
-
-}
diff --git a/tests/phpunit/includes/RevisionNoContentHandlerDbTest.php b/tests/phpunit/includes/RevisionNoContentHandlerDbTest.php
new file mode 100644 (file)
index 0000000..c980a48
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * @group Database
+ * @group medium
+ * @group ContentHandler
+ */
+class RevisionNoContentHandlerDbTest extends RevisionDbTestBase {
+
+       protected function getContentHandlerUseDB() {
+               return false;
+       }
+
+}
diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php
new file mode 100644 (file)
index 0000000..953c795
--- /dev/null
@@ -0,0 +1,469 @@
+<?php
+
+use Wikimedia\TestingAccessWrapper;
+
+/**
+ * Test cases in RevisionTest should not interact with the Database.
+ * For test cases that need Database interaction see RevisionDbTestBase.
+ */
+class RevisionTest extends MediaWikiTestCase {
+
+       public function provideConstructFromArray() {
+               yield 'with text' => [
+                       [
+                               'text' => 'hello world.',
+                               'content_model' => CONTENT_MODEL_JAVASCRIPT
+                       ],
+               ];
+               yield 'with content' => [
+                       [
+                               'content' => new JavaScriptContent( 'hellow world.' )
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideConstructFromArray
+        * @covers Revision::__construct
+        * @covers Revision::constructFromRowArray
+        */
+       public function testConstructFromArray( array $rowArray ) {
+               $rev = new Revision( $rowArray );
+               $this->assertNotNull( $rev->getContent(), 'no content object available' );
+               $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContent()->getModel() );
+               $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() );
+       }
+
+       public function provideConstructFromArrayThrowsExceptions() {
+               yield 'content and text_id both not empty' => [
+                       [
+                               'content' => new WikitextContent( 'GOAT' ),
+                               'text_id' => 'someid',
+                               ],
+                       new MWException( "Text already stored in external store (id someid), " .
+                               "can't serialize content object" )
+               ];
+               yield 'with bad content object (class)' => [
+                       [ 'content' => new stdClass() ],
+                       new MWException( '`content` field must contain a Content object.' )
+               ];
+               yield 'with bad content object (string)' => [
+                       [ 'content' => 'ImAGoat' ],
+                       new MWException( '`content` field must contain a Content object.' )
+               ];
+               yield 'bad row format' => [
+                       'imastring, not a row',
+                       new MWException( 'Revision constructor passed invalid row format.' )
+               ];
+       }
+
+       /**
+        * @dataProvider provideConstructFromArrayThrowsExceptions
+        * @covers Revision::__construct
+        * @covers Revision::constructFromRowArray
+        */
+       public function testConstructFromArrayThrowsExceptions( $rowArray, Exception $expectedException ) {
+               $this->setExpectedException(
+                       get_class( $expectedException ),
+                       $expectedException->getMessage(),
+                       $expectedException->getCode()
+               );
+               new Revision( $rowArray );
+       }
+
+       public function provideConstructFromRow() {
+               yield 'Full construction' => [
+                       [
+                               'rev_id' => '2',
+                               'rev_page' => '1',
+                               'rev_text_id' => '2',
+                               'rev_timestamp' => '20171017114835',
+                               'rev_user_text' => '127.0.0.1',
+                               'rev_user' => '0',
+                               'rev_minor_edit' => '0',
+                               'rev_deleted' => '0',
+                               'rev_len' => '46',
+                               'rev_parent_id' => '1',
+                               'rev_sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
+                               'rev_comment_text' => 'Goat Comment!',
+                               'rev_comment_data' => null,
+                               'rev_comment_cid' => null,
+                               'rev_content_format' => 'GOATFORMAT',
+                               'rev_content_model' => 'GOATMODEL',
+                       ],
+                       function ( RevisionTest $testCase, Revision $rev ) {
+                               $testCase->assertSame( 2, $rev->getId() );
+                               $testCase->assertSame( 1, $rev->getPage() );
+                               $testCase->assertSame( 2, $rev->getTextId() );
+                               $testCase->assertSame( '20171017114835', $rev->getTimestamp() );
+                               $testCase->assertSame( '127.0.0.1', $rev->getUserText() );
+                               $testCase->assertSame( 0, $rev->getUser() );
+                               $testCase->assertSame( false, $rev->isMinor() );
+                               $testCase->assertSame( false, $rev->isDeleted( Revision::DELETED_TEXT ) );
+                               $testCase->assertSame( 46, $rev->getSize() );
+                               $testCase->assertSame( 1, $rev->getParentId() );
+                               $testCase->assertSame( 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z', $rev->getSha1() );
+                               $testCase->assertSame( 'Goat Comment!', $rev->getComment() );
+                               $testCase->assertSame( 'GOATFORMAT', $rev->getContentFormat() );
+                               $testCase->assertSame( 'GOATMODEL', $rev->getContentModel() );
+                       }
+               ];
+               yield 'null fields' => [
+                       [
+                               'rev_id' => '2',
+                               'rev_page' => '1',
+                               'rev_text_id' => '2',
+                               'rev_timestamp' => '20171017114835',
+                               'rev_user_text' => '127.0.0.1',
+                               'rev_user' => '0',
+                               'rev_minor_edit' => '0',
+                               'rev_deleted' => '0',
+                               'rev_comment_text' => 'Goat Comment!',
+                               'rev_comment_data' => null,
+                               'rev_comment_cid' => null,
+                       ],
+                       function ( RevisionTest $testCase, Revision $rev ) {
+                               $testCase->assertNull( $rev->getSize() );
+                               $testCase->assertNull( $rev->getParentId() );
+                               $testCase->assertNull( $rev->getSha1() );
+                               $testCase->assertSame( 'text/x-wiki', $rev->getContentFormat() );
+                               $testCase->assertSame( 'wikitext', $rev->getContentModel() );
+                       }
+               ];
+       }
+
+       /**
+        * @dataProvider provideConstructFromRow
+        * @covers Revision::__construct
+        * @covers Revision::constructFromDbRowObject
+        */
+       public function testConstructFromRow( array $arrayData, $assertions ) {
+               $row = (object)$arrayData;
+               $rev = new Revision( $row );
+               $assertions( $this, $rev );
+       }
+
+       public function provideGetRevisionText() {
+               yield 'Generic test' => [
+                       'This is a goat of revision text.',
+                       [
+                               'old_flags' => '',
+                               'old_text' => 'This is a goat of revision text.',
+                       ],
+               ];
+       }
+
+       public function provideGetId() {
+               yield [
+                       [],
+                       null
+               ];
+               yield [
+                       [ 'id' => 998 ],
+                       998
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetId
+        * @covers Revision::getId
+        */
+       public function testGetId( $rowArray, $expectedId ) {
+               $rev = new Revision( $rowArray );
+               $this->assertEquals( $expectedId, $rev->getId() );
+       }
+
+       public function provideSetId() {
+               yield [ '123', 123 ];
+               yield [ 456, 456 ];
+       }
+
+       /**
+        * @dataProvider provideSetId
+        * @covers Revision::setId
+        */
+       public function testSetId( $input, $expected ) {
+               $rev = new Revision( [] );
+               $rev->setId( $input );
+               $this->assertSame( $expected, $rev->getId() );
+       }
+
+       public function provideSetUserIdAndName() {
+               yield [ '123', 123, 'GOaT' ];
+               yield [ 456, 456, 'GOaT' ];
+       }
+
+       /**
+        * @dataProvider provideSetUserIdAndName
+        * @covers Revision::setUserIdAndName
+        */
+       public function testSetUserIdAndName( $inputId, $expectedId, $name ) {
+               $rev = new Revision( [] );
+               $rev->setUserIdAndName( $inputId, $name );
+               $this->assertSame( $expectedId, $rev->getUser( Revision::RAW ) );
+               $this->assertEquals( $name, $rev->getUserText( Revision::RAW ) );
+       }
+
+       public function provideGetTextId() {
+               yield [ [], null ];
+               yield [ [ 'text_id' => '123' ], 123 ];
+               yield [ [ 'text_id' => 456 ], 456 ];
+       }
+
+       /**
+        * @dataProvider provideGetTextId
+        * @covers Revision::getTextId()
+        */
+       public function testGetTextId( $rowArray, $expected ) {
+               $rev = new Revision( $rowArray );
+               $this->assertSame( $expected, $rev->getTextId() );
+       }
+
+       public function provideGetParentId() {
+               yield [ [], null ];
+               yield [ [ 'parent_id' => '123' ], 123 ];
+               yield [ [ 'parent_id' => 456 ], 456 ];
+       }
+
+       /**
+        * @dataProvider provideGetParentId
+        * @covers Revision::getParentId()
+        */
+       public function testGetParentId( $rowArray, $expected ) {
+               $rev = new Revision( $rowArray );
+               $this->assertSame( $expected, $rev->getParentId() );
+       }
+
+       /**
+        * @covers Revision::getRevisionText
+        * @dataProvider provideGetRevisionText
+        */
+       public function testGetRevisionText( $expected, $rowData, $prefix = 'old_', $wiki = false ) {
+               $this->assertEquals(
+                       $expected,
+                       Revision::getRevisionText( (object)$rowData, $prefix, $wiki ) );
+       }
+
+       public function provideGetRevisionTextWithZlibExtension() {
+               yield 'Generic gzip test' => [
+                       'This is a small goat of revision text.',
+                       [
+                               'old_flags' => 'gzip',
+                               'old_text' => gzdeflate( 'This is a small goat of revision text.' ),
+                       ],
+               ];
+       }
+
+       /**
+        * @covers Revision::getRevisionText
+        * @dataProvider provideGetRevisionTextWithZlibExtension
+        */
+       public function testGetRevisionWithZlibExtension( $expected, $rowData ) {
+               $this->checkPHPExtension( 'zlib' );
+               $this->testGetRevisionText( $expected, $rowData );
+       }
+
+       public function provideGetRevisionTextWithLegacyEncoding() {
+               yield 'Utf8Native' => [
+                       "Wiki est l'\xc3\xa9cole superieur !",
+                       'iso-8859-1',
+                       [
+                               'old_flags' => 'utf-8',
+                               'old_text' => "Wiki est l'\xc3\xa9cole superieur !",
+                       ]
+               ];
+               yield 'Utf8Legacy' => [
+                       "Wiki est l'\xc3\xa9cole superieur !",
+                       'iso-8859-1',
+                       [
+                               'old_flags' => '',
+                               'old_text' => "Wiki est l'\xe9cole superieur !",
+                       ]
+               ];
+       }
+
+       /**
+        * @covers Revision::getRevisionText
+        * @dataProvider provideGetRevisionTextWithLegacyEncoding
+        */
+       public function testGetRevisionWithLegacyEncoding( $expected, $encoding, $rowData ) {
+               $this->setMwGlobals( 'wgLegacyEncoding', $encoding );
+               $this->testGetRevisionText( $expected, $rowData );
+       }
+
+       public function provideGetRevisionTextWithGzipAndLegacyEncoding() {
+               /**
+                * WARNING!
+                * Do not set the external flag!
+                * Otherwise, getRevisionText will hit the live database (if ExternalStore is enabled)!
+                */
+               yield 'Utf8NativeGzip' => [
+                       "Wiki est l'\xc3\xa9cole superieur !",
+                       'iso-8859-1',
+                       [
+                               'old_flags' => 'gzip,utf-8',
+                               'old_text' => gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" ),
+                       ]
+               ];
+               yield 'Utf8LegacyGzip' => [
+                       "Wiki est l'\xc3\xa9cole superieur !",
+                       'iso-8859-1',
+                       [
+                               'old_flags' => 'gzip',
+                               'old_text' => gzdeflate( "Wiki est l'\xe9cole superieur !" ),
+                       ]
+               ];
+       }
+
+       /**
+        * @covers Revision::getRevisionText
+        * @dataProvider provideGetRevisionTextWithGzipAndLegacyEncoding
+        */
+       public function testGetRevisionWithGzipAndLegacyEncoding( $expected, $encoding, $rowData ) {
+               $this->checkPHPExtension( 'zlib' );
+               $this->setMwGlobals( 'wgLegacyEncoding', $encoding );
+               $this->testGetRevisionText( $expected, $rowData );
+       }
+
+       /**
+        * @covers Revision::compressRevisionText
+        */
+       public function testCompressRevisionTextUtf8() {
+               $row = new stdClass;
+               $row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
+               $row->old_flags = Revision::compressRevisionText( $row->old_text );
+               $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
+                       "Flags should contain 'utf-8'" );
+               $this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ),
+                       "Flags should not contain 'gzip'" );
+               $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
+                       $row->old_text, "Direct check" );
+               $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
+                       Revision::getRevisionText( $row ), "getRevisionText" );
+       }
+
+       /**
+        * @covers Revision::compressRevisionText
+        */
+       public function testCompressRevisionTextUtf8Gzip() {
+               $this->checkPHPExtension( 'zlib' );
+               $this->setMwGlobals( 'wgCompressRevisions', true );
+
+               $row = new stdClass;
+               $row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
+               $row->old_flags = Revision::compressRevisionText( $row->old_text );
+               $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
+                       "Flags should contain 'utf-8'" );
+               $this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ),
+                       "Flags should contain 'gzip'" );
+               $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
+                       gzinflate( $row->old_text ), "Direct check" );
+               $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
+                       Revision::getRevisionText( $row ), "getRevisionText" );
+       }
+
+       public function provideFetchFromConds() {
+               yield [ 0, [] ];
+               yield [ Revision::READ_LOCKING, [ 'FOR UPDATE' ] ];
+       }
+
+       /**
+        * @dataProvider provideFetchFromConds
+        * @covers Revision::fetchFromConds
+        */
+       public function testFetchFromConds( $flags, array $options ) {
+               $conditions = [ 'conditionsArray' ];
+
+               $db = $this->getMock( IDatabase::class );
+               $db->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               $this->equalTo( [ 'revision', 'page', 'user' ] ),
+                               // We don't really care about the fields are they come from the selectField methods
+                               $this->isType( 'array' ),
+                               $this->equalTo( $conditions ),
+                               // Method name
+                               $this->equalTo( 'Revision::fetchFromConds' ),
+                               $this->equalTo( $options ),
+                               // We don't really care about the join conds are they come from the joinCond methods
+                               $this->isType( 'array' )
+                       )
+                       ->willReturn( 'RETURNVALUE' );
+
+               $wrapper = TestingAccessWrapper::newFromClass( Revision::class );
+               $result = $wrapper->fetchFromConds( $db, $conditions, $flags );
+
+               $this->assertEquals( 'RETURNVALUE', $result );
+       }
+
+       public function provideDecompressRevisionText() {
+               yield '(no legacy encoding), false in false out' => [ false, false, [], false ];
+               yield '(no legacy encoding), empty in empty out' => [ false, '', [], '' ];
+               yield '(no legacy encoding), empty in empty out' => [ false, 'A', [], 'A' ];
+               yield '(no legacy encoding), string in with gzip flag returns string' => [
+                       // gzip string below generated with gzdeflate( 'AAAABBAAA' )
+                       false, "sttttr\002\022\000", [ 'gzip' ], 'AAAABBAAA',
+               ];
+               yield '(no legacy encoding), string in with object flag returns false' => [
+                       // gzip string below generated with serialize( 'JOJO' )
+                       false, "s:4:\"JOJO\";", [ 'object' ], false,
+               ];
+               yield '(no legacy encoding), serialized object in with object flag returns string' => [
+                       false,
+                       // Using a TitleValue object as it has a getText method (which is needed)
+                       serialize( new TitleValue( 0, 'HHJJDDFF' ) ),
+                       [ 'object' ],
+                       'HHJJDDFF',
+               ];
+               yield '(no legacy encoding), serialized object in with object & gzip flag returns string' => [
+                       false,
+                       // Using a TitleValue object as it has a getText method (which is needed)
+                       gzdeflate( serialize( new TitleValue( 0, '8219JJJ840' ) ) ),
+                       [ 'object', 'gzip' ],
+                       '8219JJJ840',
+               ];
+               yield '(ISO-8859-1 encoding), string in string out' => [
+                       'ISO-8859-1',
+                       iconv( 'utf8', 'ISO-8859-1', "1®Àþ1" ),
+                       [],
+                       '1®Àþ1',
+               ];
+               yield '(ISO-8859-1 encoding), serialized object in with gzip flags returns string' => [
+                       'ISO-8859-1',
+                       gzdeflate( iconv( 'utf8', 'ISO-8859-1', "4®Àþ4" ) ),
+                       [ 'gzip' ],
+                       '4®Àþ4',
+               ];
+               yield '(ISO-8859-1 encoding), serialized object in with object flags returns string' => [
+                       'ISO-8859-1',
+                       serialize( new TitleValue( 0, iconv( 'utf8', 'ISO-8859-1', "3®Àþ3" ) ) ),
+                       [ 'object' ],
+                       '3®Àþ3',
+               ];
+               yield '(ISO-8859-1 encoding), serialized object in with object & gzip flags returns string' => [
+                       'ISO-8859-1',
+                       gzdeflate( serialize( new TitleValue( 0, iconv( 'utf8', 'ISO-8859-1', "2®Àþ2" ) ) ) ),
+                       [ 'gzip', 'object' ],
+                       '2®Àþ2',
+               ];
+       }
+
+       /**
+        * @dataProvider provideDecompressRevisionText
+        * @covers Revision::decompressRevisionText
+        *
+        * @param bool $legacyEncoding
+        * @param mixed $text
+        * @param array $flags
+        * @param mixed $expected
+        */
+       public function testDecompressRevisionText( $legacyEncoding, $text, $flags, $expected ) {
+               $this->setMwGlobals( 'wgLegacyEncoding', $legacyEncoding );
+               $this->setMwGlobals( 'wgLanguageCode', 'en' );
+               $this->assertSame(
+                       $expected,
+                       Revision::decompressRevisionText( $text, $flags )
+               );
+       }
+
+}
diff --git a/tests/phpunit/includes/RevisionUnitTest.php b/tests/phpunit/includes/RevisionUnitTest.php
deleted file mode 100644 (file)
index 7b8d316..0000000
+++ /dev/null
@@ -1,397 +0,0 @@
-<?php
-
-use Wikimedia\TestingAccessWrapper;
-
-/**
- * @group ContentHandler
- */
-class RevisionUnitTest extends MediaWikiTestCase {
-
-       public function provideConstructFromArray() {
-               yield 'with text' => [
-                       [
-                               'text' => 'hello world.',
-                               'content_model' => CONTENT_MODEL_JAVASCRIPT
-                       ],
-               ];
-               yield 'with content' => [
-                       [
-                               'content' => new JavaScriptContent( 'hellow world.' )
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideConstructFromArray
-        * @covers Revision::__construct
-        * @covers Revision::constructFromRowArray
-        */
-       public function testConstructFromArray( array $rowArray ) {
-               $rev = new Revision( $rowArray );
-               $this->assertNotNull( $rev->getContent(), 'no content object available' );
-               $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContent()->getModel() );
-               $this->assertEquals( CONTENT_MODEL_JAVASCRIPT, $rev->getContentModel() );
-       }
-
-       public function provideConstructFromArrayThrowsExceptions() {
-               yield 'content and text_id both not empty' => [
-                       [
-                               'content' => new WikitextContent( 'GOAT' ),
-                               'text_id' => 'someid',
-                               ],
-                       new MWException( "Text already stored in external store (id someid), " .
-                               "can't serialize content object" )
-               ];
-               yield 'with bad content object (class)' => [
-                       [ 'content' => new stdClass() ],
-                       new MWException( '`content` field must contain a Content object.' )
-               ];
-               yield 'with bad content object (string)' => [
-                       [ 'content' => 'ImAGoat' ],
-                       new MWException( '`content` field must contain a Content object.' )
-               ];
-               yield 'bad row format' => [
-                       'imastring, not a row',
-                       new MWException( 'Revision constructor passed invalid row format.' )
-               ];
-       }
-
-       /**
-        * @dataProvider provideConstructFromArrayThrowsExceptions
-        * @covers Revision::__construct
-        * @covers Revision::constructFromRowArray
-        */
-       public function testConstructFromArrayThrowsExceptions( $rowArray, Exception $expectedException ) {
-               $this->setExpectedException(
-                       get_class( $expectedException ),
-                       $expectedException->getMessage(),
-                       $expectedException->getCode()
-               );
-               new Revision( $rowArray );
-       }
-
-       public function provideConstructFromRow() {
-               yield 'Full construction' => [
-                       [
-                               'rev_id' => '2',
-                               'rev_page' => '1',
-                               'rev_text_id' => '2',
-                               'rev_timestamp' => '20171017114835',
-                               'rev_user_text' => '127.0.0.1',
-                               'rev_user' => '0',
-                               'rev_minor_edit' => '0',
-                               'rev_deleted' => '0',
-                               'rev_len' => '46',
-                               'rev_parent_id' => '1',
-                               'rev_sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
-                               'rev_comment_text' => 'Goat Comment!',
-                               'rev_comment_data' => null,
-                               'rev_comment_cid' => null,
-                               'rev_content_format' => 'GOATFORMAT',
-                               'rev_content_model' => 'GOATMODEL',
-                       ],
-                       function ( RevisionUnitTest $testCase, Revision $rev ) {
-                               $testCase->assertSame( 2, $rev->getId() );
-                               $testCase->assertSame( 1, $rev->getPage() );
-                               $testCase->assertSame( 2, $rev->getTextId() );
-                               $testCase->assertSame( '20171017114835', $rev->getTimestamp() );
-                               $testCase->assertSame( '127.0.0.1', $rev->getUserText() );
-                               $testCase->assertSame( 0, $rev->getUser() );
-                               $testCase->assertSame( false, $rev->isMinor() );
-                               $testCase->assertSame( false, $rev->isDeleted( Revision::DELETED_TEXT ) );
-                               $testCase->assertSame( 46, $rev->getSize() );
-                               $testCase->assertSame( 1, $rev->getParentId() );
-                               $testCase->assertSame( 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z', $rev->getSha1() );
-                               $testCase->assertSame( 'Goat Comment!', $rev->getComment() );
-                               $testCase->assertSame( 'GOATFORMAT', $rev->getContentFormat() );
-                               $testCase->assertSame( 'GOATMODEL', $rev->getContentModel() );
-                       }
-               ];
-               yield 'null fields' => [
-                       [
-                               'rev_id' => '2',
-                               'rev_page' => '1',
-                               'rev_text_id' => '2',
-                               'rev_timestamp' => '20171017114835',
-                               'rev_user_text' => '127.0.0.1',
-                               'rev_user' => '0',
-                               'rev_minor_edit' => '0',
-                               'rev_deleted' => '0',
-                               'rev_comment_text' => 'Goat Comment!',
-                               'rev_comment_data' => null,
-                               'rev_comment_cid' => null,
-                       ],
-                       function ( RevisionUnitTest $testCase, Revision $rev ) {
-                               $testCase->assertNull( $rev->getSize() );
-                               $testCase->assertNull( $rev->getParentId() );
-                               $testCase->assertNull( $rev->getSha1() );
-                               $testCase->assertSame( 'text/x-wiki', $rev->getContentFormat() );
-                               $testCase->assertSame( 'wikitext', $rev->getContentModel() );
-                       }
-               ];
-       }
-
-       /**
-        * @dataProvider provideConstructFromRow
-        * @covers Revision::__construct
-        * @covers Revision::constructFromDbRowObject
-        */
-       public function testConstructFromRow( array $arrayData, $assertions ) {
-               $row = (object)$arrayData;
-               $rev = new Revision( $row );
-               $assertions( $this, $rev );
-       }
-
-       public function provideGetRevisionText() {
-               yield 'Generic test' => [
-                       'This is a goat of revision text.',
-                       [
-                               'old_flags' => '',
-                               'old_text' => 'This is a goat of revision text.',
-                       ],
-               ];
-       }
-
-       public function provideGetId() {
-               yield [
-                       [],
-                       null
-               ];
-               yield [
-                       [ 'id' => 998 ],
-                       998
-               ];
-       }
-
-       /**
-        * @dataProvider provideGetId
-        * @covers Revision::getId
-        */
-       public function testGetId( $rowArray, $expectedId ) {
-               $rev = new Revision( $rowArray );
-               $this->assertEquals( $expectedId, $rev->getId() );
-       }
-
-       public function provideSetId() {
-               yield [ '123', 123 ];
-               yield [ 456, 456 ];
-       }
-
-       /**
-        * @dataProvider provideSetId
-        * @covers Revision::setId
-        */
-       public function testSetId( $input, $expected ) {
-               $rev = new Revision( [] );
-               $rev->setId( $input );
-               $this->assertSame( $expected, $rev->getId() );
-       }
-
-       public function provideSetUserIdAndName() {
-               yield [ '123', 123, 'GOaT' ];
-               yield [ 456, 456, 'GOaT' ];
-       }
-
-       /**
-        * @dataProvider provideSetUserIdAndName
-        * @covers Revision::setUserIdAndName
-        */
-       public function testSetUserIdAndName( $inputId, $expectedId, $name ) {
-               $rev = new Revision( [] );
-               $rev->setUserIdAndName( $inputId, $name );
-               $this->assertSame( $expectedId, $rev->getUser( Revision::RAW ) );
-               $this->assertEquals( $name, $rev->getUserText( Revision::RAW ) );
-       }
-
-       public function provideGetTextId() {
-               yield [ [], null ];
-               yield [ [ 'text_id' => '123' ], 123 ];
-               yield [ [ 'text_id' => 456 ], 456 ];
-       }
-
-       /**
-        * @dataProvider provideGetTextId
-        * @covers Revision::getTextId()
-        */
-       public function testGetTextId( $rowArray, $expected ) {
-               $rev = new Revision( $rowArray );
-               $this->assertSame( $expected, $rev->getTextId() );
-       }
-
-       public function provideGetParentId() {
-               yield [ [], null ];
-               yield [ [ 'parent_id' => '123' ], 123 ];
-               yield [ [ 'parent_id' => 456 ], 456 ];
-       }
-
-       /**
-        * @dataProvider provideGetParentId
-        * @covers Revision::getParentId()
-        */
-       public function testGetParentId( $rowArray, $expected ) {
-               $rev = new Revision( $rowArray );
-               $this->assertSame( $expected, $rev->getParentId() );
-       }
-
-       /**
-        * @covers Revision::getRevisionText
-        * @dataProvider provideGetRevisionText
-        */
-       public function testGetRevisionText( $expected, $rowData, $prefix = 'old_', $wiki = false ) {
-               $this->assertEquals(
-                       $expected,
-                       Revision::getRevisionText( (object)$rowData, $prefix, $wiki ) );
-       }
-
-       public function provideGetRevisionTextWithZlibExtension() {
-               yield 'Generic gzip test' => [
-                       'This is a small goat of revision text.',
-                       [
-                               'old_flags' => 'gzip',
-                               'old_text' => gzdeflate( 'This is a small goat of revision text.' ),
-                       ],
-               ];
-       }
-
-       /**
-        * @covers Revision::getRevisionText
-        * @dataProvider provideGetRevisionTextWithZlibExtension
-        */
-       public function testGetRevisionWithZlibExtension( $expected, $rowData ) {
-               $this->checkPHPExtension( 'zlib' );
-               $this->testGetRevisionText( $expected, $rowData );
-       }
-
-       public function provideGetRevisionTextWithLegacyEncoding() {
-               yield 'Utf8Native' => [
-                       "Wiki est l'\xc3\xa9cole superieur !",
-                       'iso-8859-1',
-                       [
-                               'old_flags' => 'utf-8',
-                               'old_text' => "Wiki est l'\xc3\xa9cole superieur !",
-                       ]
-               ];
-               yield 'Utf8Legacy' => [
-                       "Wiki est l'\xc3\xa9cole superieur !",
-                       'iso-8859-1',
-                       [
-                               'old_flags' => '',
-                               'old_text' => "Wiki est l'\xe9cole superieur !",
-                       ]
-               ];
-       }
-
-       /**
-        * @covers Revision::getRevisionText
-        * @dataProvider provideGetRevisionTextWithLegacyEncoding
-        */
-       public function testGetRevisionWithLegacyEncoding( $expected, $encoding, $rowData ) {
-               $this->setMwGlobals( 'wgLegacyEncoding', $encoding );
-               $this->testGetRevisionText( $expected, $rowData );
-       }
-
-       public function provideGetRevisionTextWithGzipAndLegacyEncoding() {
-               /**
-                * WARNING!
-                * Do not set the external flag!
-                * Otherwise, getRevisionText will hit the live database (if ExternalStore is enabled)!
-                */
-               yield 'Utf8NativeGzip' => [
-                       "Wiki est l'\xc3\xa9cole superieur !",
-                       'iso-8859-1',
-                       [
-                               'old_flags' => 'gzip,utf-8',
-                               'old_text' => gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" ),
-                       ]
-               ];
-               yield 'Utf8LegacyGzip' => [
-                       "Wiki est l'\xc3\xa9cole superieur !",
-                       'iso-8859-1',
-                       [
-                               'old_flags' => 'gzip',
-                               'old_text' => gzdeflate( "Wiki est l'\xe9cole superieur !" ),
-                       ]
-               ];
-       }
-
-       /**
-        * @covers Revision::getRevisionText
-        * @dataProvider provideGetRevisionTextWithGzipAndLegacyEncoding
-        */
-       public function testGetRevisionWithGzipAndLegacyEncoding( $expected, $encoding, $rowData ) {
-               $this->checkPHPExtension( 'zlib' );
-               $this->setMwGlobals( 'wgLegacyEncoding', $encoding );
-               $this->testGetRevisionText( $expected, $rowData );
-       }
-
-       /**
-        * @covers Revision::compressRevisionText
-        */
-       public function testCompressRevisionTextUtf8() {
-               $row = new stdClass;
-               $row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
-               $row->old_flags = Revision::compressRevisionText( $row->old_text );
-               $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
-                       "Flags should contain 'utf-8'" );
-               $this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ),
-                       "Flags should not contain 'gzip'" );
-               $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
-                       $row->old_text, "Direct check" );
-               $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
-                       Revision::getRevisionText( $row ), "getRevisionText" );
-       }
-
-       /**
-        * @covers Revision::compressRevisionText
-        */
-       public function testCompressRevisionTextUtf8Gzip() {
-               $this->checkPHPExtension( 'zlib' );
-               $this->setMwGlobals( 'wgCompressRevisions', true );
-
-               $row = new stdClass;
-               $row->old_text = "Wiki est l'\xc3\xa9cole superieur !";
-               $row->old_flags = Revision::compressRevisionText( $row->old_text );
-               $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ),
-                       "Flags should contain 'utf-8'" );
-               $this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ),
-                       "Flags should contain 'gzip'" );
-               $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
-                       gzinflate( $row->old_text ), "Direct check" );
-               $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !",
-                       Revision::getRevisionText( $row ), "getRevisionText" );
-       }
-
-       public function provideFetchFromConds() {
-               yield [ 0, [] ];
-               yield [ Revision::READ_LOCKING, [ 'FOR UPDATE' ] ];
-       }
-
-       /**
-        * @dataProvider provideFetchFromConds
-        * @covers Revision::fetchFromConds
-        */
-       public function testFetchFromConds( $flags, array $options ) {
-               $conditions = [ 'conditionsArray' ];
-
-               $db = $this->getMock( IDatabase::class );
-               $db->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               $this->equalTo( [ 'revision', 'page', 'user' ] ),
-                               // We don't really care about the fields are they come from the selectField methods
-                               $this->isType( 'array' ),
-                               $this->equalTo( $conditions ),
-                               // Method name
-                               $this->equalTo( 'Revision::fetchFromConds' ),
-                               $this->equalTo( $options ),
-                               // We don't really care about the join conds are they come from the joinCond methods
-                               $this->isType( 'array' )
-                       )
-                       ->willReturn( 'RETURNVALUE' );
-
-               $wrapper = TestingAccessWrapper::newFromClass( Revision::class );
-               $result = $wrapper->fetchFromConds( $db, $conditions, $flags );
-
-               $this->assertEquals( 'RETURNVALUE', $result );
-       }
-}
diff --git a/tests/phpunit/includes/WatchedItemIntegrationTest.php b/tests/phpunit/includes/WatchedItemIntegrationTest.php
deleted file mode 100644 (file)
index 01e7ecb..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-<?php
-use MediaWiki\MediaWikiServices;
-
-/**
- * @author Addshore
- *
- * @group Database
- *
- * @covers WatchedItem
- */
-class WatchedItemIntegrationTest extends MediaWikiTestCase {
-
-       public function setUp() {
-               parent::setUp();
-               self::$users['WatchedItemIntegrationTestUser']
-                       = new TestUser( 'WatchedItemIntegrationTestUser' );
-
-               $this->hideDeprecated( 'WatchedItem::fromUserTitle' );
-               $this->hideDeprecated( 'WatchedItem::addWatch' );
-               $this->hideDeprecated( 'WatchedItem::removeWatch' );
-               $this->hideDeprecated( 'WatchedItem::isWatched' );
-               $this->hideDeprecated( 'WatchedItem::duplicateEntries' );
-               $this->hideDeprecated( 'WatchedItem::batchAddWatch' );
-       }
-
-       private function getUser() {
-               return self::$users['WatchedItemIntegrationTestUser']->getUser();
-       }
-
-       public function testWatchAndUnWatchItem() {
-               $user = $this->getUser();
-               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
-               // Cleanup after previous tests
-               WatchedItem::fromUserTitle( $user, $title )->removeWatch();
-
-               $this->assertFalse(
-                       WatchedItem::fromUserTitle( $user, $title )->isWatched(),
-                       'Page should not initially be watched'
-               );
-               WatchedItem::fromUserTitle( $user, $title )->addWatch();
-               $this->assertTrue(
-                       WatchedItem::fromUserTitle( $user, $title )->isWatched(),
-                       'Page should be watched'
-               );
-               WatchedItem::fromUserTitle( $user, $title )->removeWatch();
-               $this->assertFalse(
-                       WatchedItem::fromUserTitle( $user, $title )->isWatched(),
-                       'Page should be unwatched'
-               );
-       }
-
-       public function testUpdateAndResetNotificationTimestamp() {
-               $user = $this->getUser();
-               $otherUser = ( new TestUser( 'WatchedItemIntegrationTestUser_otherUser' ) )->getUser();
-               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
-               WatchedItem::fromUserTitle( $user, $title )->addWatch();
-               $this->assertNull( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
-
-               EmailNotification::updateWatchlistTimestamp( $otherUser, $title, '20150202010101' );
-               $this->assertEquals(
-                       '20150202010101',
-                       WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp()
-               );
-
-               MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp(
-                       $user, $title
-               );
-               $this->assertNull( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
-       }
-
-       public function testDuplicateAllAssociatedEntries() {
-               $user = $this->getUser();
-               $titleOld = Title::newFromText( 'WatchedItemIntegrationTestPageOld' );
-               $titleNew = Title::newFromText( 'WatchedItemIntegrationTestPageNew' );
-               WatchedItem::fromUserTitle( $user, $titleOld->getSubjectPage() )->addWatch();
-               WatchedItem::fromUserTitle( $user, $titleOld->getTalkPage() )->addWatch();
-               // Cleanup after previous tests
-               WatchedItem::fromUserTitle( $user, $titleNew->getSubjectPage() )->removeWatch();
-               WatchedItem::fromUserTitle( $user, $titleNew->getTalkPage() )->removeWatch();
-
-               WatchedItem::duplicateEntries( $titleOld, $titleNew );
-
-               $this->assertTrue(
-                       WatchedItem::fromUserTitle( $user, $titleOld->getSubjectPage() )->isWatched()
-               );
-               $this->assertTrue(
-                       WatchedItem::fromUserTitle( $user, $titleOld->getTalkPage() )->isWatched()
-               );
-               $this->assertTrue(
-                       WatchedItem::fromUserTitle( $user, $titleNew->getSubjectPage() )->isWatched()
-               );
-               $this->assertTrue(
-                       WatchedItem::fromUserTitle( $user, $titleNew->getTalkPage() )->isWatched()
-               );
-       }
-
-       public function testIsWatched_falseOnNotAllowed() {
-               $user = $this->getUser();
-               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
-               WatchedItem::fromUserTitle( $user, $title )->addWatch();
-
-               $this->assertTrue( WatchedItem::fromUserTitle( $user, $title )->isWatched() );
-               $user->mRights = [];
-               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->isWatched() );
-       }
-
-       public function testGetNotificationTimestamp_falseOnNotAllowed() {
-               $user = $this->getUser();
-               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
-               WatchedItem::fromUserTitle( $user, $title )->addWatch();
-               MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp(
-                       $user, $title
-               );
-
-               $this->assertEquals(
-                       null,
-                       WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp()
-               );
-               $user->mRights = [];
-               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
-       }
-
-       public function testRemoveWatch_falseOnNotAllowed() {
-               $user = $this->getUser();
-               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
-               WatchedItem::fromUserTitle( $user, $title )->addWatch();
-
-               $previousRights = $user->mRights;
-               $user->mRights = [];
-               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->removeWatch() );
-               $user->mRights = $previousRights;
-               $this->assertTrue( WatchedItem::fromUserTitle( $user, $title )->removeWatch() );
-       }
-
-       public function testGetNotificationTimestamp_falseOnNotWatched() {
-               $user = $this->getUser();
-               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
-
-               WatchedItem::fromUserTitle( $user, $title )->removeWatch();
-               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->isWatched() );
-
-               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
-       }
-
-}
diff --git a/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php b/tests/phpunit/includes/WatchedItemQueryServiceUnitTest.php
deleted file mode 100644 (file)
index 62ba5f6..0000000
+++ /dev/null
@@ -1,1676 +0,0 @@
-<?php
-
-use Wikimedia\ScopedCallback;
-use Wikimedia\TestingAccessWrapper;
-
-/**
- * @covers WatchedItemQueryService
- */
-class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
-
-       /**
-        * @return PHPUnit_Framework_MockObject_MockObject|Database
-        */
-       private function getMockDb() {
-               $mock = $this->getMockBuilder( Database::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-
-               $mock->expects( $this->any() )
-                       ->method( 'makeList' )
-                       ->with(
-                               $this->isType( 'array' ),
-                               $this->isType( 'int' )
-                       )
-                       ->will( $this->returnCallback( function ( $a, $conj ) {
-                               $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
-                               return join( $sqlConj, array_map( function ( $s ) {
-                                       return '(' . $s . ')';
-                               }, $a
-                               ) );
-                       } ) );
-
-               $mock->expects( $this->any() )
-                       ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return "'$value'";
-                       } ) );
-
-               $mock->expects( $this->any() )
-                       ->method( 'timestamp' )
-                       ->will( $this->returnArgument( 0 ) );
-
-               $mock->expects( $this->any() )
-                       ->method( 'bitAnd' )
-                       ->willReturnCallback( function ( $a, $b ) {
-                               return "($a & $b)";
-                       } );
-
-               return $mock;
-       }
-
-       /**
-        * @param PHPUnit_Framework_MockObject_MockObject|Database $mockDb
-        * @return PHPUnit_Framework_MockObject_MockObject|LoadBalancer
-        */
-       private function getMockLoadBalancer( $mockDb ) {
-               $mock = $this->getMockBuilder( LoadBalancer::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $mock->expects( $this->any() )
-                       ->method( 'getConnectionRef' )
-                       ->with( DB_REPLICA )
-                       ->will( $this->returnValue( $mockDb ) );
-               return $mock;
-       }
-
-       /**
-        * @param int $id
-        * @return PHPUnit_Framework_MockObject_MockObject|User
-        */
-       private function getMockNonAnonUserWithId( $id ) {
-               $mock = $this->getMockBuilder( User::class )->getMock();
-               $mock->expects( $this->any() )
-                       ->method( 'isAnon' )
-                       ->will( $this->returnValue( false ) );
-               $mock->expects( $this->any() )
-                       ->method( 'getId' )
-                       ->will( $this->returnValue( $id ) );
-               return $mock;
-       }
-
-       /**
-        * @param int $id
-        * @return PHPUnit_Framework_MockObject_MockObject|User
-        */
-       private function getMockUnrestrictedNonAnonUserWithId( $id ) {
-               $mock = $this->getMockNonAnonUserWithId( $id );
-               $mock->expects( $this->any() )
-                       ->method( 'isAllowed' )
-                       ->will( $this->returnValue( true ) );
-               $mock->expects( $this->any() )
-                       ->method( 'isAllowedAny' )
-                       ->will( $this->returnValue( true ) );
-               $mock->expects( $this->any() )
-                       ->method( 'useRCPatrol' )
-                       ->will( $this->returnValue( true ) );
-               return $mock;
-       }
-
-       /**
-        * @param int $id
-        * @param string $notAllowedAction
-        * @return PHPUnit_Framework_MockObject_MockObject|User
-        */
-       private function getMockNonAnonUserWithIdAndRestrictedPermissions( $id, $notAllowedAction ) {
-               $mock = $this->getMockNonAnonUserWithId( $id );
-
-               $mock->expects( $this->any() )
-                       ->method( 'isAllowed' )
-                       ->will( $this->returnCallback( function ( $action ) use ( $notAllowedAction ) {
-                               return $action !== $notAllowedAction;
-                       } ) );
-               $mock->expects( $this->any() )
-                       ->method( 'isAllowedAny' )
-                       ->will( $this->returnCallback( function () use ( $notAllowedAction ) {
-                               $actions = func_get_args();
-                               return !in_array( $notAllowedAction, $actions );
-                       } ) );
-
-               return $mock;
-       }
-
-       /**
-        * @param int $id
-        * @return PHPUnit_Framework_MockObject_MockObject|User
-        */
-       private function getMockNonAnonUserWithIdAndNoPatrolRights( $id ) {
-               $mock = $this->getMockNonAnonUserWithId( $id );
-
-               $mock->expects( $this->any() )
-                       ->method( 'isAllowed' )
-                       ->will( $this->returnValue( true ) );
-               $mock->expects( $this->any() )
-                       ->method( 'isAllowedAny' )
-                       ->will( $this->returnValue( true ) );
-
-               $mock->expects( $this->any() )
-                       ->method( 'useRCPatrol' )
-                       ->will( $this->returnValue( false ) );
-               $mock->expects( $this->any() )
-                       ->method( 'useNPPatrol' )
-                       ->will( $this->returnValue( false ) );
-
-               return $mock;
-       }
-
-       private function getMockAnonUser() {
-               $mock = $this->getMockBuilder( User::class )->getMock();
-               $mock->expects( $this->any() )
-                       ->method( 'isAnon' )
-                       ->will( $this->returnValue( true ) );
-               return $mock;
-       }
-
-       private function getFakeRow( array $rowValues ) {
-               $fakeRow = new stdClass();
-               foreach ( $rowValues as $valueName => $value ) {
-                       $fakeRow->$valueName = $value;
-               }
-               return $fakeRow;
-       }
-
-       public function testGetWatchedItemsWithRecentChangeInfo() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               [ 'recentchanges', 'watchlist', 'page' ],
-                               [
-                                       'rc_id',
-                                       'rc_namespace',
-                                       'rc_title',
-                                       'rc_timestamp',
-                                       'rc_type',
-                                       'rc_deleted',
-                                       'wl_notificationtimestamp',
-                                       'rc_cur_id',
-                                       'rc_this_oldid',
-                                       'rc_last_oldid',
-                               ],
-                               [
-                                       'wl_user' => 1,
-                                       '(rc_this_oldid=page_latest) OR (rc_type=3)',
-                               ],
-                               $this->isType( 'string' ),
-                               [
-                                       'LIMIT' => 3,
-                               ],
-                               [
-                                       'watchlist' => [
-                                               'INNER JOIN',
-                                               [
-                                                       'wl_namespace=rc_namespace',
-                                                       'wl_title=rc_title'
-                                               ]
-                                       ],
-                                       'page' => [
-                                               'LEFT JOIN',
-                                               'rc_cur_id=page_id',
-                                       ],
-                               ]
-                       )
-                       ->will( $this->returnValue( [
-                               $this->getFakeRow( [
-                                       'rc_id' => 1,
-                                       'rc_namespace' => 0,
-                                       'rc_title' => 'Foo1',
-                                       'rc_timestamp' => '20151212010101',
-                                       'rc_type' => RC_NEW,
-                                       'rc_deleted' => 0,
-                                       'wl_notificationtimestamp' => '20151212010101',
-                               ] ),
-                               $this->getFakeRow( [
-                                       'rc_id' => 2,
-                                       'rc_namespace' => 1,
-                                       'rc_title' => 'Foo2',
-                                       'rc_timestamp' => '20151212010102',
-                                       'rc_type' => RC_NEW,
-                                       'rc_deleted' => 0,
-                                       'wl_notificationtimestamp' => null,
-                               ] ),
-                               $this->getFakeRow( [
-                                       'rc_id' => 3,
-                                       'rc_namespace' => 1,
-                                       'rc_title' => 'Foo3',
-                                       'rc_timestamp' => '20151212010103',
-                                       'rc_type' => RC_NEW,
-                                       'rc_deleted' => 0,
-                                       'wl_notificationtimestamp' => null,
-                               ] ),
-                       ] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-
-               $startFrom = null;
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
-                       $user, [ 'limit' => 2 ], $startFrom
-               );
-
-               $this->assertInternalType( 'array', $items );
-               $this->assertCount( 2, $items );
-
-               foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) {
-                       $this->assertInstanceOf( WatchedItem::class, $watchedItem );
-                       $this->assertInternalType( 'array', $recentChangeInfo );
-               }
-
-               $this->assertEquals(
-                       new WatchedItem( $user, new TitleValue( 0, 'Foo1' ), '20151212010101' ),
-                       $items[0][0]
-               );
-               $this->assertEquals(
-                       [
-                               'rc_id' => 1,
-                               'rc_namespace' => 0,
-                               'rc_title' => 'Foo1',
-                               'rc_timestamp' => '20151212010101',
-                               'rc_type' => RC_NEW,
-                               'rc_deleted' => 0,
-                       ],
-                       $items[0][1]
-               );
-
-               $this->assertEquals(
-                       new WatchedItem( $user, new TitleValue( 1, 'Foo2' ), null ),
-                       $items[1][0]
-               );
-               $this->assertEquals(
-                       [
-                               'rc_id' => 2,
-                               'rc_namespace' => 1,
-                               'rc_title' => 'Foo2',
-                               'rc_timestamp' => '20151212010102',
-                               'rc_type' => RC_NEW,
-                               'rc_deleted' => 0,
-                       ],
-                       $items[1][1]
-               );
-
-               $this->assertEquals( [ '20151212010103', 3 ], $startFrom );
-       }
-
-       public function testGetWatchedItemsWithRecentChangeInfo_extension() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               [ 'recentchanges', 'watchlist', 'page', 'extension_dummy_table' ],
-                               [
-                                       'rc_id',
-                                       'rc_namespace',
-                                       'rc_title',
-                                       'rc_timestamp',
-                                       'rc_type',
-                                       'rc_deleted',
-                                       'wl_notificationtimestamp',
-                                       'rc_cur_id',
-                                       'rc_this_oldid',
-                                       'rc_last_oldid',
-                                       'extension_dummy_field',
-                               ],
-                               [
-                                       'wl_user' => 1,
-                                       '(rc_this_oldid=page_latest) OR (rc_type=3)',
-                                       'extension_dummy_cond',
-                               ],
-                               $this->isType( 'string' ),
-                               [
-                                       'extension_dummy_option',
-                               ],
-                               [
-                                       'watchlist' => [
-                                               'INNER JOIN',
-                                               [
-                                                       'wl_namespace=rc_namespace',
-                                                       'wl_title=rc_title'
-                                               ]
-                                       ],
-                                       'page' => [
-                                               'LEFT JOIN',
-                                               'rc_cur_id=page_id',
-                                       ],
-                                       'extension_dummy_join_cond' => [],
-                               ]
-                       )
-                       ->will( $this->returnValue( [
-                               $this->getFakeRow( [
-                                       'rc_id' => 1,
-                                       'rc_namespace' => 0,
-                                       'rc_title' => 'Foo1',
-                                       'rc_timestamp' => '20151212010101',
-                                       'rc_type' => RC_NEW,
-                                       'rc_deleted' => 0,
-                                       'wl_notificationtimestamp' => '20151212010101',
-                               ] ),
-                               $this->getFakeRow( [
-                                       'rc_id' => 2,
-                                       'rc_namespace' => 1,
-                                       'rc_title' => 'Foo2',
-                                       'rc_timestamp' => '20151212010102',
-                                       'rc_type' => RC_NEW,
-                                       'rc_deleted' => 0,
-                                       'wl_notificationtimestamp' => null,
-                               ] ),
-                       ] ) );
-
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-
-               $mockExtension = $this->getMockBuilder( WatchedItemQueryServiceExtension::class )
-                       ->getMock();
-               $mockExtension->expects( $this->once() )
-                       ->method( 'modifyWatchedItemsWithRCInfoQuery' )
-                       ->with(
-                               $this->identicalTo( $user ),
-                               $this->isType( 'array' ),
-                               $this->isInstanceOf( IDatabase::class ),
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' )
-                       )
-                       ->will( $this->returnCallback( function (
-                               $user, $options, $db, &$tables, &$fields, &$conds, &$dbOptions, &$joinConds
-                       ) {
-                               $tables[] = 'extension_dummy_table';
-                               $fields[] = 'extension_dummy_field';
-                               $conds[] = 'extension_dummy_cond';
-                               $dbOptions[] = 'extension_dummy_option';
-                               $joinConds['extension_dummy_join_cond'] = [];
-                       } ) );
-               $mockExtension->expects( $this->once() )
-                       ->method( 'modifyWatchedItemsWithRCInfo' )
-                       ->with(
-                               $this->identicalTo( $user ),
-                               $this->isType( 'array' ),
-                               $this->isInstanceOf( IDatabase::class ),
-                               $this->isType( 'array' ),
-                               $this->anything(),
-                               $this->anything() // Can't test for null here, PHPUnit applies this after the callback
-                       )
-                       ->will( $this->returnCallback( function ( $user, $options, $db, &$items, $res, &$startFrom ) {
-                               foreach ( $items as $i => &$item ) {
-                                       $item[1]['extension_dummy_field'] = $i;
-                               }
-                               unset( $item );
-
-                               $this->assertNull( $startFrom );
-                               $startFrom = [ '20160203123456', 42 ];
-                       } ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               TestingAccessWrapper::newFromObject( $queryService )->extensions = [ $mockExtension ];
-
-               $startFrom = null;
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
-                       $user, [], $startFrom
-               );
-
-               $this->assertInternalType( 'array', $items );
-               $this->assertCount( 2, $items );
-
-               foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) {
-                       $this->assertInstanceOf( WatchedItem::class, $watchedItem );
-                       $this->assertInternalType( 'array', $recentChangeInfo );
-               }
-
-               $this->assertEquals(
-                       new WatchedItem( $user, new TitleValue( 0, 'Foo1' ), '20151212010101' ),
-                       $items[0][0]
-               );
-               $this->assertEquals(
-                       [
-                               'rc_id' => 1,
-                               'rc_namespace' => 0,
-                               'rc_title' => 'Foo1',
-                               'rc_timestamp' => '20151212010101',
-                               'rc_type' => RC_NEW,
-                               'rc_deleted' => 0,
-                               'extension_dummy_field' => 0,
-                       ],
-                       $items[0][1]
-               );
-
-               $this->assertEquals(
-                       new WatchedItem( $user, new TitleValue( 1, 'Foo2' ), null ),
-                       $items[1][0]
-               );
-               $this->assertEquals(
-                       [
-                               'rc_id' => 2,
-                               'rc_namespace' => 1,
-                               'rc_title' => 'Foo2',
-                               'rc_timestamp' => '20151212010102',
-                               'rc_type' => RC_NEW,
-                               'rc_deleted' => 0,
-                               'extension_dummy_field' => 1,
-                       ],
-                       $items[1][1]
-               );
-
-               $this->assertEquals( [ '20160203123456', 42 ], $startFrom );
-       }
-
-       public function getWatchedItemsWithRecentChangeInfoOptionsProvider() {
-               return [
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_FLAGS ] ],
-                               null,
-                               [],
-                               [ 'rc_type', 'rc_minor', 'rc_bot' ],
-                               [],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_USER ] ],
-                               null,
-                               [],
-                               [ 'rc_user_text' ],
-                               [],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_USER_ID ] ],
-                               null,
-                               [],
-                               [ 'rc_user' ],
-                               [],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_COMMENT ] ],
-                               null,
-                               [],
-                               [
-                                       'rc_comment_text' => 'rc_comment',
-                                       'rc_comment_data' => 'NULL',
-                                       'rc_comment_cid' => 'NULL',
-                               ],
-                               [],
-                               [],
-                               [],
-                               [ 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD ],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_COMMENT ] ],
-                               null,
-                               [ 'comment_rc_comment' => 'comment' ],
-                               [
-                                       'rc_comment_text' => 'COALESCE( comment_rc_comment.comment_text, rc_comment )',
-                                       'rc_comment_data' => 'comment_rc_comment.comment_data',
-                                       'rc_comment_cid' => 'comment_rc_comment.comment_id',
-                               ],
-                               [],
-                               [],
-                               [ 'comment_rc_comment' => [ 'LEFT JOIN', 'comment_rc_comment.comment_id = rc_comment_id' ] ],
-                               [ 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH ],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_COMMENT ] ],
-                               null,
-                               [ 'comment_rc_comment' => 'comment' ],
-                               [
-                                       'rc_comment_text' => 'COALESCE( comment_rc_comment.comment_text, rc_comment )',
-                                       'rc_comment_data' => 'comment_rc_comment.comment_data',
-                                       'rc_comment_cid' => 'comment_rc_comment.comment_id',
-                               ],
-                               [],
-                               [],
-                               [ 'comment_rc_comment' => [ 'LEFT JOIN', 'comment_rc_comment.comment_id = rc_comment_id' ] ],
-                               [ 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW ],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_COMMENT ] ],
-                               null,
-                               [ 'comment_rc_comment' => 'comment' ],
-                               [
-                                       'rc_comment_text' => 'comment_rc_comment.comment_text',
-                                       'rc_comment_data' => 'comment_rc_comment.comment_data',
-                                       'rc_comment_cid' => 'comment_rc_comment.comment_id',
-                               ],
-                               [],
-                               [],
-                               [ 'comment_rc_comment' => [ 'JOIN', 'comment_rc_comment.comment_id = rc_comment_id' ] ],
-                               [ 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW ],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_PATROL_INFO ] ],
-                               null,
-                               [],
-                               [ 'rc_patrolled', 'rc_log_type' ],
-                               [],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_SIZES ] ],
-                               null,
-                               [],
-                               [ 'rc_old_len', 'rc_new_len' ],
-                               [],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_LOG_INFO ] ],
-                               null,
-                               [],
-                               [ 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ],
-                               [],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'namespaceIds' => [ 0, 1 ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'wl_namespace' => [ 0, 1 ] ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'namespaceIds' => [ 0, "1; DROP TABLE watchlist;\n--" ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'wl_namespace' => [ 0, 1 ] ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'rcTypes' => [ RC_EDIT, RC_NEW ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_type' => [ RC_EDIT, RC_NEW ] ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
-                               null,
-                               [],
-                               [],
-                               [],
-                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_NEWER ],
-                               null,
-                               [],
-                               [],
-                               [],
-                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_OLDER, 'start' => '20151212010101' ],
-                               null,
-                               [],
-                               [],
-                               [ "rc_timestamp <= '20151212010101'" ],
-                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_OLDER, 'end' => '20151212010101' ],
-                               null,
-                               [],
-                               [],
-                               [ "rc_timestamp >= '20151212010101'" ],
-                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
-                               [],
-                       ],
-                       [
-                               [
-                                       'dir' => WatchedItemQueryService::DIR_OLDER,
-                                       'start' => '20151212020101',
-                                       'end' => '20151212010101'
-                               ],
-                               null,
-                               [],
-                               [],
-                               [ "rc_timestamp <= '20151212020101'", "rc_timestamp >= '20151212010101'" ],
-                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_NEWER, 'start' => '20151212010101' ],
-                               null,
-                               [],
-                               [],
-                               [ "rc_timestamp >= '20151212010101'" ],
-                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_NEWER, 'end' => '20151212010101' ],
-                               null,
-                               [],
-                               [],
-                               [ "rc_timestamp <= '20151212010101'" ],
-                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
-                               [],
-                       ],
-                       [
-                               [
-                                       'dir' => WatchedItemQueryService::DIR_NEWER,
-                                       'start' => '20151212010101',
-                                       'end' => '20151212020101'
-                               ],
-                               null,
-                               [],
-                               [],
-                               [ "rc_timestamp >= '20151212010101'", "rc_timestamp <= '20151212020101'" ],
-                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
-                               [],
-                       ],
-                       [
-                               [ 'limit' => 10 ],
-                               null,
-                               [],
-                               [],
-                               [],
-                               [ 'LIMIT' => 11 ],
-                               [],
-                       ],
-                       [
-                               [ 'limit' => "10; DROP TABLE watchlist;\n--" ],
-                               null,
-                               [],
-                               [],
-                               [],
-                               [ 'LIMIT' => 11 ],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_MINOR ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_minor != 0' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_MINOR ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_minor = 0' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_BOT ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_bot != 0' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_BOT ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_bot = 0' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_ANON ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_user = 0' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_ANON ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_user != 0' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_PATROLLED ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_patrolled != 0' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_PATROLLED ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_patrolled = 0' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_UNREAD ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_timestamp >= wl_notificationtimestamp' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_UNREAD ] ],
-                               null,
-                               [],
-                               [],
-                               [ 'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'onlyByUser' => 'SomeOtherUser' ],
-                               null,
-                               [],
-                               [],
-                               [ 'rc_user_text' => 'SomeOtherUser' ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'notByUser' => 'SomeOtherUser' ],
-                               null,
-                               [],
-                               [],
-                               [ "rc_user_text != 'SomeOtherUser'" ],
-                               [],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
-                               [ '20151212010101', 123 ],
-                               [],
-                               [],
-                               [
-                                       "(rc_timestamp < '20151212010101') OR ((rc_timestamp = '20151212010101') AND (rc_id <= 123))"
-                               ],
-                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_NEWER ],
-                               [ '20151212010101', 123 ],
-                               [],
-                               [],
-                               [
-                                       "(rc_timestamp > '20151212010101') OR ((rc_timestamp = '20151212010101') AND (rc_id >= 123))"
-                               ],
-                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
-                               [],
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
-                               [ '20151212010101', "123; DROP TABLE watchlist;\n--" ],
-                               [],
-                               [],
-                               [
-                                       "(rc_timestamp < '20151212010101') OR ((rc_timestamp = '20151212010101') AND (rc_id <= 123))"
-                               ],
-                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
-                               [],
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider getWatchedItemsWithRecentChangeInfoOptionsProvider
-        */
-       public function testGetWatchedItemsWithRecentChangeInfo_optionsAndEmptyResult(
-               array $options,
-               $startFrom,
-               array $expectedExtraTables,
-               array $expectedExtraFields,
-               array $expectedExtraConds,
-               array $expectedDbOptions,
-               array $expectedExtraJoinConds,
-               array $globals = []
-       ) {
-               // Sigh. This test class doesn't extend MediaWikiTestCase, so we have to reinvent setMwGlobals().
-               if ( $globals ) {
-                       $resetGlobals = [];
-                       foreach ( $globals as $k => $v ) {
-                               $resetGlobals[$k] = $GLOBALS[$k];
-                               $GLOBALS[$k] = $v;
-                       }
-                       $reset = new ScopedCallback( function () use ( $resetGlobals ) {
-                               foreach ( $resetGlobals as $k => $v ) {
-                                       $GLOBALS[$k] = $v;
-                               }
-                       } );
-               }
-
-               $expectedTables = array_merge( [ 'recentchanges', 'watchlist', 'page' ], $expectedExtraTables );
-               $expectedFields = array_merge(
-                       [
-                               'rc_id',
-                               'rc_namespace',
-                               'rc_title',
-                               'rc_timestamp',
-                               'rc_type',
-                               'rc_deleted',
-                               'wl_notificationtimestamp',
-
-                               'rc_cur_id',
-                               'rc_this_oldid',
-                               'rc_last_oldid',
-                       ],
-                       $expectedExtraFields
-               );
-               $expectedConds = array_merge(
-                       [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)', ],
-                       $expectedExtraConds
-               );
-               $expectedJoinConds = array_merge(
-                       [
-                               'watchlist' => [
-                                       'INNER JOIN',
-                                       [
-                                               'wl_namespace=rc_namespace',
-                                               'wl_title=rc_title'
-                                       ]
-                               ],
-                               'page' => [
-                                       'LEFT JOIN',
-                                       'rc_cur_id=page_id',
-                               ],
-                       ],
-                       $expectedExtraJoinConds
-               );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               $expectedTables,
-                               $expectedFields,
-                               $expectedConds,
-                               $this->isType( 'string' ),
-                               $expectedDbOptions,
-                               $expectedJoinConds
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo( $user, $options, $startFrom );
-
-               $this->assertEmpty( $items );
-               $this->assertNull( $startFrom );
-       }
-
-       public function filterPatrolledOptionProvider() {
-               return [
-                       [ WatchedItemQueryService::FILTER_PATROLLED ],
-                       [ WatchedItemQueryService::FILTER_NOT_PATROLLED ],
-               ];
-       }
-
-       /**
-        * @dataProvider filterPatrolledOptionProvider
-        */
-       public function testGetWatchedItemsWithRecentChangeInfo_filterPatrolledAndUserWithNoPatrolRights(
-               $filtersOption
-       ) {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               [ 'recentchanges', 'watchlist', 'page' ],
-                               $this->isType( 'array' ),
-                               [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)' ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' )
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $user = $this->getMockNonAnonUserWithIdAndNoPatrolRights( 1 );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
-                       $user,
-                       [ 'filters' => [ $filtersOption ] ]
-               );
-
-               $this->assertEmpty( $items );
-       }
-
-       public function mysqlIndexOptimizationProvider() {
-               return [
-                       [
-                               'mysql',
-                               [],
-                               [ "rc_timestamp > ''" ],
-                       ],
-                       [
-                               'mysql',
-                               [ 'start' => '20151212010101', 'dir' => WatchedItemQueryService::DIR_OLDER ],
-                               [ "rc_timestamp <= '20151212010101'" ],
-                       ],
-                       [
-                               'mysql',
-                               [ 'end' => '20151212010101', 'dir' => WatchedItemQueryService::DIR_OLDER ],
-                               [ "rc_timestamp >= '20151212010101'" ],
-                       ],
-                       [
-                               'postgres',
-                               [],
-                               [],
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider mysqlIndexOptimizationProvider
-        */
-       public function testGetWatchedItemsWithRecentChangeInfo_mysqlIndexOptimization(
-               $dbType,
-               array $options,
-               array $expectedExtraConds
-       ) {
-               $commonConds = [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)' ];
-               $conds = array_merge( $commonConds, $expectedExtraConds );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               [ 'recentchanges', 'watchlist', 'page' ],
-                               $this->isType( 'array' ),
-                               $conds,
-                               $this->isType( 'string' ),
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' )
-                       )
-                       ->will( $this->returnValue( [] ) );
-               $mockDb->expects( $this->any() )
-                       ->method( 'getType' )
-                       ->will( $this->returnValue( $dbType ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo( $user, $options );
-
-               $this->assertEmpty( $items );
-       }
-
-       public function userPermissionRelatedExtraChecksProvider() {
-               return [
-                       [
-                               [],
-                               'deletedhistory',
-                               [
-                                       '(rc_type != ' . RC_LOG . ') OR ((rc_deleted & ' . LogPage::DELETED_ACTION . ') != ' .
-                                               LogPage::DELETED_ACTION . ')'
-                               ],
-                       ],
-                       [
-                               [],
-                               'suppressrevision',
-                               [
-                                       '(rc_type != ' . RC_LOG . ') OR (' .
-                                               '(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
-                                               ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
-                               ],
-                       ],
-                       [
-                               [],
-                               'viewsuppressed',
-                               [
-                                       '(rc_type != ' . RC_LOG . ') OR (' .
-                                               '(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
-                                               ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
-                               ],
-                       ],
-                       [
-                               [ 'onlyByUser' => 'SomeOtherUser' ],
-                               'deletedhistory',
-                               [
-                                       'rc_user_text' => 'SomeOtherUser',
-                                       '(rc_deleted & ' . Revision::DELETED_USER . ') != ' . Revision::DELETED_USER,
-                                       '(rc_type != ' . RC_LOG . ') OR ((rc_deleted & ' . LogPage::DELETED_ACTION . ') != ' .
-                                               LogPage::DELETED_ACTION . ')'
-                               ],
-                       ],
-                       [
-                               [ 'onlyByUser' => 'SomeOtherUser' ],
-                               'suppressrevision',
-                               [
-                                       'rc_user_text' => 'SomeOtherUser',
-                                       '(rc_deleted & ' . ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ) . ') != ' .
-                                               ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ),
-                                       '(rc_type != ' . RC_LOG . ') OR (' .
-                                               '(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
-                                               ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
-                               ],
-                       ],
-                       [
-                               [ 'onlyByUser' => 'SomeOtherUser' ],
-                               'viewsuppressed',
-                               [
-                                       'rc_user_text' => 'SomeOtherUser',
-                                       '(rc_deleted & ' . ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ) . ') != ' .
-                                               ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ),
-                                       '(rc_type != ' . RC_LOG . ') OR (' .
-                                               '(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
-                                               ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
-                               ],
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider userPermissionRelatedExtraChecksProvider
-        */
-       public function testGetWatchedItemsWithRecentChangeInfo_userPermissionRelatedExtraChecks(
-               array $options,
-               $notAllowedAction,
-               array $expectedExtraConds
-       ) {
-               $commonConds = [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)' ];
-               $conds = array_merge( $commonConds, $expectedExtraConds );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               [ 'recentchanges', 'watchlist', 'page' ],
-                               $this->isType( 'array' ),
-                               $conds,
-                               $this->isType( 'string' ),
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' )
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $user = $this->getMockNonAnonUserWithIdAndRestrictedPermissions( 1, $notAllowedAction );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo( $user, $options );
-
-               $this->assertEmpty( $items );
-       }
-
-       public function testGetWatchedItemsWithRecentChangeInfo_allRevisionsOptionAndEmptyResult() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               [ 'recentchanges', 'watchlist' ],
-                               [
-                                       'rc_id',
-                                       'rc_namespace',
-                                       'rc_title',
-                                       'rc_timestamp',
-                                       'rc_type',
-                                       'rc_deleted',
-                                       'wl_notificationtimestamp',
-
-                                       'rc_cur_id',
-                                       'rc_this_oldid',
-                                       'rc_last_oldid',
-                               ],
-                               [ 'wl_user' => 1, ],
-                               $this->isType( 'string' ),
-                               [],
-                               [
-                                       'watchlist' => [
-                                               'INNER JOIN',
-                                               [
-                                                       'wl_namespace=rc_namespace',
-                                                       'wl_title=rc_title'
-                                               ]
-                                       ],
-                               ]
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo( $user, [ 'allRevisions' => true ] );
-
-               $this->assertEmpty( $items );
-       }
-
-       public function getWatchedItemsWithRecentChangeInfoInvalidOptionsProvider() {
-               return [
-                       [
-                               [ 'rcTypes' => [ 1337 ] ],
-                               null,
-                               'Bad value for parameter $options[\'rcTypes\']',
-                       ],
-                       [
-                               [ 'rcTypes' => [ 'edit' ] ],
-                               null,
-                               'Bad value for parameter $options[\'rcTypes\']',
-                       ],
-                       [
-                               [ 'rcTypes' => [ RC_EDIT, 1337 ] ],
-                               null,
-                               'Bad value for parameter $options[\'rcTypes\']',
-                       ],
-                       [
-                               [ 'dir' => 'foo' ],
-                               null,
-                               'Bad value for parameter $options[\'dir\']',
-                       ],
-                       [
-                               [ 'start' => '20151212010101' ],
-                               null,
-                               'Bad value for parameter $options[\'dir\']: must be provided',
-                       ],
-                       [
-                               [ 'end' => '20151212010101' ],
-                               null,
-                               'Bad value for parameter $options[\'dir\']: must be provided',
-                       ],
-                       [
-                               [],
-                               [ '20151212010101', 123 ],
-                               'Bad value for parameter $options[\'dir\']: must be provided',
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
-                               '20151212010101',
-                               'Bad value for parameter $startFrom: must be a two-element array',
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
-                               [ '20151212010101' ],
-                               'Bad value for parameter $startFrom: must be a two-element array',
-                       ],
-                       [
-                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
-                               [ '20151212010101', 123, 'foo' ],
-                               'Bad value for parameter $startFrom: must be a two-element array',
-                       ],
-                       [
-                               [ 'watchlistOwner' => $this->getMockUnrestrictedNonAnonUserWithId( 2 ) ],
-                               null,
-                               'Bad value for parameter $options[\'watchlistOwnerToken\']',
-                       ],
-                       [
-                               [ 'watchlistOwner' => 'Other User', 'watchlistOwnerToken' => 'some-token' ],
-                               null,
-                               'Bad value for parameter $options[\'watchlistOwner\']',
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider getWatchedItemsWithRecentChangeInfoInvalidOptionsProvider
-        */
-       public function testGetWatchedItemsWithRecentChangeInfo_invalidOptions(
-               array $options,
-               $startFrom,
-               $expectedInExceptionMessage
-       ) {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( $this->anything() );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-
-               $this->setExpectedException( InvalidArgumentException::class, $expectedInExceptionMessage );
-               $queryService->getWatchedItemsWithRecentChangeInfo( $user, $options, $startFrom );
-       }
-
-       public function testGetWatchedItemsWithRecentChangeInfo_usedInGeneratorOptionAndEmptyResult() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               [ 'recentchanges', 'watchlist', 'page' ],
-                               [
-                                       'rc_id',
-                                       'rc_namespace',
-                                       'rc_title',
-                                       'rc_timestamp',
-                                       'rc_type',
-                                       'rc_deleted',
-                                       'wl_notificationtimestamp',
-                                       'rc_cur_id',
-                               ],
-                               [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)' ],
-                               $this->isType( 'string' ),
-                               [],
-                               [
-                                       'watchlist' => [
-                                               'INNER JOIN',
-                                               [
-                                                       'wl_namespace=rc_namespace',
-                                                       'wl_title=rc_title'
-                                               ]
-                                       ],
-                                       'page' => [
-                                               'LEFT JOIN',
-                                               'rc_cur_id=page_id',
-                                       ],
-                               ]
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
-                       $user,
-                       [ 'usedInGenerator' => true ]
-               );
-
-               $this->assertEmpty( $items );
-       }
-
-       public function testGetWatchedItemsWithRecentChangeInfo_usedInGeneratorAllRevisionsOptions() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               [ 'recentchanges', 'watchlist' ],
-                               [
-                                       'rc_id',
-                                       'rc_namespace',
-                                       'rc_title',
-                                       'rc_timestamp',
-                                       'rc_type',
-                                       'rc_deleted',
-                                       'wl_notificationtimestamp',
-                                       'rc_this_oldid',
-                               ],
-                               [ 'wl_user' => 1 ],
-                               $this->isType( 'string' ),
-                               [],
-                               [
-                                       'watchlist' => [
-                                               'INNER JOIN',
-                                               [
-                                                       'wl_namespace=rc_namespace',
-                                                       'wl_title=rc_title'
-                                               ]
-                                       ],
-                               ]
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
-                       $user,
-                       [ 'usedInGenerator' => true, 'allRevisions' => true, ]
-               );
-
-               $this->assertEmpty( $items );
-       }
-
-       public function testGetWatchedItemsWithRecentChangeInfo_watchlistOwnerOptionAndEmptyResult() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' ),
-                               [
-                                       'wl_user' => 2,
-                                       '(rc_this_oldid=page_latest) OR (rc_type=3)',
-                               ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'array' ),
-                               $this->isType( 'array' )
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-               $otherUser = $this->getMockUnrestrictedNonAnonUserWithId( 2 );
-               $otherUser->expects( $this->once() )
-                       ->method( 'getOption' )
-                       ->with( 'watchlisttoken' )
-                       ->willReturn( '0123456789abcdef' );
-
-               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
-                       $user,
-                       [ 'watchlistOwner' => $otherUser, 'watchlistOwnerToken' => '0123456789abcdef' ]
-               );
-
-               $this->assertEmpty( $items );
-       }
-
-       public function invalidWatchlistTokenProvider() {
-               return [
-                       [ 'wrongToken' ],
-                       [ '' ],
-               ];
-       }
-
-       /**
-        * @dataProvider invalidWatchlistTokenProvider
-        */
-       public function testGetWatchedItemsWithRecentChangeInfo_watchlistOwnerAndInvalidToken( $token ) {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( $this->anything() );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
-               $otherUser = $this->getMockUnrestrictedNonAnonUserWithId( 2 );
-               $otherUser->expects( $this->once() )
-                       ->method( 'getOption' )
-                       ->with( 'watchlisttoken' )
-                       ->willReturn( '0123456789abcdef' );
-
-               $this->setExpectedException( ApiUsageException::class, 'Incorrect watchlist token provided' );
-               $queryService->getWatchedItemsWithRecentChangeInfo(
-                       $user,
-                       [ 'watchlistOwner' => $otherUser, 'watchlistOwnerToken' => $token ]
-               );
-       }
-
-       public function testGetWatchedItemsForUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               [ 'wl_user' => 1 ]
-                       )
-                       ->will( $this->returnValue( [
-                               $this->getFakeRow( [
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'Foo1',
-                                       'wl_notificationtimestamp' => '20151212010101',
-                               ] ),
-                               $this->getFakeRow( [
-                                       'wl_namespace' => 1,
-                                       'wl_title' => 'Foo2',
-                                       'wl_notificationtimestamp' => null,
-                               ] ),
-                       ] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $items = $queryService->getWatchedItemsForUser( $user );
-
-               $this->assertInternalType( 'array', $items );
-               $this->assertCount( 2, $items );
-               $this->assertContainsOnlyInstancesOf( WatchedItem::class, $items );
-               $this->assertEquals(
-                       new WatchedItem( $user, new TitleValue( 0, 'Foo1' ), '20151212010101' ),
-                       $items[0]
-               );
-               $this->assertEquals(
-                       new WatchedItem( $user, new TitleValue( 1, 'Foo2' ), null ),
-                       $items[1]
-               );
-       }
-
-       public function provideGetWatchedItemsForUserOptions() {
-               return [
-                       [
-                               [ 'namespaceIds' => [ 0, 1 ], ],
-                               [ 'wl_namespace' => [ 0, 1 ], ],
-                               []
-                       ],
-                       [
-                               [ 'sort' => WatchedItemQueryService::SORT_ASC, ],
-                               [],
-                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
-                       ],
-                       [
-                               [
-                                       'namespaceIds' => [ 0 ],
-                                       'sort' => WatchedItemQueryService::SORT_ASC,
-                               ],
-                               [ 'wl_namespace' => [ 0 ], ],
-                               [ 'ORDER BY' => 'wl_title ASC' ]
-                       ],
-                       [
-                               [ 'limit' => 10 ],
-                               [],
-                               [ 'LIMIT' => 10 ]
-                       ],
-                       [
-                               [
-                                       'namespaceIds' => [ 0, "1; DROP TABLE watchlist;\n--" ],
-                                       'limit' => "10; DROP TABLE watchlist;\n--",
-                               ],
-                               [ 'wl_namespace' => [ 0, 1 ], ],
-                               [ 'LIMIT' => 10 ]
-                       ],
-                       [
-                               [ 'filter' => WatchedItemQueryService::FILTER_CHANGED ],
-                               [ 'wl_notificationtimestamp IS NOT NULL' ],
-                               []
-                       ],
-                       [
-                               [ 'filter' => WatchedItemQueryService::FILTER_NOT_CHANGED ],
-                               [ 'wl_notificationtimestamp IS NULL' ],
-                               []
-                       ],
-                       [
-                               [ 'sort' => WatchedItemQueryService::SORT_DESC, ],
-                               [],
-                               [ 'ORDER BY' => [ 'wl_namespace DESC', 'wl_title DESC' ] ]
-                       ],
-                       [
-                               [
-                                       'namespaceIds' => [ 0 ],
-                                       'sort' => WatchedItemQueryService::SORT_DESC,
-                               ],
-                               [ 'wl_namespace' => [ 0 ], ],
-                               [ 'ORDER BY' => 'wl_title DESC' ]
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideGetWatchedItemsForUserOptions
-        */
-       public function testGetWatchedItemsForUser_optionsAndEmptyResult(
-               array $options,
-               array $expectedConds,
-               array $expectedDbOptions
-       ) {
-               $mockDb = $this->getMockDb();
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $expectedConds = array_merge( [ 'wl_user' => 1 ], $expectedConds );
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               $expectedConds,
-                               $this->isType( 'string' ),
-                               $expectedDbOptions
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-
-               $items = $queryService->getWatchedItemsForUser( $user, $options );
-               $this->assertEmpty( $items );
-       }
-
-       public function provideGetWatchedItemsForUser_fromUntilStartFromOptions() {
-               return [
-                       [
-                               [
-                                       'from' => new TitleValue( 0, 'SomeDbKey' ),
-                                       'sort' => WatchedItemQueryService::SORT_ASC
-                               ],
-                               [ "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'SomeDbKey'))", ],
-                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
-                       ],
-                       [
-                               [
-                                       'from' => new TitleValue( 0, 'SomeDbKey' ),
-                                       'sort' => WatchedItemQueryService::SORT_DESC,
-                               ],
-                               [ "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeDbKey'))", ],
-                               [ 'ORDER BY' => [ 'wl_namespace DESC', 'wl_title DESC' ] ]
-                       ],
-                       [
-                               [
-                                       'until' => new TitleValue( 0, 'SomeDbKey' ),
-                                       'sort' => WatchedItemQueryService::SORT_ASC
-                               ],
-                               [ "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeDbKey'))", ],
-                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
-                       ],
-                       [
-                               [
-                                       'until' => new TitleValue( 0, 'SomeDbKey' ),
-                                       'sort' => WatchedItemQueryService::SORT_DESC
-                               ],
-                               [ "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'SomeDbKey'))", ],
-                               [ 'ORDER BY' => [ 'wl_namespace DESC', 'wl_title DESC' ] ]
-                       ],
-                       [
-                               [
-                                       'from' => new TitleValue( 0, 'AnotherDbKey' ),
-                                       'until' => new TitleValue( 0, 'SomeOtherDbKey' ),
-                                       'startFrom' => new TitleValue( 0, 'SomeDbKey' ),
-                                       'sort' => WatchedItemQueryService::SORT_ASC
-                               ],
-                               [
-                                       "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'AnotherDbKey'))",
-                                       "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeOtherDbKey'))",
-                                       "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'SomeDbKey'))",
-                               ],
-                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
-                       ],
-                       [
-                               [
-                                       'from' => new TitleValue( 0, 'SomeOtherDbKey' ),
-                                       'until' => new TitleValue( 0, 'AnotherDbKey' ),
-                                       'startFrom' => new TitleValue( 0, 'SomeDbKey' ),
-                                       'sort' => WatchedItemQueryService::SORT_DESC
-                               ],
-                               [
-                                       "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeOtherDbKey'))",
-                                       "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'AnotherDbKey'))",
-                                       "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeDbKey'))",
-                               ],
-                               [ 'ORDER BY' => [ 'wl_namespace DESC', 'wl_title DESC' ] ]
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideGetWatchedItemsForUser_fromUntilStartFromOptions
-        */
-       public function testGetWatchedItemsForUser_fromUntilStartFromOptions(
-               array $options,
-               array $expectedConds,
-               array $expectedDbOptions
-       ) {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $expectedConds = array_merge( [ 'wl_user' => 1 ], $expectedConds );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->any() )
-                       ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return "'$value'";
-                       } ) );
-               $mockDb->expects( $this->any() )
-                       ->method( 'makeList' )
-                       ->with(
-                               $this->isType( 'array' ),
-                               $this->isType( 'int' )
-                       )
-                       ->will( $this->returnCallback( function ( $a, $conj ) {
-                               $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
-                               return join( $sqlConj, array_map( function ( $s ) {
-                                       return '(' . $s . ')';
-                               }, $a
-                               ) );
-                       } ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               $expectedConds,
-                               $this->isType( 'string' ),
-                               $expectedDbOptions
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-
-               $items = $queryService->getWatchedItemsForUser( $user, $options );
-               $this->assertEmpty( $items );
-       }
-
-       public function getWatchedItemsForUserInvalidOptionsProvider() {
-               return [
-                       [
-                               [ 'sort' => 'foo' ],
-                               'Bad value for parameter $options[\'sort\']'
-                       ],
-                       [
-                               [ 'filter' => 'foo' ],
-                               'Bad value for parameter $options[\'filter\']'
-                       ],
-                       [
-                               [ 'from' => new TitleValue( 0, 'SomeDbKey' ), ],
-                               'Bad value for parameter $options[\'sort\']: must be provided'
-                       ],
-                       [
-                               [ 'until' => new TitleValue( 0, 'SomeDbKey' ), ],
-                               'Bad value for parameter $options[\'sort\']: must be provided'
-                       ],
-                       [
-                               [ 'startFrom' => new TitleValue( 0, 'SomeDbKey' ), ],
-                               'Bad value for parameter $options[\'sort\']: must be provided'
-                       ],
-               ];
-       }
-
-       /**
-        * @dataProvider getWatchedItemsForUserInvalidOptionsProvider
-        */
-       public function testGetWatchedItemsForUser_invalidOptionThrowsException(
-               array $options,
-               $expectedInExceptionMessage
-       ) {
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $this->getMockDb() ) );
-
-               $this->setExpectedException( InvalidArgumentException::class, $expectedInExceptionMessage );
-               $queryService->getWatchedItemsForUser( $this->getMockNonAnonUserWithId( 1 ), $options );
-       }
-
-       public function testGetWatchedItemsForUser_userNotAllowedToViewWatchlist() {
-               $mockDb = $this->getMockDb();
-
-               $mockDb->expects( $this->never() )
-                       ->method( $this->anything() );
-
-               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
-
-               $items = $queryService->getWatchedItemsForUser( $this->getMockAnonUser() );
-               $this->assertEmpty( $items );
-       }
-
-}
diff --git a/tests/phpunit/includes/WatchedItemStoreIntegrationTest.php b/tests/phpunit/includes/WatchedItemStoreIntegrationTest.php
deleted file mode 100644 (file)
index 61b62aa..0000000
+++ /dev/null
@@ -1,214 +0,0 @@
-<?php
-
-use MediaWiki\MediaWikiServices;
-
-/**
- * @author Addshore
- *
- * @group Database
- *
- * @covers WatchedItemStore
- */
-class WatchedItemStoreIntegrationTest extends MediaWikiTestCase {
-
-       public function setUp() {
-               parent::setUp();
-               self::$users['WatchedItemStoreIntegrationTestUser']
-                       = new TestUser( 'WatchedItemStoreIntegrationTestUser' );
-       }
-
-       private function getUser() {
-               return self::$users['WatchedItemStoreIntegrationTestUser']->getUser();
-       }
-
-       public function testWatchAndUnWatchItem() {
-               $user = $this->getUser();
-               $title = Title::newFromText( 'WatchedItemStoreIntegrationTestPage' );
-               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
-               // Cleanup after previous tests
-               $store->removeWatch( $user, $title );
-               $initialWatchers = $store->countWatchers( $title );
-               $initialUserWatchedItems = $store->countWatchedItems( $user );
-
-               $this->assertFalse(
-                       $store->isWatched( $user, $title ),
-                       'Page should not initially be watched'
-               );
-
-               $store->addWatch( $user, $title );
-               $this->assertTrue(
-                       $store->isWatched( $user, $title ),
-                       'Page should be watched'
-               );
-               $this->assertEquals( $initialUserWatchedItems + 1, $store->countWatchedItems( $user ) );
-               $watchedItemsForUser = $store->getWatchedItemsForUser( $user );
-               $this->assertCount( $initialUserWatchedItems + 1, $watchedItemsForUser );
-               $watchedItemsForUserHasExpectedItem = false;
-               foreach ( $watchedItemsForUser as $watchedItem ) {
-                       if (
-                               $watchedItem->getUser()->equals( $user ) &&
-                               $watchedItem->getLinkTarget() == $title->getTitleValue()
-                       ) {
-                               $watchedItemsForUserHasExpectedItem = true;
-                       }
-               }
-               $this->assertTrue(
-                       $watchedItemsForUserHasExpectedItem,
-                       'getWatchedItemsForUser should contain the page'
-               );
-               $this->assertEquals( $initialWatchers + 1, $store->countWatchers( $title ) );
-               $this->assertEquals(
-                       $initialWatchers + 1,
-                       $store->countWatchersMultiple( [ $title ] )[$title->getNamespace()][$title->getDBkey()]
-               );
-               $this->assertEquals(
-                       [ 0 => [ 'WatchedItemStoreIntegrationTestPage' => $initialWatchers + 1 ] ],
-                       $store->countWatchersMultiple( [ $title ], [ 'minimumWatchers' => $initialWatchers + 1 ] )
-               );
-               $this->assertEquals(
-                       [ 0 => [ 'WatchedItemStoreIntegrationTestPage' => 0 ] ],
-                       $store->countWatchersMultiple( [ $title ], [ 'minimumWatchers' => $initialWatchers + 2 ] )
-               );
-               $this->assertEquals(
-                       [ $title->getNamespace() => [ $title->getDBkey() => null ] ],
-                       $store->getNotificationTimestampsBatch( $user, [ $title ] )
-               );
-
-               $store->removeWatch( $user, $title );
-               $this->assertFalse(
-                       $store->isWatched( $user, $title ),
-                       'Page should be unwatched'
-               );
-               $this->assertEquals( $initialUserWatchedItems, $store->countWatchedItems( $user ) );
-               $watchedItemsForUser = $store->getWatchedItemsForUser( $user );
-               $this->assertCount( $initialUserWatchedItems, $watchedItemsForUser );
-               $watchedItemsForUserHasExpectedItem = false;
-               foreach ( $watchedItemsForUser as $watchedItem ) {
-                       if (
-                               $watchedItem->getUser()->equals( $user ) &&
-                               $watchedItem->getLinkTarget() == $title->getTitleValue()
-                       ) {
-                               $watchedItemsForUserHasExpectedItem = true;
-                       }
-               }
-               $this->assertFalse(
-                       $watchedItemsForUserHasExpectedItem,
-                       'getWatchedItemsForUser should not contain the page'
-               );
-               $this->assertEquals( $initialWatchers, $store->countWatchers( $title ) );
-               $this->assertEquals(
-                       $initialWatchers,
-                       $store->countWatchersMultiple( [ $title ] )[$title->getNamespace()][$title->getDBkey()]
-               );
-               $this->assertEquals(
-                       [ $title->getNamespace() => [ $title->getDBkey() => false ] ],
-                       $store->getNotificationTimestampsBatch( $user, [ $title ] )
-               );
-       }
-
-       public function testUpdateResetAndSetNotificationTimestamp() {
-               $user = $this->getUser();
-               $otherUser = ( new TestUser( 'WatchedItemStoreIntegrationTestUser_otherUser' ) )->getUser();
-               $title = Title::newFromText( 'WatchedItemStoreIntegrationTestPage' );
-               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
-               $store->addWatch( $user, $title );
-               $this->assertNull( $store->loadWatchedItem( $user, $title )->getNotificationTimestamp() );
-               $initialVisitingWatchers = $store->countVisitingWatchers( $title, '20150202020202' );
-               $initialUnreadNotifications = $store->countUnreadNotifications( $user );
-
-               $store->updateNotificationTimestamp( $otherUser, $title, '20150202010101' );
-               $this->assertEquals(
-                       '20150202010101',
-                       $store->loadWatchedItem( $user, $title )->getNotificationTimestamp()
-               );
-               $this->assertEquals(
-                       [ $title->getNamespace() => [ $title->getDBkey() => '20150202010101' ] ],
-                       $store->getNotificationTimestampsBatch( $user, [ $title ] )
-               );
-               $this->assertEquals(
-                       $initialVisitingWatchers - 1,
-                       $store->countVisitingWatchers( $title, '20150202020202' )
-               );
-               $this->assertEquals(
-                       $initialVisitingWatchers - 1,
-                       $store->countVisitingWatchersMultiple(
-                               [ [ $title, '20150202020202' ] ]
-                       )[$title->getNamespace()][$title->getDBkey()]
-               );
-               $this->assertEquals(
-                       $initialUnreadNotifications + 1,
-                       $store->countUnreadNotifications( $user )
-               );
-               $this->assertSame(
-                       true,
-                       $store->countUnreadNotifications( $user, $initialUnreadNotifications + 1 )
-               );
-
-               $this->assertTrue( $store->resetNotificationTimestamp( $user, $title ) );
-               $this->assertNull( $store->getWatchedItem( $user, $title )->getNotificationTimestamp() );
-               $this->assertEquals(
-                       [ $title->getNamespace() => [ $title->getDBkey() => null ] ],
-                       $store->getNotificationTimestampsBatch( $user, [ $title ] )
-               );
-               $this->assertEquals(
-                       $initialVisitingWatchers,
-                       $store->countVisitingWatchers( $title, '20150202020202' )
-               );
-               $this->assertEquals(
-                       $initialVisitingWatchers,
-                       $store->countVisitingWatchersMultiple(
-                               [ [ $title, '20150202020202' ] ]
-                       )[$title->getNamespace()][$title->getDBkey()]
-               );
-               $this->assertEquals(
-                       [ 0 => [ 'WatchedItemStoreIntegrationTestPage' => $initialVisitingWatchers ] ],
-                       $store->countVisitingWatchersMultiple(
-                               [ [ $title, '20150202020202' ] ], $initialVisitingWatchers
-                       )
-               );
-               $this->assertEquals(
-                       [ 0 => [ 'WatchedItemStoreIntegrationTestPage' => 0 ] ],
-                       $store->countVisitingWatchersMultiple(
-                               [ [ $title, '20150202020202' ] ], $initialVisitingWatchers + 1
-                       )
-               );
-
-               // setNotificationTimestampsForUser specifying a title
-               $this->assertTrue(
-                       $store->setNotificationTimestampsForUser( $user, '20200202020202', [ $title ] )
-               );
-               $this->assertEquals(
-                       '20200202020202',
-                       $store->getWatchedItem( $user, $title )->getNotificationTimestamp()
-               );
-
-               // setNotificationTimestampsForUser not specifying a title
-               $this->assertTrue(
-                       $store->setNotificationTimestampsForUser( $user, '20210202020202' )
-               );
-               $this->assertEquals(
-                       '20210202020202',
-                       $store->getWatchedItem( $user, $title )->getNotificationTimestamp()
-               );
-       }
-
-       public function testDuplicateAllAssociatedEntries() {
-               $user = $this->getUser();
-               $titleOld = Title::newFromText( 'WatchedItemStoreIntegrationTestPageOld' );
-               $titleNew = Title::newFromText( 'WatchedItemStoreIntegrationTestPageNew' );
-               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
-               $store->addWatch( $user, $titleOld->getSubjectPage() );
-               $store->addWatch( $user, $titleOld->getTalkPage() );
-               // Cleanup after previous tests
-               $store->removeWatch( $user, $titleNew->getSubjectPage() );
-               $store->removeWatch( $user, $titleNew->getTalkPage() );
-
-               $store->duplicateAllAssociatedEntries( $titleOld, $titleNew );
-
-               $this->assertTrue( $store->isWatched( $user, $titleOld->getSubjectPage() ) );
-               $this->assertTrue( $store->isWatched( $user, $titleOld->getTalkPage() ) );
-               $this->assertTrue( $store->isWatched( $user, $titleNew->getSubjectPage() ) );
-               $this->assertTrue( $store->isWatched( $user, $titleNew->getTalkPage() ) );
-       }
-
-}
diff --git a/tests/phpunit/includes/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/WatchedItemStoreUnitTest.php
deleted file mode 100644 (file)
index 950e220..0000000
+++ /dev/null
@@ -1,2674 +0,0 @@
-<?php
-use MediaWiki\Linker\LinkTarget;
-use Wikimedia\ScopedCallback;
-
-/**
- * @author Addshore
- *
- * @covers WatchedItemStore
- */
-class WatchedItemStoreUnitTest extends MediaWikiTestCase {
-
-       /**
-        * @return PHPUnit_Framework_MockObject_MockObject|IDatabase
-        */
-       private function getMockDb() {
-               return $this->createMock( IDatabase::class );
-       }
-
-       /**
-        * @return PHPUnit_Framework_MockObject_MockObject|LoadBalancer
-        */
-       private function getMockLoadBalancer(
-               $mockDb,
-               $expectedConnectionType = null
-       ) {
-               $mock = $this->getMockBuilder( LoadBalancer::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               if ( $expectedConnectionType !== null ) {
-                       $mock->expects( $this->any() )
-                               ->method( 'getConnectionRef' )
-                               ->with( $expectedConnectionType )
-                               ->will( $this->returnValue( $mockDb ) );
-               } else {
-                       $mock->expects( $this->any() )
-                               ->method( 'getConnectionRef' )
-                               ->will( $this->returnValue( $mockDb ) );
-               }
-               return $mock;
-       }
-
-       /**
-        * @return PHPUnit_Framework_MockObject_MockObject|HashBagOStuff
-        */
-       private function getMockCache() {
-               $mock = $this->getMockBuilder( HashBagOStuff::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $mock->expects( $this->any() )
-                       ->method( 'makeKey' )
-                       ->will( $this->returnCallback( function () {
-                               return implode( ':', func_get_args() );
-                       } ) );
-               return $mock;
-       }
-
-       /**
-        * @return PHPUnit_Framework_MockObject_MockObject|ReadOnlyMode
-        */
-       private function getMockReadOnlyMode( $readOnly = false ) {
-               $mock = $this->getMockBuilder( ReadOnlyMode::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $mock->expects( $this->any() )
-                       ->method( 'isReadOnly' )
-                       ->will( $this->returnValue( $readOnly ) );
-               return $mock;
-       }
-
-       /**
-        * @param int $id
-        * @return PHPUnit_Framework_MockObject_MockObject|User
-        */
-       private function getMockNonAnonUserWithId( $id ) {
-               $mock = $this->createMock( User::class );
-               $mock->expects( $this->any() )
-                       ->method( 'isAnon' )
-                       ->will( $this->returnValue( false ) );
-               $mock->expects( $this->any() )
-                       ->method( 'getId' )
-                       ->will( $this->returnValue( $id ) );
-               return $mock;
-       }
-
-       /**
-        * @return User
-        */
-       private function getAnonUser() {
-               return User::newFromName( 'Anon_User' );
-       }
-
-       private function getFakeRow( array $rowValues ) {
-               $fakeRow = new stdClass();
-               foreach ( $rowValues as $valueName => $value ) {
-                       $fakeRow->$valueName = $value;
-               }
-               return $fakeRow;
-       }
-
-       private function newWatchedItemStore( LoadBalancer $loadBalancer, HashBagOStuff $cache,
-               ReadOnlyMode $readOnlyMode
-       ) {
-               return new WatchedItemStore(
-                       $loadBalancer,
-                       $cache,
-                       $readOnlyMode
-               );
-       }
-
-       public function testCountWatchedItems() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'selectField' )
-                       ->with(
-                               'watchlist',
-                               'COUNT(*)',
-                               [
-                                       'wl_user' => $user->getId(),
-                               ],
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 12 ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals( 12, $store->countWatchedItems( $user ) );
-       }
-
-       public function testCountWatchers() {
-               $titleValue = new TitleValue( 0, 'SomeDbKey' );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'selectField' )
-                       ->with(
-                               'watchlist',
-                               'COUNT(*)',
-                               [
-                                       'wl_namespace' => $titleValue->getNamespace(),
-                                       'wl_title' => $titleValue->getDBkey(),
-                               ],
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 7 ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals( 7, $store->countWatchers( $titleValue ) );
-       }
-
-       public function testCountWatchersMultiple() {
-               $titleValues = [
-                       new TitleValue( 0, 'SomeDbKey' ),
-                       new TitleValue( 0, 'OtherDbKey' ),
-                       new TitleValue( 1, 'AnotherDbKey' ),
-               ];
-
-               $mockDb = $this->getMockDb();
-
-               $dbResult = [
-                       $this->getFakeRow( [ 'wl_title' => 'SomeDbKey', 'wl_namespace' => 0, 'watchers' => 100 ] ),
-                       $this->getFakeRow( [ 'wl_title' => 'OtherDbKey', 'wl_namespace' => 0, 'watchers' => 300 ] ),
-                       $this->getFakeRow( [ 'wl_title' => 'AnotherDbKey', 'wl_namespace' => 1, 'watchers' => 500 ]
-                       ),
-               ];
-               $mockDb->expects( $this->once() )
-                       ->method( 'makeWhereFrom2d' )
-                       ->with(
-                               [ [ 'SomeDbKey' => 1, 'OtherDbKey' => 1 ], [ 'AnotherDbKey' => 1 ] ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'string' )
-                               )
-                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_title', 'wl_namespace', 'watchers' => 'COUNT(*)' ],
-                               [ 'makeWhereFrom2d return value' ],
-                               $this->isType( 'string' ),
-                               [
-                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
-                               ]
-                       )
-                       ->will(
-                               $this->returnValue( $dbResult )
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $expected = [
-                       0 => [ 'SomeDbKey' => 100, 'OtherDbKey' => 300 ],
-                       1 => [ 'AnotherDbKey' => 500 ],
-               ];
-               $this->assertEquals( $expected, $store->countWatchersMultiple( $titleValues ) );
-       }
-
-       public function provideIntWithDbUnsafeVersion() {
-               return [
-                       [ 50 ],
-                       [ "50; DROP TABLE watchlist;\n--" ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideIntWithDbUnsafeVersion
-        */
-       public function testCountWatchersMultiple_withMinimumWatchers( $minWatchers ) {
-               $titleValues = [
-                       new TitleValue( 0, 'SomeDbKey' ),
-                       new TitleValue( 0, 'OtherDbKey' ),
-                       new TitleValue( 1, 'AnotherDbKey' ),
-               ];
-
-               $mockDb = $this->getMockDb();
-
-               $dbResult = [
-                       $this->getFakeRow( [ 'wl_title' => 'SomeDbKey', 'wl_namespace' => 0, 'watchers' => 100 ] ),
-                       $this->getFakeRow( [ 'wl_title' => 'OtherDbKey', 'wl_namespace' => 0, 'watchers' => 300 ] ),
-                       $this->getFakeRow( [ 'wl_title' => 'AnotherDbKey', 'wl_namespace' => 1, 'watchers' => 500 ]
-                       ),
-               ];
-               $mockDb->expects( $this->once() )
-                       ->method( 'makeWhereFrom2d' )
-                       ->with(
-                               [ [ 'SomeDbKey' => 1, 'OtherDbKey' => 1 ], [ 'AnotherDbKey' => 1 ] ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_title', 'wl_namespace', 'watchers' => 'COUNT(*)' ],
-                               [ 'makeWhereFrom2d return value' ],
-                               $this->isType( 'string' ),
-                               [
-                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
-                                       'HAVING' => 'COUNT(*) >= 50',
-                               ]
-                       )
-                       ->will(
-                               $this->returnValue( $dbResult )
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $expected = [
-                       0 => [ 'SomeDbKey' => 100, 'OtherDbKey' => 300 ],
-                       1 => [ 'AnotherDbKey' => 500 ],
-               ];
-               $this->assertEquals(
-                       $expected,
-                       $store->countWatchersMultiple( $titleValues, [ 'minimumWatchers' => $minWatchers ] )
-               );
-       }
-
-       public function testCountVisitingWatchers() {
-               $titleValue = new TitleValue( 0, 'SomeDbKey' );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'selectField' )
-                       ->with(
-                               'watchlist',
-                               'COUNT(*)',
-                               [
-                                       'wl_namespace' => $titleValue->getNamespace(),
-                                       'wl_title' => $titleValue->getDBkey(),
-                                       'wl_notificationtimestamp >= \'TS111TS\' OR wl_notificationtimestamp IS NULL',
-                               ],
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 7 ) );
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return "'$value'";
-                       } ) );
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'timestamp' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return 'TS' . $value . 'TS';
-                       } ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals( 7, $store->countVisitingWatchers( $titleValue, '111' ) );
-       }
-
-       public function testCountVisitingWatchersMultiple() {
-               $titleValuesWithThresholds = [
-                       [ new TitleValue( 0, 'SomeDbKey' ), '111' ],
-                       [ new TitleValue( 0, 'OtherDbKey' ), '111' ],
-                       [ new TitleValue( 1, 'AnotherDbKey' ), '123' ],
-               ];
-
-               $dbResult = [
-                       $this->getFakeRow( [ 'wl_title' => 'SomeDbKey', 'wl_namespace' => 0, 'watchers' => 100 ] ),
-                       $this->getFakeRow( [ 'wl_title' => 'OtherDbKey', 'wl_namespace' => 0, 'watchers' => 300 ] ),
-                       $this->getFakeRow( [ 'wl_title' => 'AnotherDbKey', 'wl_namespace' => 1, 'watchers' => 500 ] ),
-               ];
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->exactly( 2 * 3 ) )
-                       ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return "'$value'";
-                       } ) );
-               $mockDb->expects( $this->exactly( 3 ) )
-                       ->method( 'timestamp' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return 'TS' . $value . 'TS';
-                       } ) );
-               $mockDb->expects( $this->any() )
-                       ->method( 'makeList' )
-                       ->with(
-                               $this->isType( 'array' ),
-                               $this->isType( 'int' )
-                       )
-                       ->will( $this->returnCallback( function ( $a, $conj ) {
-                               $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
-                               return join( $sqlConj, array_map( function ( $s ) {
-                                       return '(' . $s . ')';
-                               }, $a
-                               ) );
-                       } ) );
-               $mockDb->expects( $this->never() )
-                       ->method( 'makeWhereFrom2d' );
-
-               $expectedCond =
-                       '((wl_namespace = 0) AND (' .
-                       "(((wl_title = 'SomeDbKey') AND (" .
-                       "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
-                       ')) OR (' .
-                       "(wl_title = 'OtherDbKey') AND (" .
-                       "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
-                       '))))' .
-                       ') OR ((wl_namespace = 1) AND (' .
-                       "(((wl_title = 'AnotherDbKey') AND (".
-                       "(wl_notificationtimestamp >= 'TS123TS') OR (wl_notificationtimestamp IS NULL)" .
-                       ')))))';
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
-                               $expectedCond,
-                               $this->isType( 'string' ),
-                               [
-                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
-                               ]
-                       )
-                       ->will(
-                               $this->returnValue( $dbResult )
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $expected = [
-                       0 => [ 'SomeDbKey' => 100, 'OtherDbKey' => 300 ],
-                       1 => [ 'AnotherDbKey' => 500 ],
-               ];
-               $this->assertEquals(
-                       $expected,
-                       $store->countVisitingWatchersMultiple( $titleValuesWithThresholds )
-               );
-       }
-
-       public function testCountVisitingWatchersMultiple_withMissingTargets() {
-               $titleValuesWithThresholds = [
-                       [ new TitleValue( 0, 'SomeDbKey' ), '111' ],
-                       [ new TitleValue( 0, 'OtherDbKey' ), '111' ],
-                       [ new TitleValue( 1, 'AnotherDbKey' ), '123' ],
-                       [ new TitleValue( 0, 'SomeNotExisitingDbKey' ), null ],
-                       [ new TitleValue( 0, 'OtherNotExisitingDbKey' ), null ],
-               ];
-
-               $dbResult = [
-                       $this->getFakeRow( [ 'wl_title' => 'SomeDbKey', 'wl_namespace' => 0, 'watchers' => 100 ] ),
-                       $this->getFakeRow( [ 'wl_title' => 'OtherDbKey', 'wl_namespace' => 0, 'watchers' => 300 ] ),
-                       $this->getFakeRow( [ 'wl_title' => 'AnotherDbKey', 'wl_namespace' => 1, 'watchers' => 500 ] ),
-                       $this->getFakeRow(
-                               [ 'wl_title' => 'SomeNotExisitingDbKey', 'wl_namespace' => 0, 'watchers' => 100 ]
-                       ),
-                       $this->getFakeRow(
-                               [ 'wl_title' => 'OtherNotExisitingDbKey', 'wl_namespace' => 0, 'watchers' => 200 ]
-                       ),
-               ];
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->exactly( 2 * 3 ) )
-                       ->method( 'addQuotes' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return "'$value'";
-                       } ) );
-               $mockDb->expects( $this->exactly( 3 ) )
-                       ->method( 'timestamp' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return 'TS' . $value . 'TS';
-                       } ) );
-               $mockDb->expects( $this->any() )
-                       ->method( 'makeList' )
-                       ->with(
-                               $this->isType( 'array' ),
-                               $this->isType( 'int' )
-                       )
-                       ->will( $this->returnCallback( function ( $a, $conj ) {
-                               $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
-                               return join( $sqlConj, array_map( function ( $s ) {
-                                       return '(' . $s . ')';
-                               }, $a
-                               ) );
-                       } ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'makeWhereFrom2d' )
-                       ->with(
-                               [ [ 'SomeNotExisitingDbKey' => 1, 'OtherNotExisitingDbKey' => 1 ] ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
-
-               $expectedCond =
-                       '((wl_namespace = 0) AND (' .
-                       "(((wl_title = 'SomeDbKey') AND (" .
-                       "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
-                       ')) OR (' .
-                       "(wl_title = 'OtherDbKey') AND (" .
-                       "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
-                       '))))' .
-                       ') OR ((wl_namespace = 1) AND (' .
-                       "(((wl_title = 'AnotherDbKey') AND (".
-                       "(wl_notificationtimestamp >= 'TS123TS') OR (wl_notificationtimestamp IS NULL)" .
-                       '))))' .
-                       ') OR ' .
-                       '(makeWhereFrom2d return value)';
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
-                               $expectedCond,
-                               $this->isType( 'string' ),
-                               [
-                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
-                               ]
-                       )
-                       ->will(
-                               $this->returnValue( $dbResult )
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $expected = [
-                       0 => [
-                               'SomeDbKey' => 100, 'OtherDbKey' => 300,
-                               'SomeNotExisitingDbKey' => 100, 'OtherNotExisitingDbKey' => 200
-                       ],
-                       1 => [ 'AnotherDbKey' => 500 ],
-               ];
-               $this->assertEquals(
-                       $expected,
-                       $store->countVisitingWatchersMultiple( $titleValuesWithThresholds )
-               );
-       }
-
-       /**
-        * @dataProvider provideIntWithDbUnsafeVersion
-        */
-       public function testCountVisitingWatchersMultiple_withMinimumWatchers( $minWatchers ) {
-               $titleValuesWithThresholds = [
-                       [ new TitleValue( 0, 'SomeDbKey' ), '111' ],
-                       [ new TitleValue( 0, 'OtherDbKey' ), '111' ],
-                       [ new TitleValue( 1, 'AnotherDbKey' ), '123' ],
-               ];
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->any() )
-                       ->method( 'makeList' )
-                       ->will( $this->returnValue( 'makeList return value' ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
-                               'makeList return value',
-                               $this->isType( 'string' ),
-                               [
-                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
-                                       'HAVING' => 'COUNT(*) >= 50',
-                               ]
-                       )
-                       ->will(
-                               $this->returnValue( [] )
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $expected = [
-                       0 => [ 'SomeDbKey' => 0, 'OtherDbKey' => 0 ],
-                       1 => [ 'AnotherDbKey' => 0 ],
-               ];
-               $this->assertEquals(
-                       $expected,
-                       $store->countVisitingWatchersMultiple( $titleValuesWithThresholds, $minWatchers )
-               );
-       }
-
-       public function testCountUnreadNotifications() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'selectRowCount' )
-                       ->with(
-                               'watchlist',
-                               '1',
-                               [
-                                       "wl_notificationtimestamp IS NOT NULL",
-                                       'wl_user' => 1,
-                               ],
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 9 ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals( 9, $store->countUnreadNotifications( $user ) );
-       }
-
-       /**
-        * @dataProvider provideIntWithDbUnsafeVersion
-        */
-       public function testCountUnreadNotifications_withUnreadLimit_overLimit( $limit ) {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'selectRowCount' )
-                       ->with(
-                               'watchlist',
-                               '1',
-                               [
-                                       "wl_notificationtimestamp IS NOT NULL",
-                                       'wl_user' => 1,
-                               ],
-                               $this->isType( 'string' ),
-                               [ 'LIMIT' => 50 ]
-                       )
-                       ->will( $this->returnValue( 50 ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertSame(
-                       true,
-                       $store->countUnreadNotifications( $user, $limit )
-               );
-       }
-
-       /**
-        * @dataProvider provideIntWithDbUnsafeVersion
-        */
-       public function testCountUnreadNotifications_withUnreadLimit_underLimit( $limit ) {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'selectRowCount' )
-                       ->with(
-                               'watchlist',
-                               '1',
-                               [
-                                       "wl_notificationtimestamp IS NOT NULL",
-                                       'wl_user' => 1,
-                               ],
-                               $this->isType( 'string' ),
-                               [ 'LIMIT' => 50 ]
-                       )
-                       ->will( $this->returnValue( 9 ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals(
-                       9,
-                       $store->countUnreadNotifications( $user, $limit )
-               );
-       }
-
-       public function testDuplicateEntry_nothingToDuplicate() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       'wl_user',
-                                       'wl_notificationtimestamp',
-                               ],
-                               [
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'Old_Title',
-                               ],
-                               'WatchedItemStore::duplicateEntry',
-                               [ 'FOR UPDATE' ]
-                       )
-                       ->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $this->getMockCache(),
-                       $this->getMockReadOnlyMode()
-               );
-
-               $store->duplicateEntry(
-                       Title::newFromText( 'Old_Title' ),
-                       Title::newFromText( 'New_Title' )
-               );
-       }
-
-       public function testDuplicateEntry_somethingToDuplicate() {
-               $fakeRows = [
-                       $this->getFakeRow( [ 'wl_user' => 1, 'wl_notificationtimestamp' => '20151212010101' ] ),
-                       $this->getFakeRow( [ 'wl_user' => 2, 'wl_notificationtimestamp' => null ] ),
-               ];
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->at( 0 ) )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       'wl_user',
-                                       'wl_notificationtimestamp',
-                               ],
-                               [
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'Old_Title',
-                               ]
-                       )
-                       ->will( $this->returnValue( new FakeResultWrapper( $fakeRows ) ) );
-               $mockDb->expects( $this->at( 1 ) )
-                       ->method( 'replace' )
-                       ->with(
-                               'watchlist',
-                               [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
-                               [
-                                       [
-                                               'wl_user' => 1,
-                                               'wl_namespace' => 0,
-                                               'wl_title' => 'New_Title',
-                                               'wl_notificationtimestamp' => '20151212010101',
-                                       ],
-                                       [
-                                               'wl_user' => 2,
-                                               'wl_namespace' => 0,
-                                               'wl_title' => 'New_Title',
-                                               'wl_notificationtimestamp' => null,
-                                       ],
-                               ],
-                               $this->isType( 'string' )
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $store->duplicateEntry(
-                       Title::newFromText( 'Old_Title' ),
-                       Title::newFromText( 'New_Title' )
-               );
-       }
-
-       public function testDuplicateAllAssociatedEntries_nothingToDuplicate() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->at( 0 ) )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       'wl_user',
-                                       'wl_notificationtimestamp',
-                               ],
-                               [
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'Old_Title',
-                               ]
-                       )
-                       ->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
-               $mockDb->expects( $this->at( 1 ) )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       'wl_user',
-                                       'wl_notificationtimestamp',
-                               ],
-                               [
-                                       'wl_namespace' => 1,
-                                       'wl_title' => 'Old_Title',
-                               ]
-                       )
-                       ->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $store->duplicateAllAssociatedEntries(
-                       Title::newFromText( 'Old_Title' ),
-                       Title::newFromText( 'New_Title' )
-               );
-       }
-
-       public function provideLinkTargetPairs() {
-               return [
-                       [ Title::newFromText( 'Old_Title' ), Title::newFromText( 'New_Title' ) ],
-                       [ new TitleValue( 0, 'Old_Title' ),  new TitleValue( 0, 'New_Title' ) ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideLinkTargetPairs
-        */
-       public function testDuplicateAllAssociatedEntries_somethingToDuplicate(
-               LinkTarget $oldTarget,
-               LinkTarget $newTarget
-       ) {
-               $fakeRows = [
-                       $this->getFakeRow( [ 'wl_user' => 1, 'wl_notificationtimestamp' => '20151212010101' ] ),
-               ];
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->at( 0 ) )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       'wl_user',
-                                       'wl_notificationtimestamp',
-                               ],
-                               [
-                                       'wl_namespace' => $oldTarget->getNamespace(),
-                                       'wl_title' => $oldTarget->getDBkey(),
-                               ]
-                       )
-                       ->will( $this->returnValue( new FakeResultWrapper( $fakeRows ) ) );
-               $mockDb->expects( $this->at( 1 ) )
-                       ->method( 'replace' )
-                       ->with(
-                               'watchlist',
-                               [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
-                               [
-                                       [
-                                               'wl_user' => 1,
-                                               'wl_namespace' => $newTarget->getNamespace(),
-                                               'wl_title' => $newTarget->getDBkey(),
-                                               'wl_notificationtimestamp' => '20151212010101',
-                                       ],
-                               ],
-                               $this->isType( 'string' )
-                       );
-               $mockDb->expects( $this->at( 2 ) )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       'wl_user',
-                                       'wl_notificationtimestamp',
-                               ],
-                               [
-                                       'wl_namespace' => $oldTarget->getNamespace() + 1,
-                                       'wl_title' => $oldTarget->getDBkey(),
-                               ]
-                       )
-                       ->will( $this->returnValue( new FakeResultWrapper( $fakeRows ) ) );
-               $mockDb->expects( $this->at( 3 ) )
-                       ->method( 'replace' )
-                       ->with(
-                               'watchlist',
-                               [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
-                               [
-                                       [
-                                               'wl_user' => 1,
-                                               'wl_namespace' => $newTarget->getNamespace() + 1,
-                                               'wl_title' => $newTarget->getDBkey(),
-                                               'wl_notificationtimestamp' => '20151212010101',
-                                       ],
-                               ],
-                               $this->isType( 'string' )
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $store->duplicateAllAssociatedEntries(
-                       $oldTarget,
-                       $newTarget
-               );
-       }
-
-       public function testAddWatch_nonAnonymousUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'insert' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       [
-                                               'wl_user' => 1,
-                                               'wl_namespace' => 0,
-                                               'wl_title' => 'Some_Page',
-                                               'wl_notificationtimestamp' => null,
-                                       ]
-                               ]
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->once() )
-                       ->method( 'delete' )
-                       ->with( '0:Some_Page:1' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $store->addWatch(
-                       $this->getMockNonAnonUserWithId( 1 ),
-                       Title::newFromText( 'Some_Page' )
-               );
-       }
-
-       public function testAddWatch_anonymousUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'insert' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $store->addWatch(
-                       $this->getAnonUser(),
-                       Title::newFromText( 'Some_Page' )
-               );
-       }
-
-       public function testAddWatchBatchForUser_readOnlyDBReturnsFalse() {
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $this->getMockDb() ),
-                       $this->getMockCache(),
-                       $this->getMockReadOnlyMode( true )
-               );
-
-               $this->assertFalse(
-                       $store->addWatchBatchForUser(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               [ new TitleValue( 0, 'Some_Page' ), new TitleValue( 1, 'Some_Page' ) ]
-                       )
-               );
-       }
-
-       public function testAddWatchBatchForUser_nonAnonymousUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'insert' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       [
-                                               'wl_user' => 1,
-                                               'wl_namespace' => 0,
-                                               'wl_title' => 'Some_Page',
-                                               'wl_notificationtimestamp' => null,
-                                       ],
-                                       [
-                                               'wl_user' => 1,
-                                               'wl_namespace' => 1,
-                                               'wl_title' => 'Some_Page',
-                                               'wl_notificationtimestamp' => null,
-                                       ]
-                               ]
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->exactly( 2 ) )
-                       ->method( 'delete' );
-               $mockCache->expects( $this->at( 1 ) )
-                       ->method( 'delete' )
-                       ->with( '0:Some_Page:1' );
-               $mockCache->expects( $this->at( 3 ) )
-                       ->method( 'delete' )
-                       ->with( '1:Some_Page:1' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $mockUser = $this->getMockNonAnonUserWithId( 1 );
-
-               $this->assertTrue(
-                       $store->addWatchBatchForUser(
-                               $mockUser,
-                               [ new TitleValue( 0, 'Some_Page' ), new TitleValue( 1, 'Some_Page' ) ]
-                       )
-               );
-       }
-
-       public function testAddWatchBatchForUser_anonymousUsersAreSkipped() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'insert' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->addWatchBatchForUser(
-                               $this->getAnonUser(),
-                               [ new TitleValue( 0, 'Other_Page' ) ]
-                       )
-               );
-       }
-
-       public function testAddWatchBatchReturnsTrue_whenGivenEmptyList() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'insert' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertTrue(
-                       $store->addWatchBatchForUser( $user, [] )
-               );
-       }
-
-       public function testLoadWatchedItem_existingItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue(
-                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
-                       ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->once() )
-                       ->method( 'set' )
-                       ->with(
-                               '0:SomeDbKey:1'
-                       );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $watchedItem = $store->loadWatchedItem(
-                       $this->getMockNonAnonUserWithId( 1 ),
-                       new TitleValue( 0, 'SomeDbKey' )
-               );
-               $this->assertInstanceOf( 'WatchedItem', $watchedItem );
-               $this->assertEquals( 1, $watchedItem->getUser()->getId() );
-               $this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() );
-               $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() );
-       }
-
-       public function testLoadWatchedItem_noItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->loadWatchedItem(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testLoadWatchedItem_anonymousUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'selectRow' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->loadWatchedItem(
-                               $this->getAnonUser(),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testRemoveWatch_existingItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'delete' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       );
-               $mockDb->expects( $this->once() )
-                       ->method( 'affectedRows' )
-                       ->will( $this->returnValue( 1 ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'delete' )
-                       ->with( '0:SomeDbKey:1' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertTrue(
-                       $store->removeWatch(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testRemoveWatch_noItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'delete' )
-                       ->with(
-                               'watchlist',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       );
-               $mockDb->expects( $this->once() )
-                       ->method( 'affectedRows' )
-                       ->will( $this->returnValue( 0 ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'delete' )
-                       ->with( '0:SomeDbKey:1' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->removeWatch(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testRemoveWatch_anonymousUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->removeWatch(
-                               $this->getAnonUser(),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testGetWatchedItem_existingItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue(
-                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
-                       ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'delete' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'get' )
-                       ->with(
-                               '0:SomeDbKey:1'
-                       )
-                       ->will( $this->returnValue( null ) );
-               $mockCache->expects( $this->once() )
-                       ->method( 'set' )
-                       ->with(
-                               '0:SomeDbKey:1'
-                       );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $watchedItem = $store->getWatchedItem(
-                       $this->getMockNonAnonUserWithId( 1 ),
-                       new TitleValue( 0, 'SomeDbKey' )
-               );
-               $this->assertInstanceOf( 'WatchedItem', $watchedItem );
-               $this->assertEquals( 1, $watchedItem->getUser()->getId() );
-               $this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() );
-               $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() );
-       }
-
-       public function testGetWatchedItem_cachedItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'selectRow' );
-
-               $mockUser = $this->getMockNonAnonUserWithId( 1 );
-               $linkTarget = new TitleValue( 0, 'SomeDbKey' );
-               $cachedItem = new WatchedItem( $mockUser, $linkTarget, '20151212010101' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'delete' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'get' )
-                       ->with(
-                               '0:SomeDbKey:1'
-                       )
-                       ->will( $this->returnValue( $cachedItem ) );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals(
-                       $cachedItem,
-                       $store->getWatchedItem(
-                               $mockUser,
-                               $linkTarget
-                       )
-               );
-       }
-
-       public function testGetWatchedItem_noItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'get' )
-                       ->with( '0:SomeDbKey:1' )
-                       ->will( $this->returnValue( false ) );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->getWatchedItem(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testGetWatchedItem_anonymousUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'selectRow' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->getWatchedItem(
-                               $this->getAnonUser(),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testGetWatchedItemsForUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               [ 'wl_user' => 1 ]
-                       )
-                       ->will( $this->returnValue( [
-                               $this->getFakeRow( [
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'Foo1',
-                                       'wl_notificationtimestamp' => '20151212010101',
-                               ] ),
-                               $this->getFakeRow( [
-                                       'wl_namespace' => 1,
-                                       'wl_title' => 'Foo2',
-                                       'wl_notificationtimestamp' => null,
-                               ] ),
-                       ] ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'delete' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $watchedItems = $store->getWatchedItemsForUser( $user );
-
-               $this->assertInternalType( 'array', $watchedItems );
-               $this->assertCount( 2, $watchedItems );
-               foreach ( $watchedItems as $watchedItem ) {
-                       $this->assertInstanceOf( 'WatchedItem', $watchedItem );
-               }
-               $this->assertEquals(
-                       new WatchedItem( $user, new TitleValue( 0, 'Foo1' ), '20151212010101' ),
-                       $watchedItems[0]
-               );
-               $this->assertEquals(
-                       new WatchedItem( $user, new TitleValue( 1, 'Foo2' ), null ),
-                       $watchedItems[1]
-               );
-       }
-
-       public function provideDbTypes() {
-               return [
-                       [ false, DB_REPLICA ],
-                       [ true, DB_MASTER ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideDbTypes
-        */
-       public function testGetWatchedItemsForUser_optionsAndEmptyResult( $forWrite, $dbType ) {
-               $mockDb = $this->getMockDb();
-               $mockCache = $this->getMockCache();
-               $mockLoadBalancer = $this->getMockLoadBalancer( $mockDb, $dbType );
-               $user = $this->getMockNonAnonUserWithId( 1 );
-
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               [ 'wl_user' => 1 ],
-                               $this->isType( 'string' ),
-                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $store = $this->newWatchedItemStore(
-                       $mockLoadBalancer,
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $watchedItems = $store->getWatchedItemsForUser(
-                       $user,
-                       [ 'forWrite' => $forWrite, 'sort' => WatchedItemStore::SORT_ASC ]
-               );
-               $this->assertEquals( [], $watchedItems );
-       }
-
-       public function testGetWatchedItemsForUser_badSortOptionThrowsException() {
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $this->getMockDb() ),
-                       $this->getMockCache(),
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->setExpectedException( 'InvalidArgumentException' );
-               $store->getWatchedItemsForUser(
-                       $this->getMockNonAnonUserWithId( 1 ),
-                       [ 'sort' => 'foo' ]
-               );
-       }
-
-       public function testIsWatchedItem_existingItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue(
-                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
-                       ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'delete' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'get' )
-                       ->with( '0:SomeDbKey:1' )
-                       ->will( $this->returnValue( false ) );
-               $mockCache->expects( $this->once() )
-                       ->method( 'set' )
-                       ->with(
-                               '0:SomeDbKey:1'
-                       );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertTrue(
-                       $store->isWatched(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testIsWatchedItem_noItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'get' )
-                       ->with( '0:SomeDbKey:1' )
-                       ->will( $this->returnValue( false ) );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->isWatched(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testIsWatchedItem_anonymousUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'selectRow' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->isWatched(
-                               $this->getAnonUser(),
-                               new TitleValue( 0, 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testGetNotificationTimestampsBatch() {
-               $targets = [
-                       new TitleValue( 0, 'SomeDbKey' ),
-                       new TitleValue( 1, 'AnotherDbKey' ),
-               ];
-
-               $mockDb = $this->getMockDb();
-               $dbResult = [
-                       $this->getFakeRow( [
-                               'wl_namespace' => 0,
-                               'wl_title' => 'SomeDbKey',
-                               'wl_notificationtimestamp' => '20151212010101',
-                       ] ),
-                       $this->getFakeRow(
-                               [
-                                       'wl_namespace' => 1,
-                                       'wl_title' => 'AnotherDbKey',
-                                       'wl_notificationtimestamp' => null,
-                               ]
-                       ),
-               ];
-
-               $mockDb->expects( $this->once() )
-                       ->method( 'makeWhereFrom2d' )
-                       ->with(
-                               [ [ 'SomeDbKey' => 1 ], [ 'AnotherDbKey' => 1 ] ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               [
-                                       'makeWhereFrom2d return value',
-                                       'wl_user' => 1
-                               ],
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( $dbResult ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->exactly( 2 ) )
-                       ->method( 'get' )
-                       ->withConsecutive(
-                               [ '0:SomeDbKey:1' ],
-                               [ '1:AnotherDbKey:1' ]
-                       )
-                       ->will( $this->returnValue( null ) );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals(
-                       [
-                               0 => [ 'SomeDbKey' => '20151212010101', ],
-                               1 => [ 'AnotherDbKey' => null, ],
-                       ],
-                       $store->getNotificationTimestampsBatch( $this->getMockNonAnonUserWithId( 1 ), $targets )
-               );
-       }
-
-       public function testGetNotificationTimestampsBatch_notWatchedTarget() {
-               $targets = [
-                       new TitleValue( 0, 'OtherDbKey' ),
-               ];
-
-               $mockDb = $this->getMockDb();
-
-               $mockDb->expects( $this->once() )
-                       ->method( 'makeWhereFrom2d' )
-                       ->with(
-                               [ [ 'OtherDbKey' => 1 ] ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               [
-                                       'makeWhereFrom2d return value',
-                                       'wl_user' => 1
-                               ],
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( $this->getFakeRow( [] ) ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->once() )
-                       ->method( 'get' )
-                       ->with( '0:OtherDbKey:1' )
-                       ->will( $this->returnValue( null ) );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals(
-                       [
-                               0 => [ 'OtherDbKey' => false, ],
-                       ],
-                       $store->getNotificationTimestampsBatch( $this->getMockNonAnonUserWithId( 1 ), $targets )
-               );
-       }
-
-       public function testGetNotificationTimestampsBatch_cachedItem() {
-               $targets = [
-                       new TitleValue( 0, 'SomeDbKey' ),
-                       new TitleValue( 1, 'AnotherDbKey' ),
-               ];
-
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $cachedItem = new WatchedItem( $user, $targets[0], '20151212010101' );
-
-               $mockDb = $this->getMockDb();
-
-               $mockDb->expects( $this->once() )
-                       ->method( 'makeWhereFrom2d' )
-                       ->with(
-                               [ 1 => [ 'AnotherDbKey' => 1 ] ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'select' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
-                               [
-                                       'makeWhereFrom2d return value',
-                                       'wl_user' => 1
-                               ],
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( [
-                               $this->getFakeRow(
-                                       [ 'wl_namespace' => 1, 'wl_title' => 'AnotherDbKey', 'wl_notificationtimestamp' => null, ]
-                               )
-                       ] ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->at( 1 ) )
-                       ->method( 'get' )
-                       ->with( '0:SomeDbKey:1' )
-                       ->will( $this->returnValue( $cachedItem ) );
-               $mockCache->expects( $this->at( 3 ) )
-                       ->method( 'get' )
-                       ->with( '1:AnotherDbKey:1' )
-                       ->will( $this->returnValue( null ) );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals(
-                       [
-                               0 => [ 'SomeDbKey' => '20151212010101', ],
-                               1 => [ 'AnotherDbKey' => null, ],
-                       ],
-                       $store->getNotificationTimestampsBatch( $user, $targets )
-               );
-       }
-
-       public function testGetNotificationTimestampsBatch_allItemsCached() {
-               $targets = [
-                       new TitleValue( 0, 'SomeDbKey' ),
-                       new TitleValue( 1, 'AnotherDbKey' ),
-               ];
-
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $cachedItems = [
-                       new WatchedItem( $user, $targets[0], '20151212010101' ),
-                       new WatchedItem( $user, $targets[1], null ),
-               ];
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )->method( $this->anything() );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->at( 1 ) )
-                       ->method( 'get' )
-                       ->with( '0:SomeDbKey:1' )
-                       ->will( $this->returnValue( $cachedItems[0] ) );
-               $mockCache->expects( $this->at( 3 ) )
-                       ->method( 'get' )
-                       ->with( '1:AnotherDbKey:1' )
-                       ->will( $this->returnValue( $cachedItems[1] ) );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals(
-                       [
-                               0 => [ 'SomeDbKey' => '20151212010101', ],
-                               1 => [ 'AnotherDbKey' => null, ],
-                       ],
-                       $store->getNotificationTimestampsBatch( $user, $targets )
-               );
-       }
-
-       public function testGetNotificationTimestampsBatch_anonymousUser() {
-               $targets = [
-                       new TitleValue( 0, 'SomeDbKey' ),
-                       new TitleValue( 1, 'AnotherDbKey' ),
-               ];
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )->method( $this->anything() );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( $this->anything() );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals(
-                       [
-                               0 => [ 'SomeDbKey' => false, ],
-                               1 => [ 'AnotherDbKey' => false, ],
-                       ],
-                       $store->getNotificationTimestampsBatch( $this->getAnonUser(), $targets )
-               );
-       }
-
-       public function testResetNotificationTimestamp_anonymousUser() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'selectRow' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->resetNotificationTimestamp(
-                               $this->getAnonUser(),
-                               Title::newFromText( 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testResetNotificationTimestamp_noItem() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue( [] ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertFalse(
-                       $store->resetNotificationTimestamp(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               Title::newFromText( 'SomeDbKey' )
-                       )
-               );
-       }
-
-       public function testResetNotificationTimestamp_item() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $title = Title::newFromText( 'SomeDbKey' );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue(
-                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
-                       ) );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'set' )
-                       ->with(
-                               '0:SomeDbKey:1',
-                               $this->isInstanceOf( WatchedItem::class )
-                       );
-               $mockCache->expects( $this->once() )
-                       ->method( 'delete' )
-                       ->with( '0:SomeDbKey:1' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               // Note: This does not actually assert the job is correct
-               $callableCallCounter = 0;
-               $mockCallback = function ( $callable ) use ( &$callableCallCounter ) {
-                       $callableCallCounter++;
-                       $this->assertInternalType( 'callable', $callable );
-               };
-               $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback( $mockCallback );
-
-               $this->assertTrue(
-                       $store->resetNotificationTimestamp(
-                               $user,
-                               $title
-                       )
-               );
-               $this->assertEquals( 1, $callableCallCounter );
-
-               ScopedCallback::consume( $scopedOverride );
-       }
-
-       public function testResetNotificationTimestamp_noItemForced() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $title = Title::newFromText( 'SomeDbKey' );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'selectRow' );
-
-               $mockCache = $this->getMockCache();
-               $mockDb->expects( $this->never() )
-                       ->method( 'get' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'set' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               // Note: This does not actually assert the job is correct
-               $callableCallCounter = 0;
-               $mockCallback = function ( $callable ) use ( &$callableCallCounter ) {
-                       $callableCallCounter++;
-                       $this->assertInternalType( 'callable', $callable );
-               };
-               $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback( $mockCallback );
-
-               $this->assertTrue(
-                       $store->resetNotificationTimestamp(
-                               $user,
-                               $title,
-                               'force'
-                       )
-               );
-               $this->assertEquals( 1, $callableCallCounter );
-
-               ScopedCallback::consume( $scopedOverride );
-       }
-
-       /**
-        * @param string $text
-        * @param int $ns
-        *
-        * @return PHPUnit_Framework_MockObject_MockObject|Title
-        */
-       private function getMockTitle( $text, $ns = 0 ) {
-               $title = $this->createMock( Title::class );
-               $title->expects( $this->any() )
-                       ->method( 'getText' )
-                       ->will( $this->returnValue( str_replace( '_', ' ', $text ) ) );
-               $title->expects( $this->any() )
-                       ->method( 'getDbKey' )
-                       ->will( $this->returnValue( str_replace( '_', ' ', $text ) ) );
-               $title->expects( $this->any() )
-                       ->method( 'getNamespace' )
-                       ->will( $this->returnValue( $ns ) );
-               return $title;
-       }
-
-       private function verifyCallbackJob(
-               $callback,
-               LinkTarget $expectedTitle,
-               $expectedUserId,
-               callable $notificationTimestampCondition
-       ) {
-               $this->assertInternalType( 'callable', $callback );
-
-               $callbackReflector = new ReflectionFunction( $callback );
-               $vars = $callbackReflector->getStaticVariables();
-               $this->assertArrayHasKey( 'job', $vars );
-               $this->assertInstanceOf( ActivityUpdateJob::class, $vars['job'] );
-
-               /** @var ActivityUpdateJob $job */
-               $job = $vars['job'];
-               $this->assertEquals( $expectedTitle->getDBkey(), $job->getTitle()->getDBkey() );
-               $this->assertEquals( $expectedTitle->getNamespace(), $job->getTitle()->getNamespace() );
-
-               $jobParams = $job->getParams();
-               $this->assertArrayHasKey( 'type', $jobParams );
-               $this->assertEquals( 'updateWatchlistNotification', $jobParams['type'] );
-               $this->assertArrayHasKey( 'userid', $jobParams );
-               $this->assertEquals( $expectedUserId, $jobParams['userid'] );
-               $this->assertArrayHasKey( 'notifTime', $jobParams );
-               $this->assertTrue( $notificationTimestampCondition( $jobParams['notifTime'] ) );
-       }
-
-       public function testResetNotificationTimestamp_oldidSpecifiedLatestRevisionForced() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $oldid = 22;
-               $title = $this->getMockTitle( 'SomeTitle' );
-               $title->expects( $this->once() )
-                       ->method( 'getNextRevisionID' )
-                       ->with( $oldid )
-                       ->will( $this->returnValue( false ) );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->never() )
-                       ->method( 'selectRow' );
-
-               $mockCache = $this->getMockCache();
-               $mockDb->expects( $this->never() )
-                       ->method( 'get' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'set' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $callableCallCounter = 0;
-               $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
-                       function ( $callable ) use ( &$callableCallCounter, $title, $user ) {
-                               $callableCallCounter++;
-                               $this->verifyCallbackJob(
-                                       $callable,
-                                       $title,
-                                       $user->getId(),
-                                       function ( $time ) {
-                                               return $time === null;
-                                       }
-                               );
-                       }
-               );
-
-               $this->assertTrue(
-                       $store->resetNotificationTimestamp(
-                               $user,
-                               $title,
-                               'force',
-                               $oldid
-                       )
-               );
-               $this->assertEquals( 1, $callableCallCounter );
-
-               ScopedCallback::consume( $scopedOverride );
-       }
-
-       public function testResetNotificationTimestamp_oldidSpecifiedNotLatestRevisionForced() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $oldid = 22;
-               $title = $this->getMockTitle( 'SomeDbKey' );
-               $title->expects( $this->once() )
-                       ->method( 'getNextRevisionID' )
-                       ->with( $oldid )
-                       ->will( $this->returnValue( 33 ) );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue(
-                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
-                       ) );
-
-               $mockCache = $this->getMockCache();
-               $mockDb->expects( $this->never() )
-                       ->method( 'get' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'set' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $addUpdateCallCounter = 0;
-               $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
-                       function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
-                               $addUpdateCallCounter++;
-                               $this->verifyCallbackJob(
-                                       $callable,
-                                       $title,
-                                       $user->getId(),
-                                       function ( $time ) {
-                                               return $time !== null && $time > '20151212010101';
-                                       }
-                               );
-                       }
-               );
-
-               $getTimestampCallCounter = 0;
-               $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
-                       function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
-                               $getTimestampCallCounter++;
-                               $this->assertEquals( $title, $titleParam );
-                               $this->assertEquals( $oldid, $oldidParam );
-                       }
-               );
-
-               $this->assertTrue(
-                       $store->resetNotificationTimestamp(
-                               $user,
-                               $title,
-                               'force',
-                               $oldid
-                       )
-               );
-               $this->assertEquals( 1, $addUpdateCallCounter );
-               $this->assertEquals( 1, $getTimestampCallCounter );
-
-               ScopedCallback::consume( $scopedOverrideDeferred );
-               ScopedCallback::consume( $scopedOverrideRevision );
-       }
-
-       public function testResetNotificationTimestamp_notWatchedPageForced() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $oldid = 22;
-               $title = $this->getMockTitle( 'SomeDbKey' );
-               $title->expects( $this->once() )
-                       ->method( 'getNextRevisionID' )
-                       ->with( $oldid )
-                       ->will( $this->returnValue( 33 ) );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue( false ) );
-
-               $mockCache = $this->getMockCache();
-               $mockDb->expects( $this->never() )
-                       ->method( 'get' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'set' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $callableCallCounter = 0;
-               $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
-                       function ( $callable ) use ( &$callableCallCounter, $title, $user ) {
-                               $callableCallCounter++;
-                               $this->verifyCallbackJob(
-                                       $callable,
-                                       $title,
-                                       $user->getId(),
-                                       function ( $time ) {
-                                               return $time === null;
-                                       }
-                               );
-                       }
-               );
-
-               $this->assertTrue(
-                       $store->resetNotificationTimestamp(
-                               $user,
-                               $title,
-                               'force',
-                               $oldid
-                       )
-               );
-               $this->assertEquals( 1, $callableCallCounter );
-
-               ScopedCallback::consume( $scopedOverride );
-       }
-
-       public function testResetNotificationTimestamp_futureNotificationTimestampForced() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $oldid = 22;
-               $title = $this->getMockTitle( 'SomeDbKey' );
-               $title->expects( $this->once() )
-                       ->method( 'getNextRevisionID' )
-                       ->with( $oldid )
-                       ->will( $this->returnValue( 33 ) );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue(
-                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '30151212010101' ] )
-                       ) );
-
-               $mockCache = $this->getMockCache();
-               $mockDb->expects( $this->never() )
-                       ->method( 'get' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'set' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $addUpdateCallCounter = 0;
-               $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
-                       function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
-                               $addUpdateCallCounter++;
-                               $this->verifyCallbackJob(
-                                       $callable,
-                                       $title,
-                                       $user->getId(),
-                                       function ( $time ) {
-                                               return $time === '30151212010101';
-                                       }
-                               );
-                       }
-               );
-
-               $getTimestampCallCounter = 0;
-               $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
-                       function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
-                               $getTimestampCallCounter++;
-                               $this->assertEquals( $title, $titleParam );
-                               $this->assertEquals( $oldid, $oldidParam );
-                       }
-               );
-
-               $this->assertTrue(
-                       $store->resetNotificationTimestamp(
-                               $user,
-                               $title,
-                               'force',
-                               $oldid
-                       )
-               );
-               $this->assertEquals( 1, $addUpdateCallCounter );
-               $this->assertEquals( 1, $getTimestampCallCounter );
-
-               ScopedCallback::consume( $scopedOverrideDeferred );
-               ScopedCallback::consume( $scopedOverrideRevision );
-       }
-
-       public function testResetNotificationTimestamp_futureNotificationTimestampNotForced() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $oldid = 22;
-               $title = $this->getMockTitle( 'SomeDbKey' );
-               $title->expects( $this->once() )
-                       ->method( 'getNextRevisionID' )
-                       ->with( $oldid )
-                       ->will( $this->returnValue( 33 ) );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->with(
-                               'watchlist',
-                               'wl_notificationtimestamp',
-                               [
-                                       'wl_user' => 1,
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       )
-                       ->will( $this->returnValue(
-                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '30151212010101' ] )
-                       ) );
-
-               $mockCache = $this->getMockCache();
-               $mockDb->expects( $this->never() )
-                       ->method( 'get' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'set' );
-               $mockDb->expects( $this->never() )
-                       ->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $addUpdateCallCounter = 0;
-               $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
-                       function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
-                               $addUpdateCallCounter++;
-                               $this->verifyCallbackJob(
-                                       $callable,
-                                       $title,
-                                       $user->getId(),
-                                       function ( $time ) {
-                                               return $time === false;
-                                       }
-                               );
-                       }
-               );
-
-               $getTimestampCallCounter = 0;
-               $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
-                       function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
-                               $getTimestampCallCounter++;
-                               $this->assertEquals( $title, $titleParam );
-                               $this->assertEquals( $oldid, $oldidParam );
-                       }
-               );
-
-               $this->assertTrue(
-                       $store->resetNotificationTimestamp(
-                               $user,
-                               $title,
-                               '',
-                               $oldid
-                       )
-               );
-               $this->assertEquals( 1, $addUpdateCallCounter );
-               $this->assertEquals( 1, $getTimestampCallCounter );
-
-               ScopedCallback::consume( $scopedOverrideDeferred );
-               ScopedCallback::consume( $scopedOverrideRevision );
-       }
-
-       public function testSetNotificationTimestampsForUser_anonUser() {
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $this->getMockDb() ),
-                       $this->getMockCache(),
-                       $this->getMockReadOnlyMode()
-               );
-               $this->assertFalse( $store->setNotificationTimestampsForUser( $this->getAnonUser(), '' ) );
-       }
-
-       public function testSetNotificationTimestampsForUser_allRows() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $timestamp = '20100101010101';
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'update' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_notificationtimestamp' => 'TS' . $timestamp . 'TS' ],
-                               [ 'wl_user' => 1 ]
-                       )
-                       ->will( $this->returnValue( true ) );
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'timestamp' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return 'TS' . $value . 'TS';
-                       } ) );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $this->getMockCache(),
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertTrue(
-                       $store->setNotificationTimestampsForUser( $user, $timestamp )
-               );
-       }
-
-       public function testSetNotificationTimestampsForUser_nullTimestamp() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $timestamp = null;
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'update' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_notificationtimestamp' => null ],
-                               [ 'wl_user' => 1 ]
-                       )
-                       ->will( $this->returnValue( true ) );
-               $mockDb->expects( $this->exactly( 0 ) )
-                       ->method( 'timestamp' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return 'TS' . $value . 'TS';
-                       } ) );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $this->getMockCache(),
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertTrue(
-                       $store->setNotificationTimestampsForUser( $user, $timestamp )
-               );
-       }
-
-       public function testSetNotificationTimestampsForUser_specificTargets() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $timestamp = '20100101010101';
-               $targets = [ new TitleValue( 0, 'Foo' ), new TitleValue( 0, 'Bar' ) ];
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'update' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_notificationtimestamp' => 'TS' . $timestamp . 'TS' ],
-                               [ 'wl_user' => 1, 0 => 'makeWhereFrom2d return value' ]
-                       )
-                       ->will( $this->returnValue( true ) );
-               $mockDb->expects( $this->exactly( 1 ) )
-                       ->method( 'timestamp' )
-                       ->will( $this->returnCallback( function ( $value ) {
-                               return 'TS' . $value . 'TS';
-                       } ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'makeWhereFrom2d' )
-                       ->with(
-                               [ [ 'Foo' => 1, 'Bar' => 1 ] ],
-                               $this->isType( 'string' ),
-                               $this->isType( 'string' )
-                       )
-                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $this->getMockCache(),
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertTrue(
-                       $store->setNotificationTimestampsForUser( $user, $timestamp, $targets )
-               );
-       }
-
-       public function testUpdateNotificationTimestamp_watchersExist() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectFieldValues' )
-                       ->with(
-                               'watchlist',
-                               'wl_user',
-                               [
-                                       'wl_user != 1',
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                                       'wl_notificationtimestamp IS NULL'
-                               ]
-                       )
-                       ->will( $this->returnValue( [ '2', '3' ] ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'update' )
-                       ->with(
-                               'watchlist',
-                               [ 'wl_notificationtimestamp' => null ],
-                               [
-                                       'wl_user' => [ 2, 3 ],
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                               ]
-                       );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $this->assertEquals(
-                       [ 2, 3 ],
-                       $store->updateNotificationTimestamp(
-                               $this->getMockNonAnonUserWithId( 1 ),
-                               new TitleValue( 0, 'SomeDbKey' ),
-                               '20151212010101'
-                       )
-               );
-       }
-
-       public function testUpdateNotificationTimestamp_noWatchers() {
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectFieldValues' )
-                       ->with(
-                               'watchlist',
-                               'wl_user',
-                               [
-                                       'wl_user != 1',
-                                       'wl_namespace' => 0,
-                                       'wl_title' => 'SomeDbKey',
-                                       'wl_notificationtimestamp IS NULL'
-                               ]
-                       )
-                       ->will(
-                               $this->returnValue( [] )
-                       );
-               $mockDb->expects( $this->never() )
-                       ->method( 'update' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->never() )->method( 'set' );
-               $mockCache->expects( $this->never() )->method( 'get' );
-               $mockCache->expects( $this->never() )->method( 'delete' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               $watchers = $store->updateNotificationTimestamp(
-                       $this->getMockNonAnonUserWithId( 1 ),
-                       new TitleValue( 0, 'SomeDbKey' ),
-                       '20151212010101'
-               );
-               $this->assertInternalType( 'array', $watchers );
-               $this->assertEmpty( $watchers );
-       }
-
-       public function testUpdateNotificationTimestamp_clearsCachedItems() {
-               $user = $this->getMockNonAnonUserWithId( 1 );
-               $titleValue = new TitleValue( 0, 'SomeDbKey' );
-
-               $mockDb = $this->getMockDb();
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectRow' )
-                       ->will( $this->returnValue(
-                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
-                       ) );
-               $mockDb->expects( $this->once() )
-                       ->method( 'selectFieldValues' )
-                       ->will(
-                               $this->returnValue( [ '2', '3' ] )
-                       );
-               $mockDb->expects( $this->once() )
-                       ->method( 'update' );
-
-               $mockCache = $this->getMockCache();
-               $mockCache->expects( $this->once() )
-                       ->method( 'set' )
-                       ->with( '0:SomeDbKey:1', $this->isType( 'object' ) );
-               $mockCache->expects( $this->once() )
-                       ->method( 'get' )
-                       ->with( '0:SomeDbKey:1' );
-               $mockCache->expects( $this->once() )
-                       ->method( 'delete' )
-                       ->with( '0:SomeDbKey:1' );
-
-               $store = $this->newWatchedItemStore(
-                       $this->getMockLoadBalancer( $mockDb ),
-                       $mockCache,
-                       $this->getMockReadOnlyMode()
-               );
-
-               // This will add the item to the cache
-               $store->getWatchedItem( $user, $titleValue );
-
-               $store->updateNotificationTimestamp(
-                       $this->getMockNonAnonUserWithId( 1 ),
-                       $titleValue,
-                       '20151212010101'
-               );
-       }
-
-}
diff --git a/tests/phpunit/includes/WatchedItemUnitTest.php b/tests/phpunit/includes/WatchedItemUnitTest.php
deleted file mode 100644 (file)
index 8897645..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php
-use MediaWiki\Linker\LinkTarget;
-
-/**
- * @author Addshore
- *
- * @covers WatchedItem
- */
-class WatchedItemUnitTest extends MediaWikiTestCase {
-
-       /**
-        * @param int $id
-        *
-        * @return PHPUnit_Framework_MockObject_MockObject|User
-        */
-       private function getMockUser( $id ) {
-               $user = $this->createMock( User::class );
-               $user->expects( $this->any() )
-                       ->method( 'getId' )
-                       ->will( $this->returnValue( $id ) );
-               $user->expects( $this->any() )
-                       ->method( 'isAllowed' )
-                       ->will( $this->returnValue( true ) );
-               return $user;
-       }
-
-       public function provideUserTitleTimestamp() {
-               $user = $this->getMockUser( 111 );
-               return [
-                       [ $user, Title::newFromText( 'SomeTitle' ), null ],
-                       [ $user, Title::newFromText( 'SomeTitle' ), '20150101010101' ],
-                       [ $user, new TitleValue( 0, 'TVTitle', 'frag' ), '20150101010101' ],
-               ];
-       }
-
-       /**
-        * @return PHPUnit_Framework_MockObject_MockObject|WatchedItemStore
-        */
-       private function getMockWatchedItemStore() {
-               return $this->getMockBuilder( WatchedItemStore::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-       }
-
-       /**
-        * @dataProvider provideUserTitleTimestamp
-        */
-       public function testConstruction( $user, LinkTarget $linkTarget, $notifTimestamp ) {
-               $item = new WatchedItem( $user, $linkTarget, $notifTimestamp );
-
-               $this->assertSame( $user, $item->getUser() );
-               $this->assertSame( $linkTarget, $item->getLinkTarget() );
-               $this->assertSame( $notifTimestamp, $item->getNotificationTimestamp() );
-
-               // The below tests the internal WatchedItem::getTitle method
-               $this->assertInstanceOf( 'Title', $item->getTitle() );
-               $this->assertSame( $linkTarget->getDBkey(), $item->getTitle()->getDBkey() );
-               $this->assertSame( $linkTarget->getFragment(), $item->getTitle()->getFragment() );
-               $this->assertSame( $linkTarget->getNamespace(), $item->getTitle()->getNamespace() );
-               $this->assertSame( $linkTarget->getText(), $item->getTitle()->getText() );
-       }
-
-       /**
-        * @dataProvider provideUserTitleTimestamp
-        */
-       public function testFromUserTitle( $user, $linkTarget, $timestamp ) {
-               $store = $this->getMockWatchedItemStore();
-               $store->expects( $this->once() )
-                       ->method( 'loadWatchedItem' )
-                       ->with( $user, $linkTarget )
-                       ->will( $this->returnValue( new WatchedItem( $user, $linkTarget, $timestamp ) ) );
-               $this->setService( 'WatchedItemStore', $store );
-
-               $item = WatchedItem::fromUserTitle( $user, $linkTarget, User::IGNORE_USER_RIGHTS );
-
-               $this->assertEquals( $user, $item->getUser() );
-               $this->assertEquals( $linkTarget, $item->getLinkTarget() );
-               $this->assertEquals( $timestamp, $item->getNotificationTimestamp() );
-       }
-
-       public function testAddWatch() {
-               $title = Title::newFromText( 'SomeTitle' );
-               $timestamp = null;
-               $checkRights = 0;
-
-               /** @var User|PHPUnit_Framework_MockObject_MockObject $user */
-               $user = $this->createMock( User::class );
-               $user->expects( $this->once() )
-                       ->method( 'addWatch' )
-                       ->with( $title, $checkRights );
-
-               $item = new WatchedItem( $user, $title, $timestamp, $checkRights );
-               $this->assertTrue( $item->addWatch() );
-       }
-
-       public function testRemoveWatch() {
-               $title = Title::newFromText( 'SomeTitle' );
-               $timestamp = null;
-               $checkRights = 0;
-
-               /** @var User|PHPUnit_Framework_MockObject_MockObject $user */
-               $user = $this->createMock( User::class );
-               $user->expects( $this->once() )
-                       ->method( 'removeWatch' )
-                       ->with( $title, $checkRights );
-
-               $item = new WatchedItem( $user, $title, $timestamp, $checkRights );
-               $this->assertTrue( $item->removeWatch() );
-       }
-
-       public function provideBooleans() {
-               return [
-                       [ true ],
-                       [ false ],
-               ];
-       }
-
-       /**
-        * @dataProvider provideBooleans
-        */
-       public function testIsWatched( $returnValue ) {
-               $title = Title::newFromText( 'SomeTitle' );
-               $timestamp = null;
-               $checkRights = 0;
-
-               /** @var User|PHPUnit_Framework_MockObject_MockObject $user */
-               $user = $this->createMock( User::class );
-               $user->expects( $this->once() )
-                       ->method( 'isWatched' )
-                       ->with( $title, $checkRights )
-                       ->will( $this->returnValue( $returnValue ) );
-
-               $item = new WatchedItem( $user, $title, $timestamp, $checkRights );
-               $this->assertEquals( $returnValue, $item->isWatched() );
-       }
-
-       public function testDuplicateEntries() {
-               $oldTitle = Title::newFromText( 'OldTitle' );
-               $newTitle = Title::newFromText( 'NewTitle' );
-
-               $store = $this->getMockWatchedItemStore();
-               $store->expects( $this->once() )
-                       ->method( 'duplicateAllAssociatedEntries' )
-                       ->with( $oldTitle, $newTitle );
-               $this->setService( 'WatchedItemStore', $store );
-
-               WatchedItem::duplicateEntries( $oldTitle, $newTitle );
-       }
-
-}
diff --git a/tests/phpunit/includes/watcheditem/WatchedItemIntegrationTest.php b/tests/phpunit/includes/watcheditem/WatchedItemIntegrationTest.php
new file mode 100644 (file)
index 0000000..01e7ecb
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+use MediaWiki\MediaWikiServices;
+
+/**
+ * @author Addshore
+ *
+ * @group Database
+ *
+ * @covers WatchedItem
+ */
+class WatchedItemIntegrationTest extends MediaWikiTestCase {
+
+       public function setUp() {
+               parent::setUp();
+               self::$users['WatchedItemIntegrationTestUser']
+                       = new TestUser( 'WatchedItemIntegrationTestUser' );
+
+               $this->hideDeprecated( 'WatchedItem::fromUserTitle' );
+               $this->hideDeprecated( 'WatchedItem::addWatch' );
+               $this->hideDeprecated( 'WatchedItem::removeWatch' );
+               $this->hideDeprecated( 'WatchedItem::isWatched' );
+               $this->hideDeprecated( 'WatchedItem::duplicateEntries' );
+               $this->hideDeprecated( 'WatchedItem::batchAddWatch' );
+       }
+
+       private function getUser() {
+               return self::$users['WatchedItemIntegrationTestUser']->getUser();
+       }
+
+       public function testWatchAndUnWatchItem() {
+               $user = $this->getUser();
+               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
+               // Cleanup after previous tests
+               WatchedItem::fromUserTitle( $user, $title )->removeWatch();
+
+               $this->assertFalse(
+                       WatchedItem::fromUserTitle( $user, $title )->isWatched(),
+                       'Page should not initially be watched'
+               );
+               WatchedItem::fromUserTitle( $user, $title )->addWatch();
+               $this->assertTrue(
+                       WatchedItem::fromUserTitle( $user, $title )->isWatched(),
+                       'Page should be watched'
+               );
+               WatchedItem::fromUserTitle( $user, $title )->removeWatch();
+               $this->assertFalse(
+                       WatchedItem::fromUserTitle( $user, $title )->isWatched(),
+                       'Page should be unwatched'
+               );
+       }
+
+       public function testUpdateAndResetNotificationTimestamp() {
+               $user = $this->getUser();
+               $otherUser = ( new TestUser( 'WatchedItemIntegrationTestUser_otherUser' ) )->getUser();
+               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
+               WatchedItem::fromUserTitle( $user, $title )->addWatch();
+               $this->assertNull( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
+
+               EmailNotification::updateWatchlistTimestamp( $otherUser, $title, '20150202010101' );
+               $this->assertEquals(
+                       '20150202010101',
+                       WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp()
+               );
+
+               MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp(
+                       $user, $title
+               );
+               $this->assertNull( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
+       }
+
+       public function testDuplicateAllAssociatedEntries() {
+               $user = $this->getUser();
+               $titleOld = Title::newFromText( 'WatchedItemIntegrationTestPageOld' );
+               $titleNew = Title::newFromText( 'WatchedItemIntegrationTestPageNew' );
+               WatchedItem::fromUserTitle( $user, $titleOld->getSubjectPage() )->addWatch();
+               WatchedItem::fromUserTitle( $user, $titleOld->getTalkPage() )->addWatch();
+               // Cleanup after previous tests
+               WatchedItem::fromUserTitle( $user, $titleNew->getSubjectPage() )->removeWatch();
+               WatchedItem::fromUserTitle( $user, $titleNew->getTalkPage() )->removeWatch();
+
+               WatchedItem::duplicateEntries( $titleOld, $titleNew );
+
+               $this->assertTrue(
+                       WatchedItem::fromUserTitle( $user, $titleOld->getSubjectPage() )->isWatched()
+               );
+               $this->assertTrue(
+                       WatchedItem::fromUserTitle( $user, $titleOld->getTalkPage() )->isWatched()
+               );
+               $this->assertTrue(
+                       WatchedItem::fromUserTitle( $user, $titleNew->getSubjectPage() )->isWatched()
+               );
+               $this->assertTrue(
+                       WatchedItem::fromUserTitle( $user, $titleNew->getTalkPage() )->isWatched()
+               );
+       }
+
+       public function testIsWatched_falseOnNotAllowed() {
+               $user = $this->getUser();
+               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
+               WatchedItem::fromUserTitle( $user, $title )->addWatch();
+
+               $this->assertTrue( WatchedItem::fromUserTitle( $user, $title )->isWatched() );
+               $user->mRights = [];
+               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->isWatched() );
+       }
+
+       public function testGetNotificationTimestamp_falseOnNotAllowed() {
+               $user = $this->getUser();
+               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
+               WatchedItem::fromUserTitle( $user, $title )->addWatch();
+               MediaWikiServices::getInstance()->getWatchedItemStore()->resetNotificationTimestamp(
+                       $user, $title
+               );
+
+               $this->assertEquals(
+                       null,
+                       WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp()
+               );
+               $user->mRights = [];
+               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
+       }
+
+       public function testRemoveWatch_falseOnNotAllowed() {
+               $user = $this->getUser();
+               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
+               WatchedItem::fromUserTitle( $user, $title )->addWatch();
+
+               $previousRights = $user->mRights;
+               $user->mRights = [];
+               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->removeWatch() );
+               $user->mRights = $previousRights;
+               $this->assertTrue( WatchedItem::fromUserTitle( $user, $title )->removeWatch() );
+       }
+
+       public function testGetNotificationTimestamp_falseOnNotWatched() {
+               $user = $this->getUser();
+               $title = Title::newFromText( 'WatchedItemIntegrationTestPage' );
+
+               WatchedItem::fromUserTitle( $user, $title )->removeWatch();
+               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->isWatched() );
+
+               $this->assertFalse( WatchedItem::fromUserTitle( $user, $title )->getNotificationTimestamp() );
+       }
+
+}
diff --git a/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php
new file mode 100644 (file)
index 0000000..62ba5f6
--- /dev/null
@@ -0,0 +1,1676 @@
+<?php
+
+use Wikimedia\ScopedCallback;
+use Wikimedia\TestingAccessWrapper;
+
+/**
+ * @covers WatchedItemQueryService
+ */
+class WatchedItemQueryServiceUnitTest extends PHPUnit_Framework_TestCase {
+
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|Database
+        */
+       private function getMockDb() {
+               $mock = $this->getMockBuilder( Database::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+
+               $mock->expects( $this->any() )
+                       ->method( 'makeList' )
+                       ->with(
+                               $this->isType( 'array' ),
+                               $this->isType( 'int' )
+                       )
+                       ->will( $this->returnCallback( function ( $a, $conj ) {
+                               $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
+                               return join( $sqlConj, array_map( function ( $s ) {
+                                       return '(' . $s . ')';
+                               }, $a
+                               ) );
+                       } ) );
+
+               $mock->expects( $this->any() )
+                       ->method( 'addQuotes' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return "'$value'";
+                       } ) );
+
+               $mock->expects( $this->any() )
+                       ->method( 'timestamp' )
+                       ->will( $this->returnArgument( 0 ) );
+
+               $mock->expects( $this->any() )
+                       ->method( 'bitAnd' )
+                       ->willReturnCallback( function ( $a, $b ) {
+                               return "($a & $b)";
+                       } );
+
+               return $mock;
+       }
+
+       /**
+        * @param PHPUnit_Framework_MockObject_MockObject|Database $mockDb
+        * @return PHPUnit_Framework_MockObject_MockObject|LoadBalancer
+        */
+       private function getMockLoadBalancer( $mockDb ) {
+               $mock = $this->getMockBuilder( LoadBalancer::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $mock->expects( $this->any() )
+                       ->method( 'getConnectionRef' )
+                       ->with( DB_REPLICA )
+                       ->will( $this->returnValue( $mockDb ) );
+               return $mock;
+       }
+
+       /**
+        * @param int $id
+        * @return PHPUnit_Framework_MockObject_MockObject|User
+        */
+       private function getMockNonAnonUserWithId( $id ) {
+               $mock = $this->getMockBuilder( User::class )->getMock();
+               $mock->expects( $this->any() )
+                       ->method( 'isAnon' )
+                       ->will( $this->returnValue( false ) );
+               $mock->expects( $this->any() )
+                       ->method( 'getId' )
+                       ->will( $this->returnValue( $id ) );
+               return $mock;
+       }
+
+       /**
+        * @param int $id
+        * @return PHPUnit_Framework_MockObject_MockObject|User
+        */
+       private function getMockUnrestrictedNonAnonUserWithId( $id ) {
+               $mock = $this->getMockNonAnonUserWithId( $id );
+               $mock->expects( $this->any() )
+                       ->method( 'isAllowed' )
+                       ->will( $this->returnValue( true ) );
+               $mock->expects( $this->any() )
+                       ->method( 'isAllowedAny' )
+                       ->will( $this->returnValue( true ) );
+               $mock->expects( $this->any() )
+                       ->method( 'useRCPatrol' )
+                       ->will( $this->returnValue( true ) );
+               return $mock;
+       }
+
+       /**
+        * @param int $id
+        * @param string $notAllowedAction
+        * @return PHPUnit_Framework_MockObject_MockObject|User
+        */
+       private function getMockNonAnonUserWithIdAndRestrictedPermissions( $id, $notAllowedAction ) {
+               $mock = $this->getMockNonAnonUserWithId( $id );
+
+               $mock->expects( $this->any() )
+                       ->method( 'isAllowed' )
+                       ->will( $this->returnCallback( function ( $action ) use ( $notAllowedAction ) {
+                               return $action !== $notAllowedAction;
+                       } ) );
+               $mock->expects( $this->any() )
+                       ->method( 'isAllowedAny' )
+                       ->will( $this->returnCallback( function () use ( $notAllowedAction ) {
+                               $actions = func_get_args();
+                               return !in_array( $notAllowedAction, $actions );
+                       } ) );
+
+               return $mock;
+       }
+
+       /**
+        * @param int $id
+        * @return PHPUnit_Framework_MockObject_MockObject|User
+        */
+       private function getMockNonAnonUserWithIdAndNoPatrolRights( $id ) {
+               $mock = $this->getMockNonAnonUserWithId( $id );
+
+               $mock->expects( $this->any() )
+                       ->method( 'isAllowed' )
+                       ->will( $this->returnValue( true ) );
+               $mock->expects( $this->any() )
+                       ->method( 'isAllowedAny' )
+                       ->will( $this->returnValue( true ) );
+
+               $mock->expects( $this->any() )
+                       ->method( 'useRCPatrol' )
+                       ->will( $this->returnValue( false ) );
+               $mock->expects( $this->any() )
+                       ->method( 'useNPPatrol' )
+                       ->will( $this->returnValue( false ) );
+
+               return $mock;
+       }
+
+       private function getMockAnonUser() {
+               $mock = $this->getMockBuilder( User::class )->getMock();
+               $mock->expects( $this->any() )
+                       ->method( 'isAnon' )
+                       ->will( $this->returnValue( true ) );
+               return $mock;
+       }
+
+       private function getFakeRow( array $rowValues ) {
+               $fakeRow = new stdClass();
+               foreach ( $rowValues as $valueName => $value ) {
+                       $fakeRow->$valueName = $value;
+               }
+               return $fakeRow;
+       }
+
+       public function testGetWatchedItemsWithRecentChangeInfo() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               [ 'recentchanges', 'watchlist', 'page' ],
+                               [
+                                       'rc_id',
+                                       'rc_namespace',
+                                       'rc_title',
+                                       'rc_timestamp',
+                                       'rc_type',
+                                       'rc_deleted',
+                                       'wl_notificationtimestamp',
+                                       'rc_cur_id',
+                                       'rc_this_oldid',
+                                       'rc_last_oldid',
+                               ],
+                               [
+                                       'wl_user' => 1,
+                                       '(rc_this_oldid=page_latest) OR (rc_type=3)',
+                               ],
+                               $this->isType( 'string' ),
+                               [
+                                       'LIMIT' => 3,
+                               ],
+                               [
+                                       'watchlist' => [
+                                               'INNER JOIN',
+                                               [
+                                                       'wl_namespace=rc_namespace',
+                                                       'wl_title=rc_title'
+                                               ]
+                                       ],
+                                       'page' => [
+                                               'LEFT JOIN',
+                                               'rc_cur_id=page_id',
+                                       ],
+                               ]
+                       )
+                       ->will( $this->returnValue( [
+                               $this->getFakeRow( [
+                                       'rc_id' => 1,
+                                       'rc_namespace' => 0,
+                                       'rc_title' => 'Foo1',
+                                       'rc_timestamp' => '20151212010101',
+                                       'rc_type' => RC_NEW,
+                                       'rc_deleted' => 0,
+                                       'wl_notificationtimestamp' => '20151212010101',
+                               ] ),
+                               $this->getFakeRow( [
+                                       'rc_id' => 2,
+                                       'rc_namespace' => 1,
+                                       'rc_title' => 'Foo2',
+                                       'rc_timestamp' => '20151212010102',
+                                       'rc_type' => RC_NEW,
+                                       'rc_deleted' => 0,
+                                       'wl_notificationtimestamp' => null,
+                               ] ),
+                               $this->getFakeRow( [
+                                       'rc_id' => 3,
+                                       'rc_namespace' => 1,
+                                       'rc_title' => 'Foo3',
+                                       'rc_timestamp' => '20151212010103',
+                                       'rc_type' => RC_NEW,
+                                       'rc_deleted' => 0,
+                                       'wl_notificationtimestamp' => null,
+                               ] ),
+                       ] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+
+               $startFrom = null;
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
+                       $user, [ 'limit' => 2 ], $startFrom
+               );
+
+               $this->assertInternalType( 'array', $items );
+               $this->assertCount( 2, $items );
+
+               foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) {
+                       $this->assertInstanceOf( WatchedItem::class, $watchedItem );
+                       $this->assertInternalType( 'array', $recentChangeInfo );
+               }
+
+               $this->assertEquals(
+                       new WatchedItem( $user, new TitleValue( 0, 'Foo1' ), '20151212010101' ),
+                       $items[0][0]
+               );
+               $this->assertEquals(
+                       [
+                               'rc_id' => 1,
+                               'rc_namespace' => 0,
+                               'rc_title' => 'Foo1',
+                               'rc_timestamp' => '20151212010101',
+                               'rc_type' => RC_NEW,
+                               'rc_deleted' => 0,
+                       ],
+                       $items[0][1]
+               );
+
+               $this->assertEquals(
+                       new WatchedItem( $user, new TitleValue( 1, 'Foo2' ), null ),
+                       $items[1][0]
+               );
+               $this->assertEquals(
+                       [
+                               'rc_id' => 2,
+                               'rc_namespace' => 1,
+                               'rc_title' => 'Foo2',
+                               'rc_timestamp' => '20151212010102',
+                               'rc_type' => RC_NEW,
+                               'rc_deleted' => 0,
+                       ],
+                       $items[1][1]
+               );
+
+               $this->assertEquals( [ '20151212010103', 3 ], $startFrom );
+       }
+
+       public function testGetWatchedItemsWithRecentChangeInfo_extension() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               [ 'recentchanges', 'watchlist', 'page', 'extension_dummy_table' ],
+                               [
+                                       'rc_id',
+                                       'rc_namespace',
+                                       'rc_title',
+                                       'rc_timestamp',
+                                       'rc_type',
+                                       'rc_deleted',
+                                       'wl_notificationtimestamp',
+                                       'rc_cur_id',
+                                       'rc_this_oldid',
+                                       'rc_last_oldid',
+                                       'extension_dummy_field',
+                               ],
+                               [
+                                       'wl_user' => 1,
+                                       '(rc_this_oldid=page_latest) OR (rc_type=3)',
+                                       'extension_dummy_cond',
+                               ],
+                               $this->isType( 'string' ),
+                               [
+                                       'extension_dummy_option',
+                               ],
+                               [
+                                       'watchlist' => [
+                                               'INNER JOIN',
+                                               [
+                                                       'wl_namespace=rc_namespace',
+                                                       'wl_title=rc_title'
+                                               ]
+                                       ],
+                                       'page' => [
+                                               'LEFT JOIN',
+                                               'rc_cur_id=page_id',
+                                       ],
+                                       'extension_dummy_join_cond' => [],
+                               ]
+                       )
+                       ->will( $this->returnValue( [
+                               $this->getFakeRow( [
+                                       'rc_id' => 1,
+                                       'rc_namespace' => 0,
+                                       'rc_title' => 'Foo1',
+                                       'rc_timestamp' => '20151212010101',
+                                       'rc_type' => RC_NEW,
+                                       'rc_deleted' => 0,
+                                       'wl_notificationtimestamp' => '20151212010101',
+                               ] ),
+                               $this->getFakeRow( [
+                                       'rc_id' => 2,
+                                       'rc_namespace' => 1,
+                                       'rc_title' => 'Foo2',
+                                       'rc_timestamp' => '20151212010102',
+                                       'rc_type' => RC_NEW,
+                                       'rc_deleted' => 0,
+                                       'wl_notificationtimestamp' => null,
+                               ] ),
+                       ] ) );
+
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+
+               $mockExtension = $this->getMockBuilder( WatchedItemQueryServiceExtension::class )
+                       ->getMock();
+               $mockExtension->expects( $this->once() )
+                       ->method( 'modifyWatchedItemsWithRCInfoQuery' )
+                       ->with(
+                               $this->identicalTo( $user ),
+                               $this->isType( 'array' ),
+                               $this->isInstanceOf( IDatabase::class ),
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' )
+                       )
+                       ->will( $this->returnCallback( function (
+                               $user, $options, $db, &$tables, &$fields, &$conds, &$dbOptions, &$joinConds
+                       ) {
+                               $tables[] = 'extension_dummy_table';
+                               $fields[] = 'extension_dummy_field';
+                               $conds[] = 'extension_dummy_cond';
+                               $dbOptions[] = 'extension_dummy_option';
+                               $joinConds['extension_dummy_join_cond'] = [];
+                       } ) );
+               $mockExtension->expects( $this->once() )
+                       ->method( 'modifyWatchedItemsWithRCInfo' )
+                       ->with(
+                               $this->identicalTo( $user ),
+                               $this->isType( 'array' ),
+                               $this->isInstanceOf( IDatabase::class ),
+                               $this->isType( 'array' ),
+                               $this->anything(),
+                               $this->anything() // Can't test for null here, PHPUnit applies this after the callback
+                       )
+                       ->will( $this->returnCallback( function ( $user, $options, $db, &$items, $res, &$startFrom ) {
+                               foreach ( $items as $i => &$item ) {
+                                       $item[1]['extension_dummy_field'] = $i;
+                               }
+                               unset( $item );
+
+                               $this->assertNull( $startFrom );
+                               $startFrom = [ '20160203123456', 42 ];
+                       } ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               TestingAccessWrapper::newFromObject( $queryService )->extensions = [ $mockExtension ];
+
+               $startFrom = null;
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
+                       $user, [], $startFrom
+               );
+
+               $this->assertInternalType( 'array', $items );
+               $this->assertCount( 2, $items );
+
+               foreach ( $items as list( $watchedItem, $recentChangeInfo ) ) {
+                       $this->assertInstanceOf( WatchedItem::class, $watchedItem );
+                       $this->assertInternalType( 'array', $recentChangeInfo );
+               }
+
+               $this->assertEquals(
+                       new WatchedItem( $user, new TitleValue( 0, 'Foo1' ), '20151212010101' ),
+                       $items[0][0]
+               );
+               $this->assertEquals(
+                       [
+                               'rc_id' => 1,
+                               'rc_namespace' => 0,
+                               'rc_title' => 'Foo1',
+                               'rc_timestamp' => '20151212010101',
+                               'rc_type' => RC_NEW,
+                               'rc_deleted' => 0,
+                               'extension_dummy_field' => 0,
+                       ],
+                       $items[0][1]
+               );
+
+               $this->assertEquals(
+                       new WatchedItem( $user, new TitleValue( 1, 'Foo2' ), null ),
+                       $items[1][0]
+               );
+               $this->assertEquals(
+                       [
+                               'rc_id' => 2,
+                               'rc_namespace' => 1,
+                               'rc_title' => 'Foo2',
+                               'rc_timestamp' => '20151212010102',
+                               'rc_type' => RC_NEW,
+                               'rc_deleted' => 0,
+                               'extension_dummy_field' => 1,
+                       ],
+                       $items[1][1]
+               );
+
+               $this->assertEquals( [ '20160203123456', 42 ], $startFrom );
+       }
+
+       public function getWatchedItemsWithRecentChangeInfoOptionsProvider() {
+               return [
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_FLAGS ] ],
+                               null,
+                               [],
+                               [ 'rc_type', 'rc_minor', 'rc_bot' ],
+                               [],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_USER ] ],
+                               null,
+                               [],
+                               [ 'rc_user_text' ],
+                               [],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_USER_ID ] ],
+                               null,
+                               [],
+                               [ 'rc_user' ],
+                               [],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_COMMENT ] ],
+                               null,
+                               [],
+                               [
+                                       'rc_comment_text' => 'rc_comment',
+                                       'rc_comment_data' => 'NULL',
+                                       'rc_comment_cid' => 'NULL',
+                               ],
+                               [],
+                               [],
+                               [],
+                               [ 'wgCommentTableSchemaMigrationStage' => MIGRATION_OLD ],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_COMMENT ] ],
+                               null,
+                               [ 'comment_rc_comment' => 'comment' ],
+                               [
+                                       'rc_comment_text' => 'COALESCE( comment_rc_comment.comment_text, rc_comment )',
+                                       'rc_comment_data' => 'comment_rc_comment.comment_data',
+                                       'rc_comment_cid' => 'comment_rc_comment.comment_id',
+                               ],
+                               [],
+                               [],
+                               [ 'comment_rc_comment' => [ 'LEFT JOIN', 'comment_rc_comment.comment_id = rc_comment_id' ] ],
+                               [ 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_BOTH ],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_COMMENT ] ],
+                               null,
+                               [ 'comment_rc_comment' => 'comment' ],
+                               [
+                                       'rc_comment_text' => 'COALESCE( comment_rc_comment.comment_text, rc_comment )',
+                                       'rc_comment_data' => 'comment_rc_comment.comment_data',
+                                       'rc_comment_cid' => 'comment_rc_comment.comment_id',
+                               ],
+                               [],
+                               [],
+                               [ 'comment_rc_comment' => [ 'LEFT JOIN', 'comment_rc_comment.comment_id = rc_comment_id' ] ],
+                               [ 'wgCommentTableSchemaMigrationStage' => MIGRATION_WRITE_NEW ],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_COMMENT ] ],
+                               null,
+                               [ 'comment_rc_comment' => 'comment' ],
+                               [
+                                       'rc_comment_text' => 'comment_rc_comment.comment_text',
+                                       'rc_comment_data' => 'comment_rc_comment.comment_data',
+                                       'rc_comment_cid' => 'comment_rc_comment.comment_id',
+                               ],
+                               [],
+                               [],
+                               [ 'comment_rc_comment' => [ 'JOIN', 'comment_rc_comment.comment_id = rc_comment_id' ] ],
+                               [ 'wgCommentTableSchemaMigrationStage' => MIGRATION_NEW ],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_PATROL_INFO ] ],
+                               null,
+                               [],
+                               [ 'rc_patrolled', 'rc_log_type' ],
+                               [],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_SIZES ] ],
+                               null,
+                               [],
+                               [ 'rc_old_len', 'rc_new_len' ],
+                               [],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'includeFields' => [ WatchedItemQueryService::INCLUDE_LOG_INFO ] ],
+                               null,
+                               [],
+                               [ 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ],
+                               [],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'namespaceIds' => [ 0, 1 ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'wl_namespace' => [ 0, 1 ] ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'namespaceIds' => [ 0, "1; DROP TABLE watchlist;\n--" ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'wl_namespace' => [ 0, 1 ] ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'rcTypes' => [ RC_EDIT, RC_NEW ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_type' => [ RC_EDIT, RC_NEW ] ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
+                               null,
+                               [],
+                               [],
+                               [],
+                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_NEWER ],
+                               null,
+                               [],
+                               [],
+                               [],
+                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_OLDER, 'start' => '20151212010101' ],
+                               null,
+                               [],
+                               [],
+                               [ "rc_timestamp <= '20151212010101'" ],
+                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_OLDER, 'end' => '20151212010101' ],
+                               null,
+                               [],
+                               [],
+                               [ "rc_timestamp >= '20151212010101'" ],
+                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
+                               [],
+                       ],
+                       [
+                               [
+                                       'dir' => WatchedItemQueryService::DIR_OLDER,
+                                       'start' => '20151212020101',
+                                       'end' => '20151212010101'
+                               ],
+                               null,
+                               [],
+                               [],
+                               [ "rc_timestamp <= '20151212020101'", "rc_timestamp >= '20151212010101'" ],
+                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_NEWER, 'start' => '20151212010101' ],
+                               null,
+                               [],
+                               [],
+                               [ "rc_timestamp >= '20151212010101'" ],
+                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_NEWER, 'end' => '20151212010101' ],
+                               null,
+                               [],
+                               [],
+                               [ "rc_timestamp <= '20151212010101'" ],
+                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
+                               [],
+                       ],
+                       [
+                               [
+                                       'dir' => WatchedItemQueryService::DIR_NEWER,
+                                       'start' => '20151212010101',
+                                       'end' => '20151212020101'
+                               ],
+                               null,
+                               [],
+                               [],
+                               [ "rc_timestamp >= '20151212010101'", "rc_timestamp <= '20151212020101'" ],
+                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'limit' => 10 ],
+                               null,
+                               [],
+                               [],
+                               [],
+                               [ 'LIMIT' => 11 ],
+                               [],
+                       ],
+                       [
+                               [ 'limit' => "10; DROP TABLE watchlist;\n--" ],
+                               null,
+                               [],
+                               [],
+                               [],
+                               [ 'LIMIT' => 11 ],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_MINOR ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_minor != 0' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_MINOR ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_minor = 0' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_BOT ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_bot != 0' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_BOT ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_bot = 0' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_ANON ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_user = 0' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_ANON ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_user != 0' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_PATROLLED ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_patrolled != 0' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_PATROLLED ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_patrolled = 0' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_UNREAD ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_timestamp >= wl_notificationtimestamp' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'filters' => [ WatchedItemQueryService::FILTER_NOT_UNREAD ] ],
+                               null,
+                               [],
+                               [],
+                               [ 'wl_notificationtimestamp IS NULL OR rc_timestamp < wl_notificationtimestamp' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'onlyByUser' => 'SomeOtherUser' ],
+                               null,
+                               [],
+                               [],
+                               [ 'rc_user_text' => 'SomeOtherUser' ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'notByUser' => 'SomeOtherUser' ],
+                               null,
+                               [],
+                               [],
+                               [ "rc_user_text != 'SomeOtherUser'" ],
+                               [],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
+                               [ '20151212010101', 123 ],
+                               [],
+                               [],
+                               [
+                                       "(rc_timestamp < '20151212010101') OR ((rc_timestamp = '20151212010101') AND (rc_id <= 123))"
+                               ],
+                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_NEWER ],
+                               [ '20151212010101', 123 ],
+                               [],
+                               [],
+                               [
+                                       "(rc_timestamp > '20151212010101') OR ((rc_timestamp = '20151212010101') AND (rc_id >= 123))"
+                               ],
+                               [ 'ORDER BY' => [ 'rc_timestamp', 'rc_id' ] ],
+                               [],
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
+                               [ '20151212010101', "123; DROP TABLE watchlist;\n--" ],
+                               [],
+                               [],
+                               [
+                                       "(rc_timestamp < '20151212010101') OR ((rc_timestamp = '20151212010101') AND (rc_id <= 123))"
+                               ],
+                               [ 'ORDER BY' => [ 'rc_timestamp DESC', 'rc_id DESC' ] ],
+                               [],
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider getWatchedItemsWithRecentChangeInfoOptionsProvider
+        */
+       public function testGetWatchedItemsWithRecentChangeInfo_optionsAndEmptyResult(
+               array $options,
+               $startFrom,
+               array $expectedExtraTables,
+               array $expectedExtraFields,
+               array $expectedExtraConds,
+               array $expectedDbOptions,
+               array $expectedExtraJoinConds,
+               array $globals = []
+       ) {
+               // Sigh. This test class doesn't extend MediaWikiTestCase, so we have to reinvent setMwGlobals().
+               if ( $globals ) {
+                       $resetGlobals = [];
+                       foreach ( $globals as $k => $v ) {
+                               $resetGlobals[$k] = $GLOBALS[$k];
+                               $GLOBALS[$k] = $v;
+                       }
+                       $reset = new ScopedCallback( function () use ( $resetGlobals ) {
+                               foreach ( $resetGlobals as $k => $v ) {
+                                       $GLOBALS[$k] = $v;
+                               }
+                       } );
+               }
+
+               $expectedTables = array_merge( [ 'recentchanges', 'watchlist', 'page' ], $expectedExtraTables );
+               $expectedFields = array_merge(
+                       [
+                               'rc_id',
+                               'rc_namespace',
+                               'rc_title',
+                               'rc_timestamp',
+                               'rc_type',
+                               'rc_deleted',
+                               'wl_notificationtimestamp',
+
+                               'rc_cur_id',
+                               'rc_this_oldid',
+                               'rc_last_oldid',
+                       ],
+                       $expectedExtraFields
+               );
+               $expectedConds = array_merge(
+                       [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)', ],
+                       $expectedExtraConds
+               );
+               $expectedJoinConds = array_merge(
+                       [
+                               'watchlist' => [
+                                       'INNER JOIN',
+                                       [
+                                               'wl_namespace=rc_namespace',
+                                               'wl_title=rc_title'
+                                       ]
+                               ],
+                               'page' => [
+                                       'LEFT JOIN',
+                                       'rc_cur_id=page_id',
+                               ],
+                       ],
+                       $expectedExtraJoinConds
+               );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               $expectedTables,
+                               $expectedFields,
+                               $expectedConds,
+                               $this->isType( 'string' ),
+                               $expectedDbOptions,
+                               $expectedJoinConds
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo( $user, $options, $startFrom );
+
+               $this->assertEmpty( $items );
+               $this->assertNull( $startFrom );
+       }
+
+       public function filterPatrolledOptionProvider() {
+               return [
+                       [ WatchedItemQueryService::FILTER_PATROLLED ],
+                       [ WatchedItemQueryService::FILTER_NOT_PATROLLED ],
+               ];
+       }
+
+       /**
+        * @dataProvider filterPatrolledOptionProvider
+        */
+       public function testGetWatchedItemsWithRecentChangeInfo_filterPatrolledAndUserWithNoPatrolRights(
+               $filtersOption
+       ) {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               [ 'recentchanges', 'watchlist', 'page' ],
+                               $this->isType( 'array' ),
+                               [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)' ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' )
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $user = $this->getMockNonAnonUserWithIdAndNoPatrolRights( 1 );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
+                       $user,
+                       [ 'filters' => [ $filtersOption ] ]
+               );
+
+               $this->assertEmpty( $items );
+       }
+
+       public function mysqlIndexOptimizationProvider() {
+               return [
+                       [
+                               'mysql',
+                               [],
+                               [ "rc_timestamp > ''" ],
+                       ],
+                       [
+                               'mysql',
+                               [ 'start' => '20151212010101', 'dir' => WatchedItemQueryService::DIR_OLDER ],
+                               [ "rc_timestamp <= '20151212010101'" ],
+                       ],
+                       [
+                               'mysql',
+                               [ 'end' => '20151212010101', 'dir' => WatchedItemQueryService::DIR_OLDER ],
+                               [ "rc_timestamp >= '20151212010101'" ],
+                       ],
+                       [
+                               'postgres',
+                               [],
+                               [],
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider mysqlIndexOptimizationProvider
+        */
+       public function testGetWatchedItemsWithRecentChangeInfo_mysqlIndexOptimization(
+               $dbType,
+               array $options,
+               array $expectedExtraConds
+       ) {
+               $commonConds = [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)' ];
+               $conds = array_merge( $commonConds, $expectedExtraConds );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               [ 'recentchanges', 'watchlist', 'page' ],
+                               $this->isType( 'array' ),
+                               $conds,
+                               $this->isType( 'string' ),
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' )
+                       )
+                       ->will( $this->returnValue( [] ) );
+               $mockDb->expects( $this->any() )
+                       ->method( 'getType' )
+                       ->will( $this->returnValue( $dbType ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo( $user, $options );
+
+               $this->assertEmpty( $items );
+       }
+
+       public function userPermissionRelatedExtraChecksProvider() {
+               return [
+                       [
+                               [],
+                               'deletedhistory',
+                               [
+                                       '(rc_type != ' . RC_LOG . ') OR ((rc_deleted & ' . LogPage::DELETED_ACTION . ') != ' .
+                                               LogPage::DELETED_ACTION . ')'
+                               ],
+                       ],
+                       [
+                               [],
+                               'suppressrevision',
+                               [
+                                       '(rc_type != ' . RC_LOG . ') OR (' .
+                                               '(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
+                                               ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
+                               ],
+                       ],
+                       [
+                               [],
+                               'viewsuppressed',
+                               [
+                                       '(rc_type != ' . RC_LOG . ') OR (' .
+                                               '(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
+                                               ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
+                               ],
+                       ],
+                       [
+                               [ 'onlyByUser' => 'SomeOtherUser' ],
+                               'deletedhistory',
+                               [
+                                       'rc_user_text' => 'SomeOtherUser',
+                                       '(rc_deleted & ' . Revision::DELETED_USER . ') != ' . Revision::DELETED_USER,
+                                       '(rc_type != ' . RC_LOG . ') OR ((rc_deleted & ' . LogPage::DELETED_ACTION . ') != ' .
+                                               LogPage::DELETED_ACTION . ')'
+                               ],
+                       ],
+                       [
+                               [ 'onlyByUser' => 'SomeOtherUser' ],
+                               'suppressrevision',
+                               [
+                                       'rc_user_text' => 'SomeOtherUser',
+                                       '(rc_deleted & ' . ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ) . ') != ' .
+                                               ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ),
+                                       '(rc_type != ' . RC_LOG . ') OR (' .
+                                               '(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
+                                               ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
+                               ],
+                       ],
+                       [
+                               [ 'onlyByUser' => 'SomeOtherUser' ],
+                               'viewsuppressed',
+                               [
+                                       'rc_user_text' => 'SomeOtherUser',
+                                       '(rc_deleted & ' . ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ) . ') != ' .
+                                               ( Revision::DELETED_USER | Revision::DELETED_RESTRICTED ),
+                                       '(rc_type != ' . RC_LOG . ') OR (' .
+                                               '(rc_deleted & ' . ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ') != ' .
+                                               ( LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED ) . ')'
+                               ],
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider userPermissionRelatedExtraChecksProvider
+        */
+       public function testGetWatchedItemsWithRecentChangeInfo_userPermissionRelatedExtraChecks(
+               array $options,
+               $notAllowedAction,
+               array $expectedExtraConds
+       ) {
+               $commonConds = [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)' ];
+               $conds = array_merge( $commonConds, $expectedExtraConds );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               [ 'recentchanges', 'watchlist', 'page' ],
+                               $this->isType( 'array' ),
+                               $conds,
+                               $this->isType( 'string' ),
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' )
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $user = $this->getMockNonAnonUserWithIdAndRestrictedPermissions( 1, $notAllowedAction );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo( $user, $options );
+
+               $this->assertEmpty( $items );
+       }
+
+       public function testGetWatchedItemsWithRecentChangeInfo_allRevisionsOptionAndEmptyResult() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               [ 'recentchanges', 'watchlist' ],
+                               [
+                                       'rc_id',
+                                       'rc_namespace',
+                                       'rc_title',
+                                       'rc_timestamp',
+                                       'rc_type',
+                                       'rc_deleted',
+                                       'wl_notificationtimestamp',
+
+                                       'rc_cur_id',
+                                       'rc_this_oldid',
+                                       'rc_last_oldid',
+                               ],
+                               [ 'wl_user' => 1, ],
+                               $this->isType( 'string' ),
+                               [],
+                               [
+                                       'watchlist' => [
+                                               'INNER JOIN',
+                                               [
+                                                       'wl_namespace=rc_namespace',
+                                                       'wl_title=rc_title'
+                                               ]
+                                       ],
+                               ]
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo( $user, [ 'allRevisions' => true ] );
+
+               $this->assertEmpty( $items );
+       }
+
+       public function getWatchedItemsWithRecentChangeInfoInvalidOptionsProvider() {
+               return [
+                       [
+                               [ 'rcTypes' => [ 1337 ] ],
+                               null,
+                               'Bad value for parameter $options[\'rcTypes\']',
+                       ],
+                       [
+                               [ 'rcTypes' => [ 'edit' ] ],
+                               null,
+                               'Bad value for parameter $options[\'rcTypes\']',
+                       ],
+                       [
+                               [ 'rcTypes' => [ RC_EDIT, 1337 ] ],
+                               null,
+                               'Bad value for parameter $options[\'rcTypes\']',
+                       ],
+                       [
+                               [ 'dir' => 'foo' ],
+                               null,
+                               'Bad value for parameter $options[\'dir\']',
+                       ],
+                       [
+                               [ 'start' => '20151212010101' ],
+                               null,
+                               'Bad value for parameter $options[\'dir\']: must be provided',
+                       ],
+                       [
+                               [ 'end' => '20151212010101' ],
+                               null,
+                               'Bad value for parameter $options[\'dir\']: must be provided',
+                       ],
+                       [
+                               [],
+                               [ '20151212010101', 123 ],
+                               'Bad value for parameter $options[\'dir\']: must be provided',
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
+                               '20151212010101',
+                               'Bad value for parameter $startFrom: must be a two-element array',
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
+                               [ '20151212010101' ],
+                               'Bad value for parameter $startFrom: must be a two-element array',
+                       ],
+                       [
+                               [ 'dir' => WatchedItemQueryService::DIR_OLDER ],
+                               [ '20151212010101', 123, 'foo' ],
+                               'Bad value for parameter $startFrom: must be a two-element array',
+                       ],
+                       [
+                               [ 'watchlistOwner' => $this->getMockUnrestrictedNonAnonUserWithId( 2 ) ],
+                               null,
+                               'Bad value for parameter $options[\'watchlistOwnerToken\']',
+                       ],
+                       [
+                               [ 'watchlistOwner' => 'Other User', 'watchlistOwnerToken' => 'some-token' ],
+                               null,
+                               'Bad value for parameter $options[\'watchlistOwner\']',
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider getWatchedItemsWithRecentChangeInfoInvalidOptionsProvider
+        */
+       public function testGetWatchedItemsWithRecentChangeInfo_invalidOptions(
+               array $options,
+               $startFrom,
+               $expectedInExceptionMessage
+       ) {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( $this->anything() );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+
+               $this->setExpectedException( InvalidArgumentException::class, $expectedInExceptionMessage );
+               $queryService->getWatchedItemsWithRecentChangeInfo( $user, $options, $startFrom );
+       }
+
+       public function testGetWatchedItemsWithRecentChangeInfo_usedInGeneratorOptionAndEmptyResult() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               [ 'recentchanges', 'watchlist', 'page' ],
+                               [
+                                       'rc_id',
+                                       'rc_namespace',
+                                       'rc_title',
+                                       'rc_timestamp',
+                                       'rc_type',
+                                       'rc_deleted',
+                                       'wl_notificationtimestamp',
+                                       'rc_cur_id',
+                               ],
+                               [ 'wl_user' => 1, '(rc_this_oldid=page_latest) OR (rc_type=3)' ],
+                               $this->isType( 'string' ),
+                               [],
+                               [
+                                       'watchlist' => [
+                                               'INNER JOIN',
+                                               [
+                                                       'wl_namespace=rc_namespace',
+                                                       'wl_title=rc_title'
+                                               ]
+                                       ],
+                                       'page' => [
+                                               'LEFT JOIN',
+                                               'rc_cur_id=page_id',
+                                       ],
+                               ]
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
+                       $user,
+                       [ 'usedInGenerator' => true ]
+               );
+
+               $this->assertEmpty( $items );
+       }
+
+       public function testGetWatchedItemsWithRecentChangeInfo_usedInGeneratorAllRevisionsOptions() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               [ 'recentchanges', 'watchlist' ],
+                               [
+                                       'rc_id',
+                                       'rc_namespace',
+                                       'rc_title',
+                                       'rc_timestamp',
+                                       'rc_type',
+                                       'rc_deleted',
+                                       'wl_notificationtimestamp',
+                                       'rc_this_oldid',
+                               ],
+                               [ 'wl_user' => 1 ],
+                               $this->isType( 'string' ),
+                               [],
+                               [
+                                       'watchlist' => [
+                                               'INNER JOIN',
+                                               [
+                                                       'wl_namespace=rc_namespace',
+                                                       'wl_title=rc_title'
+                                               ]
+                                       ],
+                               ]
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
+                       $user,
+                       [ 'usedInGenerator' => true, 'allRevisions' => true, ]
+               );
+
+               $this->assertEmpty( $items );
+       }
+
+       public function testGetWatchedItemsWithRecentChangeInfo_watchlistOwnerOptionAndEmptyResult() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' ),
+                               [
+                                       'wl_user' => 2,
+                                       '(rc_this_oldid=page_latest) OR (rc_type=3)',
+                               ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'array' ),
+                               $this->isType( 'array' )
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+               $otherUser = $this->getMockUnrestrictedNonAnonUserWithId( 2 );
+               $otherUser->expects( $this->once() )
+                       ->method( 'getOption' )
+                       ->with( 'watchlisttoken' )
+                       ->willReturn( '0123456789abcdef' );
+
+               $items = $queryService->getWatchedItemsWithRecentChangeInfo(
+                       $user,
+                       [ 'watchlistOwner' => $otherUser, 'watchlistOwnerToken' => '0123456789abcdef' ]
+               );
+
+               $this->assertEmpty( $items );
+       }
+
+       public function invalidWatchlistTokenProvider() {
+               return [
+                       [ 'wrongToken' ],
+                       [ '' ],
+               ];
+       }
+
+       /**
+        * @dataProvider invalidWatchlistTokenProvider
+        */
+       public function testGetWatchedItemsWithRecentChangeInfo_watchlistOwnerAndInvalidToken( $token ) {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( $this->anything() );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockUnrestrictedNonAnonUserWithId( 1 );
+               $otherUser = $this->getMockUnrestrictedNonAnonUserWithId( 2 );
+               $otherUser->expects( $this->once() )
+                       ->method( 'getOption' )
+                       ->with( 'watchlisttoken' )
+                       ->willReturn( '0123456789abcdef' );
+
+               $this->setExpectedException( ApiUsageException::class, 'Incorrect watchlist token provided' );
+               $queryService->getWatchedItemsWithRecentChangeInfo(
+                       $user,
+                       [ 'watchlistOwner' => $otherUser, 'watchlistOwnerToken' => $token ]
+               );
+       }
+
+       public function testGetWatchedItemsForUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                               [ 'wl_user' => 1 ]
+                       )
+                       ->will( $this->returnValue( [
+                               $this->getFakeRow( [
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'Foo1',
+                                       'wl_notificationtimestamp' => '20151212010101',
+                               ] ),
+                               $this->getFakeRow( [
+                                       'wl_namespace' => 1,
+                                       'wl_title' => 'Foo2',
+                                       'wl_notificationtimestamp' => null,
+                               ] ),
+                       ] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $items = $queryService->getWatchedItemsForUser( $user );
+
+               $this->assertInternalType( 'array', $items );
+               $this->assertCount( 2, $items );
+               $this->assertContainsOnlyInstancesOf( WatchedItem::class, $items );
+               $this->assertEquals(
+                       new WatchedItem( $user, new TitleValue( 0, 'Foo1' ), '20151212010101' ),
+                       $items[0]
+               );
+               $this->assertEquals(
+                       new WatchedItem( $user, new TitleValue( 1, 'Foo2' ), null ),
+                       $items[1]
+               );
+       }
+
+       public function provideGetWatchedItemsForUserOptions() {
+               return [
+                       [
+                               [ 'namespaceIds' => [ 0, 1 ], ],
+                               [ 'wl_namespace' => [ 0, 1 ], ],
+                               []
+                       ],
+                       [
+                               [ 'sort' => WatchedItemQueryService::SORT_ASC, ],
+                               [],
+                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
+                       ],
+                       [
+                               [
+                                       'namespaceIds' => [ 0 ],
+                                       'sort' => WatchedItemQueryService::SORT_ASC,
+                               ],
+                               [ 'wl_namespace' => [ 0 ], ],
+                               [ 'ORDER BY' => 'wl_title ASC' ]
+                       ],
+                       [
+                               [ 'limit' => 10 ],
+                               [],
+                               [ 'LIMIT' => 10 ]
+                       ],
+                       [
+                               [
+                                       'namespaceIds' => [ 0, "1; DROP TABLE watchlist;\n--" ],
+                                       'limit' => "10; DROP TABLE watchlist;\n--",
+                               ],
+                               [ 'wl_namespace' => [ 0, 1 ], ],
+                               [ 'LIMIT' => 10 ]
+                       ],
+                       [
+                               [ 'filter' => WatchedItemQueryService::FILTER_CHANGED ],
+                               [ 'wl_notificationtimestamp IS NOT NULL' ],
+                               []
+                       ],
+                       [
+                               [ 'filter' => WatchedItemQueryService::FILTER_NOT_CHANGED ],
+                               [ 'wl_notificationtimestamp IS NULL' ],
+                               []
+                       ],
+                       [
+                               [ 'sort' => WatchedItemQueryService::SORT_DESC, ],
+                               [],
+                               [ 'ORDER BY' => [ 'wl_namespace DESC', 'wl_title DESC' ] ]
+                       ],
+                       [
+                               [
+                                       'namespaceIds' => [ 0 ],
+                                       'sort' => WatchedItemQueryService::SORT_DESC,
+                               ],
+                               [ 'wl_namespace' => [ 0 ], ],
+                               [ 'ORDER BY' => 'wl_title DESC' ]
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetWatchedItemsForUserOptions
+        */
+       public function testGetWatchedItemsForUser_optionsAndEmptyResult(
+               array $options,
+               array $expectedConds,
+               array $expectedDbOptions
+       ) {
+               $mockDb = $this->getMockDb();
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $expectedConds = array_merge( [ 'wl_user' => 1 ], $expectedConds );
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                               $expectedConds,
+                               $this->isType( 'string' ),
+                               $expectedDbOptions
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+
+               $items = $queryService->getWatchedItemsForUser( $user, $options );
+               $this->assertEmpty( $items );
+       }
+
+       public function provideGetWatchedItemsForUser_fromUntilStartFromOptions() {
+               return [
+                       [
+                               [
+                                       'from' => new TitleValue( 0, 'SomeDbKey' ),
+                                       'sort' => WatchedItemQueryService::SORT_ASC
+                               ],
+                               [ "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'SomeDbKey'))", ],
+                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
+                       ],
+                       [
+                               [
+                                       'from' => new TitleValue( 0, 'SomeDbKey' ),
+                                       'sort' => WatchedItemQueryService::SORT_DESC,
+                               ],
+                               [ "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeDbKey'))", ],
+                               [ 'ORDER BY' => [ 'wl_namespace DESC', 'wl_title DESC' ] ]
+                       ],
+                       [
+                               [
+                                       'until' => new TitleValue( 0, 'SomeDbKey' ),
+                                       'sort' => WatchedItemQueryService::SORT_ASC
+                               ],
+                               [ "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeDbKey'))", ],
+                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
+                       ],
+                       [
+                               [
+                                       'until' => new TitleValue( 0, 'SomeDbKey' ),
+                                       'sort' => WatchedItemQueryService::SORT_DESC
+                               ],
+                               [ "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'SomeDbKey'))", ],
+                               [ 'ORDER BY' => [ 'wl_namespace DESC', 'wl_title DESC' ] ]
+                       ],
+                       [
+                               [
+                                       'from' => new TitleValue( 0, 'AnotherDbKey' ),
+                                       'until' => new TitleValue( 0, 'SomeOtherDbKey' ),
+                                       'startFrom' => new TitleValue( 0, 'SomeDbKey' ),
+                                       'sort' => WatchedItemQueryService::SORT_ASC
+                               ],
+                               [
+                                       "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'AnotherDbKey'))",
+                                       "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeOtherDbKey'))",
+                                       "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'SomeDbKey'))",
+                               ],
+                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
+                       ],
+                       [
+                               [
+                                       'from' => new TitleValue( 0, 'SomeOtherDbKey' ),
+                                       'until' => new TitleValue( 0, 'AnotherDbKey' ),
+                                       'startFrom' => new TitleValue( 0, 'SomeDbKey' ),
+                                       'sort' => WatchedItemQueryService::SORT_DESC
+                               ],
+                               [
+                                       "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeOtherDbKey'))",
+                                       "(wl_namespace > 0) OR ((wl_namespace = 0) AND (wl_title >= 'AnotherDbKey'))",
+                                       "(wl_namespace < 0) OR ((wl_namespace = 0) AND (wl_title <= 'SomeDbKey'))",
+                               ],
+                               [ 'ORDER BY' => [ 'wl_namespace DESC', 'wl_title DESC' ] ]
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideGetWatchedItemsForUser_fromUntilStartFromOptions
+        */
+       public function testGetWatchedItemsForUser_fromUntilStartFromOptions(
+               array $options,
+               array $expectedConds,
+               array $expectedDbOptions
+       ) {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $expectedConds = array_merge( [ 'wl_user' => 1 ], $expectedConds );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->any() )
+                       ->method( 'addQuotes' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return "'$value'";
+                       } ) );
+               $mockDb->expects( $this->any() )
+                       ->method( 'makeList' )
+                       ->with(
+                               $this->isType( 'array' ),
+                               $this->isType( 'int' )
+                       )
+                       ->will( $this->returnCallback( function ( $a, $conj ) {
+                               $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
+                               return join( $sqlConj, array_map( function ( $s ) {
+                                       return '(' . $s . ')';
+                               }, $a
+                               ) );
+                       } ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                               $expectedConds,
+                               $this->isType( 'string' ),
+                               $expectedDbOptions
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+
+               $items = $queryService->getWatchedItemsForUser( $user, $options );
+               $this->assertEmpty( $items );
+       }
+
+       public function getWatchedItemsForUserInvalidOptionsProvider() {
+               return [
+                       [
+                               [ 'sort' => 'foo' ],
+                               'Bad value for parameter $options[\'sort\']'
+                       ],
+                       [
+                               [ 'filter' => 'foo' ],
+                               'Bad value for parameter $options[\'filter\']'
+                       ],
+                       [
+                               [ 'from' => new TitleValue( 0, 'SomeDbKey' ), ],
+                               'Bad value for parameter $options[\'sort\']: must be provided'
+                       ],
+                       [
+                               [ 'until' => new TitleValue( 0, 'SomeDbKey' ), ],
+                               'Bad value for parameter $options[\'sort\']: must be provided'
+                       ],
+                       [
+                               [ 'startFrom' => new TitleValue( 0, 'SomeDbKey' ), ],
+                               'Bad value for parameter $options[\'sort\']: must be provided'
+                       ],
+               ];
+       }
+
+       /**
+        * @dataProvider getWatchedItemsForUserInvalidOptionsProvider
+        */
+       public function testGetWatchedItemsForUser_invalidOptionThrowsException(
+               array $options,
+               $expectedInExceptionMessage
+       ) {
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $this->getMockDb() ) );
+
+               $this->setExpectedException( InvalidArgumentException::class, $expectedInExceptionMessage );
+               $queryService->getWatchedItemsForUser( $this->getMockNonAnonUserWithId( 1 ), $options );
+       }
+
+       public function testGetWatchedItemsForUser_userNotAllowedToViewWatchlist() {
+               $mockDb = $this->getMockDb();
+
+               $mockDb->expects( $this->never() )
+                       ->method( $this->anything() );
+
+               $queryService = new WatchedItemQueryService( $this->getMockLoadBalancer( $mockDb ) );
+
+               $items = $queryService->getWatchedItemsForUser( $this->getMockAnonUser() );
+               $this->assertEmpty( $items );
+       }
+
+}
diff --git a/tests/phpunit/includes/watcheditem/WatchedItemStoreIntegrationTest.php b/tests/phpunit/includes/watcheditem/WatchedItemStoreIntegrationTest.php
new file mode 100644 (file)
index 0000000..61b62aa
--- /dev/null
@@ -0,0 +1,214 @@
+<?php
+
+use MediaWiki\MediaWikiServices;
+
+/**
+ * @author Addshore
+ *
+ * @group Database
+ *
+ * @covers WatchedItemStore
+ */
+class WatchedItemStoreIntegrationTest extends MediaWikiTestCase {
+
+       public function setUp() {
+               parent::setUp();
+               self::$users['WatchedItemStoreIntegrationTestUser']
+                       = new TestUser( 'WatchedItemStoreIntegrationTestUser' );
+       }
+
+       private function getUser() {
+               return self::$users['WatchedItemStoreIntegrationTestUser']->getUser();
+       }
+
+       public function testWatchAndUnWatchItem() {
+               $user = $this->getUser();
+               $title = Title::newFromText( 'WatchedItemStoreIntegrationTestPage' );
+               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+               // Cleanup after previous tests
+               $store->removeWatch( $user, $title );
+               $initialWatchers = $store->countWatchers( $title );
+               $initialUserWatchedItems = $store->countWatchedItems( $user );
+
+               $this->assertFalse(
+                       $store->isWatched( $user, $title ),
+                       'Page should not initially be watched'
+               );
+
+               $store->addWatch( $user, $title );
+               $this->assertTrue(
+                       $store->isWatched( $user, $title ),
+                       'Page should be watched'
+               );
+               $this->assertEquals( $initialUserWatchedItems + 1, $store->countWatchedItems( $user ) );
+               $watchedItemsForUser = $store->getWatchedItemsForUser( $user );
+               $this->assertCount( $initialUserWatchedItems + 1, $watchedItemsForUser );
+               $watchedItemsForUserHasExpectedItem = false;
+               foreach ( $watchedItemsForUser as $watchedItem ) {
+                       if (
+                               $watchedItem->getUser()->equals( $user ) &&
+                               $watchedItem->getLinkTarget() == $title->getTitleValue()
+                       ) {
+                               $watchedItemsForUserHasExpectedItem = true;
+                       }
+               }
+               $this->assertTrue(
+                       $watchedItemsForUserHasExpectedItem,
+                       'getWatchedItemsForUser should contain the page'
+               );
+               $this->assertEquals( $initialWatchers + 1, $store->countWatchers( $title ) );
+               $this->assertEquals(
+                       $initialWatchers + 1,
+                       $store->countWatchersMultiple( [ $title ] )[$title->getNamespace()][$title->getDBkey()]
+               );
+               $this->assertEquals(
+                       [ 0 => [ 'WatchedItemStoreIntegrationTestPage' => $initialWatchers + 1 ] ],
+                       $store->countWatchersMultiple( [ $title ], [ 'minimumWatchers' => $initialWatchers + 1 ] )
+               );
+               $this->assertEquals(
+                       [ 0 => [ 'WatchedItemStoreIntegrationTestPage' => 0 ] ],
+                       $store->countWatchersMultiple( [ $title ], [ 'minimumWatchers' => $initialWatchers + 2 ] )
+               );
+               $this->assertEquals(
+                       [ $title->getNamespace() => [ $title->getDBkey() => null ] ],
+                       $store->getNotificationTimestampsBatch( $user, [ $title ] )
+               );
+
+               $store->removeWatch( $user, $title );
+               $this->assertFalse(
+                       $store->isWatched( $user, $title ),
+                       'Page should be unwatched'
+               );
+               $this->assertEquals( $initialUserWatchedItems, $store->countWatchedItems( $user ) );
+               $watchedItemsForUser = $store->getWatchedItemsForUser( $user );
+               $this->assertCount( $initialUserWatchedItems, $watchedItemsForUser );
+               $watchedItemsForUserHasExpectedItem = false;
+               foreach ( $watchedItemsForUser as $watchedItem ) {
+                       if (
+                               $watchedItem->getUser()->equals( $user ) &&
+                               $watchedItem->getLinkTarget() == $title->getTitleValue()
+                       ) {
+                               $watchedItemsForUserHasExpectedItem = true;
+                       }
+               }
+               $this->assertFalse(
+                       $watchedItemsForUserHasExpectedItem,
+                       'getWatchedItemsForUser should not contain the page'
+               );
+               $this->assertEquals( $initialWatchers, $store->countWatchers( $title ) );
+               $this->assertEquals(
+                       $initialWatchers,
+                       $store->countWatchersMultiple( [ $title ] )[$title->getNamespace()][$title->getDBkey()]
+               );
+               $this->assertEquals(
+                       [ $title->getNamespace() => [ $title->getDBkey() => false ] ],
+                       $store->getNotificationTimestampsBatch( $user, [ $title ] )
+               );
+       }
+
+       public function testUpdateResetAndSetNotificationTimestamp() {
+               $user = $this->getUser();
+               $otherUser = ( new TestUser( 'WatchedItemStoreIntegrationTestUser_otherUser' ) )->getUser();
+               $title = Title::newFromText( 'WatchedItemStoreIntegrationTestPage' );
+               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+               $store->addWatch( $user, $title );
+               $this->assertNull( $store->loadWatchedItem( $user, $title )->getNotificationTimestamp() );
+               $initialVisitingWatchers = $store->countVisitingWatchers( $title, '20150202020202' );
+               $initialUnreadNotifications = $store->countUnreadNotifications( $user );
+
+               $store->updateNotificationTimestamp( $otherUser, $title, '20150202010101' );
+               $this->assertEquals(
+                       '20150202010101',
+                       $store->loadWatchedItem( $user, $title )->getNotificationTimestamp()
+               );
+               $this->assertEquals(
+                       [ $title->getNamespace() => [ $title->getDBkey() => '20150202010101' ] ],
+                       $store->getNotificationTimestampsBatch( $user, [ $title ] )
+               );
+               $this->assertEquals(
+                       $initialVisitingWatchers - 1,
+                       $store->countVisitingWatchers( $title, '20150202020202' )
+               );
+               $this->assertEquals(
+                       $initialVisitingWatchers - 1,
+                       $store->countVisitingWatchersMultiple(
+                               [ [ $title, '20150202020202' ] ]
+                       )[$title->getNamespace()][$title->getDBkey()]
+               );
+               $this->assertEquals(
+                       $initialUnreadNotifications + 1,
+                       $store->countUnreadNotifications( $user )
+               );
+               $this->assertSame(
+                       true,
+                       $store->countUnreadNotifications( $user, $initialUnreadNotifications + 1 )
+               );
+
+               $this->assertTrue( $store->resetNotificationTimestamp( $user, $title ) );
+               $this->assertNull( $store->getWatchedItem( $user, $title )->getNotificationTimestamp() );
+               $this->assertEquals(
+                       [ $title->getNamespace() => [ $title->getDBkey() => null ] ],
+                       $store->getNotificationTimestampsBatch( $user, [ $title ] )
+               );
+               $this->assertEquals(
+                       $initialVisitingWatchers,
+                       $store->countVisitingWatchers( $title, '20150202020202' )
+               );
+               $this->assertEquals(
+                       $initialVisitingWatchers,
+                       $store->countVisitingWatchersMultiple(
+                               [ [ $title, '20150202020202' ] ]
+                       )[$title->getNamespace()][$title->getDBkey()]
+               );
+               $this->assertEquals(
+                       [ 0 => [ 'WatchedItemStoreIntegrationTestPage' => $initialVisitingWatchers ] ],
+                       $store->countVisitingWatchersMultiple(
+                               [ [ $title, '20150202020202' ] ], $initialVisitingWatchers
+                       )
+               );
+               $this->assertEquals(
+                       [ 0 => [ 'WatchedItemStoreIntegrationTestPage' => 0 ] ],
+                       $store->countVisitingWatchersMultiple(
+                               [ [ $title, '20150202020202' ] ], $initialVisitingWatchers + 1
+                       )
+               );
+
+               // setNotificationTimestampsForUser specifying a title
+               $this->assertTrue(
+                       $store->setNotificationTimestampsForUser( $user, '20200202020202', [ $title ] )
+               );
+               $this->assertEquals(
+                       '20200202020202',
+                       $store->getWatchedItem( $user, $title )->getNotificationTimestamp()
+               );
+
+               // setNotificationTimestampsForUser not specifying a title
+               $this->assertTrue(
+                       $store->setNotificationTimestampsForUser( $user, '20210202020202' )
+               );
+               $this->assertEquals(
+                       '20210202020202',
+                       $store->getWatchedItem( $user, $title )->getNotificationTimestamp()
+               );
+       }
+
+       public function testDuplicateAllAssociatedEntries() {
+               $user = $this->getUser();
+               $titleOld = Title::newFromText( 'WatchedItemStoreIntegrationTestPageOld' );
+               $titleNew = Title::newFromText( 'WatchedItemStoreIntegrationTestPageNew' );
+               $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+               $store->addWatch( $user, $titleOld->getSubjectPage() );
+               $store->addWatch( $user, $titleOld->getTalkPage() );
+               // Cleanup after previous tests
+               $store->removeWatch( $user, $titleNew->getSubjectPage() );
+               $store->removeWatch( $user, $titleNew->getTalkPage() );
+
+               $store->duplicateAllAssociatedEntries( $titleOld, $titleNew );
+
+               $this->assertTrue( $store->isWatched( $user, $titleOld->getSubjectPage() ) );
+               $this->assertTrue( $store->isWatched( $user, $titleOld->getTalkPage() ) );
+               $this->assertTrue( $store->isWatched( $user, $titleNew->getSubjectPage() ) );
+               $this->assertTrue( $store->isWatched( $user, $titleNew->getTalkPage() ) );
+       }
+
+}
diff --git a/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php
new file mode 100644 (file)
index 0000000..43b4fe9
--- /dev/null
@@ -0,0 +1,2675 @@
+<?php
+use MediaWiki\Linker\LinkTarget;
+use Wikimedia\Rdbms\LoadBalancer;
+use Wikimedia\ScopedCallback;
+
+/**
+ * @author Addshore
+ *
+ * @covers WatchedItemStore
+ */
+class WatchedItemStoreUnitTest extends MediaWikiTestCase {
+
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|IDatabase
+        */
+       private function getMockDb() {
+               return $this->createMock( IDatabase::class );
+       }
+
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|LoadBalancer
+        */
+       private function getMockLoadBalancer(
+               $mockDb,
+               $expectedConnectionType = null
+       ) {
+               $mock = $this->getMockBuilder( LoadBalancer::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               if ( $expectedConnectionType !== null ) {
+                       $mock->expects( $this->any() )
+                               ->method( 'getConnectionRef' )
+                               ->with( $expectedConnectionType )
+                               ->will( $this->returnValue( $mockDb ) );
+               } else {
+                       $mock->expects( $this->any() )
+                               ->method( 'getConnectionRef' )
+                               ->will( $this->returnValue( $mockDb ) );
+               }
+               return $mock;
+       }
+
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|HashBagOStuff
+        */
+       private function getMockCache() {
+               $mock = $this->getMockBuilder( HashBagOStuff::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $mock->expects( $this->any() )
+                       ->method( 'makeKey' )
+                       ->will( $this->returnCallback( function () {
+                               return implode( ':', func_get_args() );
+                       } ) );
+               return $mock;
+       }
+
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|ReadOnlyMode
+        */
+       private function getMockReadOnlyMode( $readOnly = false ) {
+               $mock = $this->getMockBuilder( ReadOnlyMode::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $mock->expects( $this->any() )
+                       ->method( 'isReadOnly' )
+                       ->will( $this->returnValue( $readOnly ) );
+               return $mock;
+       }
+
+       /**
+        * @param int $id
+        * @return PHPUnit_Framework_MockObject_MockObject|User
+        */
+       private function getMockNonAnonUserWithId( $id ) {
+               $mock = $this->createMock( User::class );
+               $mock->expects( $this->any() )
+                       ->method( 'isAnon' )
+                       ->will( $this->returnValue( false ) );
+               $mock->expects( $this->any() )
+                       ->method( 'getId' )
+                       ->will( $this->returnValue( $id ) );
+               return $mock;
+       }
+
+       /**
+        * @return User
+        */
+       private function getAnonUser() {
+               return User::newFromName( 'Anon_User' );
+       }
+
+       private function getFakeRow( array $rowValues ) {
+               $fakeRow = new stdClass();
+               foreach ( $rowValues as $valueName => $value ) {
+                       $fakeRow->$valueName = $value;
+               }
+               return $fakeRow;
+       }
+
+       private function newWatchedItemStore( LoadBalancer $loadBalancer, HashBagOStuff $cache,
+               ReadOnlyMode $readOnlyMode
+       ) {
+               return new WatchedItemStore(
+                       $loadBalancer,
+                       $cache,
+                       $readOnlyMode
+               );
+       }
+
+       public function testCountWatchedItems() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'selectField' )
+                       ->with(
+                               'watchlist',
+                               'COUNT(*)',
+                               [
+                                       'wl_user' => $user->getId(),
+                               ],
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 12 ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals( 12, $store->countWatchedItems( $user ) );
+       }
+
+       public function testCountWatchers() {
+               $titleValue = new TitleValue( 0, 'SomeDbKey' );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'selectField' )
+                       ->with(
+                               'watchlist',
+                               'COUNT(*)',
+                               [
+                                       'wl_namespace' => $titleValue->getNamespace(),
+                                       'wl_title' => $titleValue->getDBkey(),
+                               ],
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 7 ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals( 7, $store->countWatchers( $titleValue ) );
+       }
+
+       public function testCountWatchersMultiple() {
+               $titleValues = [
+                       new TitleValue( 0, 'SomeDbKey' ),
+                       new TitleValue( 0, 'OtherDbKey' ),
+                       new TitleValue( 1, 'AnotherDbKey' ),
+               ];
+
+               $mockDb = $this->getMockDb();
+
+               $dbResult = [
+                       $this->getFakeRow( [ 'wl_title' => 'SomeDbKey', 'wl_namespace' => 0, 'watchers' => 100 ] ),
+                       $this->getFakeRow( [ 'wl_title' => 'OtherDbKey', 'wl_namespace' => 0, 'watchers' => 300 ] ),
+                       $this->getFakeRow( [ 'wl_title' => 'AnotherDbKey', 'wl_namespace' => 1, 'watchers' => 500 ]
+                       ),
+               ];
+               $mockDb->expects( $this->once() )
+                       ->method( 'makeWhereFrom2d' )
+                       ->with(
+                               [ [ 'SomeDbKey' => 1, 'OtherDbKey' => 1 ], [ 'AnotherDbKey' => 1 ] ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'string' )
+                               )
+                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_title', 'wl_namespace', 'watchers' => 'COUNT(*)' ],
+                               [ 'makeWhereFrom2d return value' ],
+                               $this->isType( 'string' ),
+                               [
+                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
+                               ]
+                       )
+                       ->will(
+                               $this->returnValue( $dbResult )
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $expected = [
+                       0 => [ 'SomeDbKey' => 100, 'OtherDbKey' => 300 ],
+                       1 => [ 'AnotherDbKey' => 500 ],
+               ];
+               $this->assertEquals( $expected, $store->countWatchersMultiple( $titleValues ) );
+       }
+
+       public function provideIntWithDbUnsafeVersion() {
+               return [
+                       [ 50 ],
+                       [ "50; DROP TABLE watchlist;\n--" ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideIntWithDbUnsafeVersion
+        */
+       public function testCountWatchersMultiple_withMinimumWatchers( $minWatchers ) {
+               $titleValues = [
+                       new TitleValue( 0, 'SomeDbKey' ),
+                       new TitleValue( 0, 'OtherDbKey' ),
+                       new TitleValue( 1, 'AnotherDbKey' ),
+               ];
+
+               $mockDb = $this->getMockDb();
+
+               $dbResult = [
+                       $this->getFakeRow( [ 'wl_title' => 'SomeDbKey', 'wl_namespace' => 0, 'watchers' => 100 ] ),
+                       $this->getFakeRow( [ 'wl_title' => 'OtherDbKey', 'wl_namespace' => 0, 'watchers' => 300 ] ),
+                       $this->getFakeRow( [ 'wl_title' => 'AnotherDbKey', 'wl_namespace' => 1, 'watchers' => 500 ]
+                       ),
+               ];
+               $mockDb->expects( $this->once() )
+                       ->method( 'makeWhereFrom2d' )
+                       ->with(
+                               [ [ 'SomeDbKey' => 1, 'OtherDbKey' => 1 ], [ 'AnotherDbKey' => 1 ] ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_title', 'wl_namespace', 'watchers' => 'COUNT(*)' ],
+                               [ 'makeWhereFrom2d return value' ],
+                               $this->isType( 'string' ),
+                               [
+                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
+                                       'HAVING' => 'COUNT(*) >= 50',
+                               ]
+                       )
+                       ->will(
+                               $this->returnValue( $dbResult )
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $expected = [
+                       0 => [ 'SomeDbKey' => 100, 'OtherDbKey' => 300 ],
+                       1 => [ 'AnotherDbKey' => 500 ],
+               ];
+               $this->assertEquals(
+                       $expected,
+                       $store->countWatchersMultiple( $titleValues, [ 'minimumWatchers' => $minWatchers ] )
+               );
+       }
+
+       public function testCountVisitingWatchers() {
+               $titleValue = new TitleValue( 0, 'SomeDbKey' );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'selectField' )
+                       ->with(
+                               'watchlist',
+                               'COUNT(*)',
+                               [
+                                       'wl_namespace' => $titleValue->getNamespace(),
+                                       'wl_title' => $titleValue->getDBkey(),
+                                       'wl_notificationtimestamp >= \'TS111TS\' OR wl_notificationtimestamp IS NULL',
+                               ],
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 7 ) );
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'addQuotes' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return "'$value'";
+                       } ) );
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'timestamp' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return 'TS' . $value . 'TS';
+                       } ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals( 7, $store->countVisitingWatchers( $titleValue, '111' ) );
+       }
+
+       public function testCountVisitingWatchersMultiple() {
+               $titleValuesWithThresholds = [
+                       [ new TitleValue( 0, 'SomeDbKey' ), '111' ],
+                       [ new TitleValue( 0, 'OtherDbKey' ), '111' ],
+                       [ new TitleValue( 1, 'AnotherDbKey' ), '123' ],
+               ];
+
+               $dbResult = [
+                       $this->getFakeRow( [ 'wl_title' => 'SomeDbKey', 'wl_namespace' => 0, 'watchers' => 100 ] ),
+                       $this->getFakeRow( [ 'wl_title' => 'OtherDbKey', 'wl_namespace' => 0, 'watchers' => 300 ] ),
+                       $this->getFakeRow( [ 'wl_title' => 'AnotherDbKey', 'wl_namespace' => 1, 'watchers' => 500 ] ),
+               ];
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->exactly( 2 * 3 ) )
+                       ->method( 'addQuotes' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return "'$value'";
+                       } ) );
+               $mockDb->expects( $this->exactly( 3 ) )
+                       ->method( 'timestamp' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return 'TS' . $value . 'TS';
+                       } ) );
+               $mockDb->expects( $this->any() )
+                       ->method( 'makeList' )
+                       ->with(
+                               $this->isType( 'array' ),
+                               $this->isType( 'int' )
+                       )
+                       ->will( $this->returnCallback( function ( $a, $conj ) {
+                               $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
+                               return join( $sqlConj, array_map( function ( $s ) {
+                                       return '(' . $s . ')';
+                               }, $a
+                               ) );
+                       } ) );
+               $mockDb->expects( $this->never() )
+                       ->method( 'makeWhereFrom2d' );
+
+               $expectedCond =
+                       '((wl_namespace = 0) AND (' .
+                       "(((wl_title = 'SomeDbKey') AND (" .
+                       "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
+                       ')) OR (' .
+                       "(wl_title = 'OtherDbKey') AND (" .
+                       "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
+                       '))))' .
+                       ') OR ((wl_namespace = 1) AND (' .
+                       "(((wl_title = 'AnotherDbKey') AND (".
+                       "(wl_notificationtimestamp >= 'TS123TS') OR (wl_notificationtimestamp IS NULL)" .
+                       ')))))';
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
+                               $expectedCond,
+                               $this->isType( 'string' ),
+                               [
+                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
+                               ]
+                       )
+                       ->will(
+                               $this->returnValue( $dbResult )
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $expected = [
+                       0 => [ 'SomeDbKey' => 100, 'OtherDbKey' => 300 ],
+                       1 => [ 'AnotherDbKey' => 500 ],
+               ];
+               $this->assertEquals(
+                       $expected,
+                       $store->countVisitingWatchersMultiple( $titleValuesWithThresholds )
+               );
+       }
+
+       public function testCountVisitingWatchersMultiple_withMissingTargets() {
+               $titleValuesWithThresholds = [
+                       [ new TitleValue( 0, 'SomeDbKey' ), '111' ],
+                       [ new TitleValue( 0, 'OtherDbKey' ), '111' ],
+                       [ new TitleValue( 1, 'AnotherDbKey' ), '123' ],
+                       [ new TitleValue( 0, 'SomeNotExisitingDbKey' ), null ],
+                       [ new TitleValue( 0, 'OtherNotExisitingDbKey' ), null ],
+               ];
+
+               $dbResult = [
+                       $this->getFakeRow( [ 'wl_title' => 'SomeDbKey', 'wl_namespace' => 0, 'watchers' => 100 ] ),
+                       $this->getFakeRow( [ 'wl_title' => 'OtherDbKey', 'wl_namespace' => 0, 'watchers' => 300 ] ),
+                       $this->getFakeRow( [ 'wl_title' => 'AnotherDbKey', 'wl_namespace' => 1, 'watchers' => 500 ] ),
+                       $this->getFakeRow(
+                               [ 'wl_title' => 'SomeNotExisitingDbKey', 'wl_namespace' => 0, 'watchers' => 100 ]
+                       ),
+                       $this->getFakeRow(
+                               [ 'wl_title' => 'OtherNotExisitingDbKey', 'wl_namespace' => 0, 'watchers' => 200 ]
+                       ),
+               ];
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->exactly( 2 * 3 ) )
+                       ->method( 'addQuotes' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return "'$value'";
+                       } ) );
+               $mockDb->expects( $this->exactly( 3 ) )
+                       ->method( 'timestamp' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return 'TS' . $value . 'TS';
+                       } ) );
+               $mockDb->expects( $this->any() )
+                       ->method( 'makeList' )
+                       ->with(
+                               $this->isType( 'array' ),
+                               $this->isType( 'int' )
+                       )
+                       ->will( $this->returnCallback( function ( $a, $conj ) {
+                               $sqlConj = $conj === LIST_AND ? ' AND ' : ' OR ';
+                               return join( $sqlConj, array_map( function ( $s ) {
+                                       return '(' . $s . ')';
+                               }, $a
+                               ) );
+                       } ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'makeWhereFrom2d' )
+                       ->with(
+                               [ [ 'SomeNotExisitingDbKey' => 1, 'OtherNotExisitingDbKey' => 1 ] ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
+
+               $expectedCond =
+                       '((wl_namespace = 0) AND (' .
+                       "(((wl_title = 'SomeDbKey') AND (" .
+                       "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
+                       ')) OR (' .
+                       "(wl_title = 'OtherDbKey') AND (" .
+                       "(wl_notificationtimestamp >= 'TS111TS') OR (wl_notificationtimestamp IS NULL)" .
+                       '))))' .
+                       ') OR ((wl_namespace = 1) AND (' .
+                       "(((wl_title = 'AnotherDbKey') AND (".
+                       "(wl_notificationtimestamp >= 'TS123TS') OR (wl_notificationtimestamp IS NULL)" .
+                       '))))' .
+                       ') OR ' .
+                       '(makeWhereFrom2d return value)';
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
+                               $expectedCond,
+                               $this->isType( 'string' ),
+                               [
+                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
+                               ]
+                       )
+                       ->will(
+                               $this->returnValue( $dbResult )
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $expected = [
+                       0 => [
+                               'SomeDbKey' => 100, 'OtherDbKey' => 300,
+                               'SomeNotExisitingDbKey' => 100, 'OtherNotExisitingDbKey' => 200
+                       ],
+                       1 => [ 'AnotherDbKey' => 500 ],
+               ];
+               $this->assertEquals(
+                       $expected,
+                       $store->countVisitingWatchersMultiple( $titleValuesWithThresholds )
+               );
+       }
+
+       /**
+        * @dataProvider provideIntWithDbUnsafeVersion
+        */
+       public function testCountVisitingWatchersMultiple_withMinimumWatchers( $minWatchers ) {
+               $titleValuesWithThresholds = [
+                       [ new TitleValue( 0, 'SomeDbKey' ), '111' ],
+                       [ new TitleValue( 0, 'OtherDbKey' ), '111' ],
+                       [ new TitleValue( 1, 'AnotherDbKey' ), '123' ],
+               ];
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->any() )
+                       ->method( 'makeList' )
+                       ->will( $this->returnValue( 'makeList return value' ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
+                               'makeList return value',
+                               $this->isType( 'string' ),
+                               [
+                                       'GROUP BY' => [ 'wl_namespace', 'wl_title' ],
+                                       'HAVING' => 'COUNT(*) >= 50',
+                               ]
+                       )
+                       ->will(
+                               $this->returnValue( [] )
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $expected = [
+                       0 => [ 'SomeDbKey' => 0, 'OtherDbKey' => 0 ],
+                       1 => [ 'AnotherDbKey' => 0 ],
+               ];
+               $this->assertEquals(
+                       $expected,
+                       $store->countVisitingWatchersMultiple( $titleValuesWithThresholds, $minWatchers )
+               );
+       }
+
+       public function testCountUnreadNotifications() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'selectRowCount' )
+                       ->with(
+                               'watchlist',
+                               '1',
+                               [
+                                       "wl_notificationtimestamp IS NOT NULL",
+                                       'wl_user' => 1,
+                               ],
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 9 ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals( 9, $store->countUnreadNotifications( $user ) );
+       }
+
+       /**
+        * @dataProvider provideIntWithDbUnsafeVersion
+        */
+       public function testCountUnreadNotifications_withUnreadLimit_overLimit( $limit ) {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'selectRowCount' )
+                       ->with(
+                               'watchlist',
+                               '1',
+                               [
+                                       "wl_notificationtimestamp IS NOT NULL",
+                                       'wl_user' => 1,
+                               ],
+                               $this->isType( 'string' ),
+                               [ 'LIMIT' => 50 ]
+                       )
+                       ->will( $this->returnValue( 50 ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertSame(
+                       true,
+                       $store->countUnreadNotifications( $user, $limit )
+               );
+       }
+
+       /**
+        * @dataProvider provideIntWithDbUnsafeVersion
+        */
+       public function testCountUnreadNotifications_withUnreadLimit_underLimit( $limit ) {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'selectRowCount' )
+                       ->with(
+                               'watchlist',
+                               '1',
+                               [
+                                       "wl_notificationtimestamp IS NOT NULL",
+                                       'wl_user' => 1,
+                               ],
+                               $this->isType( 'string' ),
+                               [ 'LIMIT' => 50 ]
+                       )
+                       ->will( $this->returnValue( 9 ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals(
+                       9,
+                       $store->countUnreadNotifications( $user, $limit )
+               );
+       }
+
+       public function testDuplicateEntry_nothingToDuplicate() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       'wl_user',
+                                       'wl_notificationtimestamp',
+                               ],
+                               [
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'Old_Title',
+                               ],
+                               'WatchedItemStore::duplicateEntry',
+                               [ 'FOR UPDATE' ]
+                       )
+                       ->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
+               );
+
+               $store->duplicateEntry(
+                       Title::newFromText( 'Old_Title' ),
+                       Title::newFromText( 'New_Title' )
+               );
+       }
+
+       public function testDuplicateEntry_somethingToDuplicate() {
+               $fakeRows = [
+                       $this->getFakeRow( [ 'wl_user' => 1, 'wl_notificationtimestamp' => '20151212010101' ] ),
+                       $this->getFakeRow( [ 'wl_user' => 2, 'wl_notificationtimestamp' => null ] ),
+               ];
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->at( 0 ) )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       'wl_user',
+                                       'wl_notificationtimestamp',
+                               ],
+                               [
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'Old_Title',
+                               ]
+                       )
+                       ->will( $this->returnValue( new FakeResultWrapper( $fakeRows ) ) );
+               $mockDb->expects( $this->at( 1 ) )
+                       ->method( 'replace' )
+                       ->with(
+                               'watchlist',
+                               [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
+                               [
+                                       [
+                                               'wl_user' => 1,
+                                               'wl_namespace' => 0,
+                                               'wl_title' => 'New_Title',
+                                               'wl_notificationtimestamp' => '20151212010101',
+                                       ],
+                                       [
+                                               'wl_user' => 2,
+                                               'wl_namespace' => 0,
+                                               'wl_title' => 'New_Title',
+                                               'wl_notificationtimestamp' => null,
+                                       ],
+                               ],
+                               $this->isType( 'string' )
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $store->duplicateEntry(
+                       Title::newFromText( 'Old_Title' ),
+                       Title::newFromText( 'New_Title' )
+               );
+       }
+
+       public function testDuplicateAllAssociatedEntries_nothingToDuplicate() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->at( 0 ) )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       'wl_user',
+                                       'wl_notificationtimestamp',
+                               ],
+                               [
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'Old_Title',
+                               ]
+                       )
+                       ->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
+               $mockDb->expects( $this->at( 1 ) )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       'wl_user',
+                                       'wl_notificationtimestamp',
+                               ],
+                               [
+                                       'wl_namespace' => 1,
+                                       'wl_title' => 'Old_Title',
+                               ]
+                       )
+                       ->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $store->duplicateAllAssociatedEntries(
+                       Title::newFromText( 'Old_Title' ),
+                       Title::newFromText( 'New_Title' )
+               );
+       }
+
+       public function provideLinkTargetPairs() {
+               return [
+                       [ Title::newFromText( 'Old_Title' ), Title::newFromText( 'New_Title' ) ],
+                       [ new TitleValue( 0, 'Old_Title' ),  new TitleValue( 0, 'New_Title' ) ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideLinkTargetPairs
+        */
+       public function testDuplicateAllAssociatedEntries_somethingToDuplicate(
+               LinkTarget $oldTarget,
+               LinkTarget $newTarget
+       ) {
+               $fakeRows = [
+                       $this->getFakeRow( [ 'wl_user' => 1, 'wl_notificationtimestamp' => '20151212010101' ] ),
+               ];
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->at( 0 ) )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       'wl_user',
+                                       'wl_notificationtimestamp',
+                               ],
+                               [
+                                       'wl_namespace' => $oldTarget->getNamespace(),
+                                       'wl_title' => $oldTarget->getDBkey(),
+                               ]
+                       )
+                       ->will( $this->returnValue( new FakeResultWrapper( $fakeRows ) ) );
+               $mockDb->expects( $this->at( 1 ) )
+                       ->method( 'replace' )
+                       ->with(
+                               'watchlist',
+                               [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
+                               [
+                                       [
+                                               'wl_user' => 1,
+                                               'wl_namespace' => $newTarget->getNamespace(),
+                                               'wl_title' => $newTarget->getDBkey(),
+                                               'wl_notificationtimestamp' => '20151212010101',
+                                       ],
+                               ],
+                               $this->isType( 'string' )
+                       );
+               $mockDb->expects( $this->at( 2 ) )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       'wl_user',
+                                       'wl_notificationtimestamp',
+                               ],
+                               [
+                                       'wl_namespace' => $oldTarget->getNamespace() + 1,
+                                       'wl_title' => $oldTarget->getDBkey(),
+                               ]
+                       )
+                       ->will( $this->returnValue( new FakeResultWrapper( $fakeRows ) ) );
+               $mockDb->expects( $this->at( 3 ) )
+                       ->method( 'replace' )
+                       ->with(
+                               'watchlist',
+                               [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
+                               [
+                                       [
+                                               'wl_user' => 1,
+                                               'wl_namespace' => $newTarget->getNamespace() + 1,
+                                               'wl_title' => $newTarget->getDBkey(),
+                                               'wl_notificationtimestamp' => '20151212010101',
+                                       ],
+                               ],
+                               $this->isType( 'string' )
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $store->duplicateAllAssociatedEntries(
+                       $oldTarget,
+                       $newTarget
+               );
+       }
+
+       public function testAddWatch_nonAnonymousUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'insert' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       [
+                                               'wl_user' => 1,
+                                               'wl_namespace' => 0,
+                                               'wl_title' => 'Some_Page',
+                                               'wl_notificationtimestamp' => null,
+                                       ]
+                               ]
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->once() )
+                       ->method( 'delete' )
+                       ->with( '0:Some_Page:1' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $store->addWatch(
+                       $this->getMockNonAnonUserWithId( 1 ),
+                       Title::newFromText( 'Some_Page' )
+               );
+       }
+
+       public function testAddWatch_anonymousUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'insert' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $store->addWatch(
+                       $this->getAnonUser(),
+                       Title::newFromText( 'Some_Page' )
+               );
+       }
+
+       public function testAddWatchBatchForUser_readOnlyDBReturnsFalse() {
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $this->getMockDb() ),
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode( true )
+               );
+
+               $this->assertFalse(
+                       $store->addWatchBatchForUser(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               [ new TitleValue( 0, 'Some_Page' ), new TitleValue( 1, 'Some_Page' ) ]
+                       )
+               );
+       }
+
+       public function testAddWatchBatchForUser_nonAnonymousUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'insert' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       [
+                                               'wl_user' => 1,
+                                               'wl_namespace' => 0,
+                                               'wl_title' => 'Some_Page',
+                                               'wl_notificationtimestamp' => null,
+                                       ],
+                                       [
+                                               'wl_user' => 1,
+                                               'wl_namespace' => 1,
+                                               'wl_title' => 'Some_Page',
+                                               'wl_notificationtimestamp' => null,
+                                       ]
+                               ]
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->exactly( 2 ) )
+                       ->method( 'delete' );
+               $mockCache->expects( $this->at( 1 ) )
+                       ->method( 'delete' )
+                       ->with( '0:Some_Page:1' );
+               $mockCache->expects( $this->at( 3 ) )
+                       ->method( 'delete' )
+                       ->with( '1:Some_Page:1' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $mockUser = $this->getMockNonAnonUserWithId( 1 );
+
+               $this->assertTrue(
+                       $store->addWatchBatchForUser(
+                               $mockUser,
+                               [ new TitleValue( 0, 'Some_Page' ), new TitleValue( 1, 'Some_Page' ) ]
+                       )
+               );
+       }
+
+       public function testAddWatchBatchForUser_anonymousUsersAreSkipped() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'insert' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->addWatchBatchForUser(
+                               $this->getAnonUser(),
+                               [ new TitleValue( 0, 'Other_Page' ) ]
+                       )
+               );
+       }
+
+       public function testAddWatchBatchReturnsTrue_whenGivenEmptyList() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'insert' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertTrue(
+                       $store->addWatchBatchForUser( $user, [] )
+               );
+       }
+
+       public function testLoadWatchedItem_existingItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue(
+                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
+                       ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->once() )
+                       ->method( 'set' )
+                       ->with(
+                               '0:SomeDbKey:1'
+                       );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $watchedItem = $store->loadWatchedItem(
+                       $this->getMockNonAnonUserWithId( 1 ),
+                       new TitleValue( 0, 'SomeDbKey' )
+               );
+               $this->assertInstanceOf( 'WatchedItem', $watchedItem );
+               $this->assertEquals( 1, $watchedItem->getUser()->getId() );
+               $this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() );
+               $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() );
+       }
+
+       public function testLoadWatchedItem_noItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->loadWatchedItem(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testLoadWatchedItem_anonymousUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'selectRow' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->loadWatchedItem(
+                               $this->getAnonUser(),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testRemoveWatch_existingItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'delete' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       );
+               $mockDb->expects( $this->once() )
+                       ->method( 'affectedRows' )
+                       ->will( $this->returnValue( 1 ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'delete' )
+                       ->with( '0:SomeDbKey:1' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertTrue(
+                       $store->removeWatch(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testRemoveWatch_noItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'delete' )
+                       ->with(
+                               'watchlist',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       );
+               $mockDb->expects( $this->once() )
+                       ->method( 'affectedRows' )
+                       ->will( $this->returnValue( 0 ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'delete' )
+                       ->with( '0:SomeDbKey:1' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->removeWatch(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testRemoveWatch_anonymousUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->removeWatch(
+                               $this->getAnonUser(),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testGetWatchedItem_existingItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue(
+                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
+                       ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'delete' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'get' )
+                       ->with(
+                               '0:SomeDbKey:1'
+                       )
+                       ->will( $this->returnValue( null ) );
+               $mockCache->expects( $this->once() )
+                       ->method( 'set' )
+                       ->with(
+                               '0:SomeDbKey:1'
+                       );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $watchedItem = $store->getWatchedItem(
+                       $this->getMockNonAnonUserWithId( 1 ),
+                       new TitleValue( 0, 'SomeDbKey' )
+               );
+               $this->assertInstanceOf( 'WatchedItem', $watchedItem );
+               $this->assertEquals( 1, $watchedItem->getUser()->getId() );
+               $this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() );
+               $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() );
+       }
+
+       public function testGetWatchedItem_cachedItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'selectRow' );
+
+               $mockUser = $this->getMockNonAnonUserWithId( 1 );
+               $linkTarget = new TitleValue( 0, 'SomeDbKey' );
+               $cachedItem = new WatchedItem( $mockUser, $linkTarget, '20151212010101' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'delete' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'get' )
+                       ->with(
+                               '0:SomeDbKey:1'
+                       )
+                       ->will( $this->returnValue( $cachedItem ) );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals(
+                       $cachedItem,
+                       $store->getWatchedItem(
+                               $mockUser,
+                               $linkTarget
+                       )
+               );
+       }
+
+       public function testGetWatchedItem_noItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'get' )
+                       ->with( '0:SomeDbKey:1' )
+                       ->will( $this->returnValue( false ) );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->getWatchedItem(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testGetWatchedItem_anonymousUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'selectRow' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->getWatchedItem(
+                               $this->getAnonUser(),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testGetWatchedItemsForUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                               [ 'wl_user' => 1 ]
+                       )
+                       ->will( $this->returnValue( [
+                               $this->getFakeRow( [
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'Foo1',
+                                       'wl_notificationtimestamp' => '20151212010101',
+                               ] ),
+                               $this->getFakeRow( [
+                                       'wl_namespace' => 1,
+                                       'wl_title' => 'Foo2',
+                                       'wl_notificationtimestamp' => null,
+                               ] ),
+                       ] ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'delete' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $watchedItems = $store->getWatchedItemsForUser( $user );
+
+               $this->assertInternalType( 'array', $watchedItems );
+               $this->assertCount( 2, $watchedItems );
+               foreach ( $watchedItems as $watchedItem ) {
+                       $this->assertInstanceOf( 'WatchedItem', $watchedItem );
+               }
+               $this->assertEquals(
+                       new WatchedItem( $user, new TitleValue( 0, 'Foo1' ), '20151212010101' ),
+                       $watchedItems[0]
+               );
+               $this->assertEquals(
+                       new WatchedItem( $user, new TitleValue( 1, 'Foo2' ), null ),
+                       $watchedItems[1]
+               );
+       }
+
+       public function provideDbTypes() {
+               return [
+                       [ false, DB_REPLICA ],
+                       [ true, DB_MASTER ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideDbTypes
+        */
+       public function testGetWatchedItemsForUser_optionsAndEmptyResult( $forWrite, $dbType ) {
+               $mockDb = $this->getMockDb();
+               $mockCache = $this->getMockCache();
+               $mockLoadBalancer = $this->getMockLoadBalancer( $mockDb, $dbType );
+               $user = $this->getMockNonAnonUserWithId( 1 );
+
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                               [ 'wl_user' => 1 ],
+                               $this->isType( 'string' ),
+                               [ 'ORDER BY' => [ 'wl_namespace ASC', 'wl_title ASC' ] ]
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $store = $this->newWatchedItemStore(
+                       $mockLoadBalancer,
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $watchedItems = $store->getWatchedItemsForUser(
+                       $user,
+                       [ 'forWrite' => $forWrite, 'sort' => WatchedItemStore::SORT_ASC ]
+               );
+               $this->assertEquals( [], $watchedItems );
+       }
+
+       public function testGetWatchedItemsForUser_badSortOptionThrowsException() {
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $this->getMockDb() ),
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->setExpectedException( 'InvalidArgumentException' );
+               $store->getWatchedItemsForUser(
+                       $this->getMockNonAnonUserWithId( 1 ),
+                       [ 'sort' => 'foo' ]
+               );
+       }
+
+       public function testIsWatchedItem_existingItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue(
+                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
+                       ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'delete' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'get' )
+                       ->with( '0:SomeDbKey:1' )
+                       ->will( $this->returnValue( false ) );
+               $mockCache->expects( $this->once() )
+                       ->method( 'set' )
+                       ->with(
+                               '0:SomeDbKey:1'
+                       );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertTrue(
+                       $store->isWatched(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testIsWatchedItem_noItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'get' )
+                       ->with( '0:SomeDbKey:1' )
+                       ->will( $this->returnValue( false ) );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->isWatched(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testIsWatchedItem_anonymousUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'selectRow' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->isWatched(
+                               $this->getAnonUser(),
+                               new TitleValue( 0, 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testGetNotificationTimestampsBatch() {
+               $targets = [
+                       new TitleValue( 0, 'SomeDbKey' ),
+                       new TitleValue( 1, 'AnotherDbKey' ),
+               ];
+
+               $mockDb = $this->getMockDb();
+               $dbResult = [
+                       $this->getFakeRow( [
+                               'wl_namespace' => 0,
+                               'wl_title' => 'SomeDbKey',
+                               'wl_notificationtimestamp' => '20151212010101',
+                       ] ),
+                       $this->getFakeRow(
+                               [
+                                       'wl_namespace' => 1,
+                                       'wl_title' => 'AnotherDbKey',
+                                       'wl_notificationtimestamp' => null,
+                               ]
+                       ),
+               ];
+
+               $mockDb->expects( $this->once() )
+                       ->method( 'makeWhereFrom2d' )
+                       ->with(
+                               [ [ 'SomeDbKey' => 1 ], [ 'AnotherDbKey' => 1 ] ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                               [
+                                       'makeWhereFrom2d return value',
+                                       'wl_user' => 1
+                               ],
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( $dbResult ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->exactly( 2 ) )
+                       ->method( 'get' )
+                       ->withConsecutive(
+                               [ '0:SomeDbKey:1' ],
+                               [ '1:AnotherDbKey:1' ]
+                       )
+                       ->will( $this->returnValue( null ) );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals(
+                       [
+                               0 => [ 'SomeDbKey' => '20151212010101', ],
+                               1 => [ 'AnotherDbKey' => null, ],
+                       ],
+                       $store->getNotificationTimestampsBatch( $this->getMockNonAnonUserWithId( 1 ), $targets )
+               );
+       }
+
+       public function testGetNotificationTimestampsBatch_notWatchedTarget() {
+               $targets = [
+                       new TitleValue( 0, 'OtherDbKey' ),
+               ];
+
+               $mockDb = $this->getMockDb();
+
+               $mockDb->expects( $this->once() )
+                       ->method( 'makeWhereFrom2d' )
+                       ->with(
+                               [ [ 'OtherDbKey' => 1 ] ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                               [
+                                       'makeWhereFrom2d return value',
+                                       'wl_user' => 1
+                               ],
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( $this->getFakeRow( [] ) ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->once() )
+                       ->method( 'get' )
+                       ->with( '0:OtherDbKey:1' )
+                       ->will( $this->returnValue( null ) );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals(
+                       [
+                               0 => [ 'OtherDbKey' => false, ],
+                       ],
+                       $store->getNotificationTimestampsBatch( $this->getMockNonAnonUserWithId( 1 ), $targets )
+               );
+       }
+
+       public function testGetNotificationTimestampsBatch_cachedItem() {
+               $targets = [
+                       new TitleValue( 0, 'SomeDbKey' ),
+                       new TitleValue( 1, 'AnotherDbKey' ),
+               ];
+
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $cachedItem = new WatchedItem( $user, $targets[0], '20151212010101' );
+
+               $mockDb = $this->getMockDb();
+
+               $mockDb->expects( $this->once() )
+                       ->method( 'makeWhereFrom2d' )
+                       ->with(
+                               [ 1 => [ 'AnotherDbKey' => 1 ] ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'select' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
+                               [
+                                       'makeWhereFrom2d return value',
+                                       'wl_user' => 1
+                               ],
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( [
+                               $this->getFakeRow(
+                                       [ 'wl_namespace' => 1, 'wl_title' => 'AnotherDbKey', 'wl_notificationtimestamp' => null, ]
+                               )
+                       ] ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->at( 1 ) )
+                       ->method( 'get' )
+                       ->with( '0:SomeDbKey:1' )
+                       ->will( $this->returnValue( $cachedItem ) );
+               $mockCache->expects( $this->at( 3 ) )
+                       ->method( 'get' )
+                       ->with( '1:AnotherDbKey:1' )
+                       ->will( $this->returnValue( null ) );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals(
+                       [
+                               0 => [ 'SomeDbKey' => '20151212010101', ],
+                               1 => [ 'AnotherDbKey' => null, ],
+                       ],
+                       $store->getNotificationTimestampsBatch( $user, $targets )
+               );
+       }
+
+       public function testGetNotificationTimestampsBatch_allItemsCached() {
+               $targets = [
+                       new TitleValue( 0, 'SomeDbKey' ),
+                       new TitleValue( 1, 'AnotherDbKey' ),
+               ];
+
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $cachedItems = [
+                       new WatchedItem( $user, $targets[0], '20151212010101' ),
+                       new WatchedItem( $user, $targets[1], null ),
+               ];
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )->method( $this->anything() );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->at( 1 ) )
+                       ->method( 'get' )
+                       ->with( '0:SomeDbKey:1' )
+                       ->will( $this->returnValue( $cachedItems[0] ) );
+               $mockCache->expects( $this->at( 3 ) )
+                       ->method( 'get' )
+                       ->with( '1:AnotherDbKey:1' )
+                       ->will( $this->returnValue( $cachedItems[1] ) );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals(
+                       [
+                               0 => [ 'SomeDbKey' => '20151212010101', ],
+                               1 => [ 'AnotherDbKey' => null, ],
+                       ],
+                       $store->getNotificationTimestampsBatch( $user, $targets )
+               );
+       }
+
+       public function testGetNotificationTimestampsBatch_anonymousUser() {
+               $targets = [
+                       new TitleValue( 0, 'SomeDbKey' ),
+                       new TitleValue( 1, 'AnotherDbKey' ),
+               ];
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )->method( $this->anything() );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( $this->anything() );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals(
+                       [
+                               0 => [ 'SomeDbKey' => false, ],
+                               1 => [ 'AnotherDbKey' => false, ],
+                       ],
+                       $store->getNotificationTimestampsBatch( $this->getAnonUser(), $targets )
+               );
+       }
+
+       public function testResetNotificationTimestamp_anonymousUser() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'selectRow' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->resetNotificationTimestamp(
+                               $this->getAnonUser(),
+                               Title::newFromText( 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testResetNotificationTimestamp_noItem() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue( [] ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertFalse(
+                       $store->resetNotificationTimestamp(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               Title::newFromText( 'SomeDbKey' )
+                       )
+               );
+       }
+
+       public function testResetNotificationTimestamp_item() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $title = Title::newFromText( 'SomeDbKey' );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue(
+                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
+                       ) );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'set' )
+                       ->with(
+                               '0:SomeDbKey:1',
+                               $this->isInstanceOf( WatchedItem::class )
+                       );
+               $mockCache->expects( $this->once() )
+                       ->method( 'delete' )
+                       ->with( '0:SomeDbKey:1' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               // Note: This does not actually assert the job is correct
+               $callableCallCounter = 0;
+               $mockCallback = function ( $callable ) use ( &$callableCallCounter ) {
+                       $callableCallCounter++;
+                       $this->assertInternalType( 'callable', $callable );
+               };
+               $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback( $mockCallback );
+
+               $this->assertTrue(
+                       $store->resetNotificationTimestamp(
+                               $user,
+                               $title
+                       )
+               );
+               $this->assertEquals( 1, $callableCallCounter );
+
+               ScopedCallback::consume( $scopedOverride );
+       }
+
+       public function testResetNotificationTimestamp_noItemForced() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $title = Title::newFromText( 'SomeDbKey' );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'selectRow' );
+
+               $mockCache = $this->getMockCache();
+               $mockDb->expects( $this->never() )
+                       ->method( 'get' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'set' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               // Note: This does not actually assert the job is correct
+               $callableCallCounter = 0;
+               $mockCallback = function ( $callable ) use ( &$callableCallCounter ) {
+                       $callableCallCounter++;
+                       $this->assertInternalType( 'callable', $callable );
+               };
+               $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback( $mockCallback );
+
+               $this->assertTrue(
+                       $store->resetNotificationTimestamp(
+                               $user,
+                               $title,
+                               'force'
+                       )
+               );
+               $this->assertEquals( 1, $callableCallCounter );
+
+               ScopedCallback::consume( $scopedOverride );
+       }
+
+       /**
+        * @param string $text
+        * @param int $ns
+        *
+        * @return PHPUnit_Framework_MockObject_MockObject|Title
+        */
+       private function getMockTitle( $text, $ns = 0 ) {
+               $title = $this->createMock( Title::class );
+               $title->expects( $this->any() )
+                       ->method( 'getText' )
+                       ->will( $this->returnValue( str_replace( '_', ' ', $text ) ) );
+               $title->expects( $this->any() )
+                       ->method( 'getDbKey' )
+                       ->will( $this->returnValue( str_replace( '_', ' ', $text ) ) );
+               $title->expects( $this->any() )
+                       ->method( 'getNamespace' )
+                       ->will( $this->returnValue( $ns ) );
+               return $title;
+       }
+
+       private function verifyCallbackJob(
+               $callback,
+               LinkTarget $expectedTitle,
+               $expectedUserId,
+               callable $notificationTimestampCondition
+       ) {
+               $this->assertInternalType( 'callable', $callback );
+
+               $callbackReflector = new ReflectionFunction( $callback );
+               $vars = $callbackReflector->getStaticVariables();
+               $this->assertArrayHasKey( 'job', $vars );
+               $this->assertInstanceOf( ActivityUpdateJob::class, $vars['job'] );
+
+               /** @var ActivityUpdateJob $job */
+               $job = $vars['job'];
+               $this->assertEquals( $expectedTitle->getDBkey(), $job->getTitle()->getDBkey() );
+               $this->assertEquals( $expectedTitle->getNamespace(), $job->getTitle()->getNamespace() );
+
+               $jobParams = $job->getParams();
+               $this->assertArrayHasKey( 'type', $jobParams );
+               $this->assertEquals( 'updateWatchlistNotification', $jobParams['type'] );
+               $this->assertArrayHasKey( 'userid', $jobParams );
+               $this->assertEquals( $expectedUserId, $jobParams['userid'] );
+               $this->assertArrayHasKey( 'notifTime', $jobParams );
+               $this->assertTrue( $notificationTimestampCondition( $jobParams['notifTime'] ) );
+       }
+
+       public function testResetNotificationTimestamp_oldidSpecifiedLatestRevisionForced() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $oldid = 22;
+               $title = $this->getMockTitle( 'SomeTitle' );
+               $title->expects( $this->once() )
+                       ->method( 'getNextRevisionID' )
+                       ->with( $oldid )
+                       ->will( $this->returnValue( false ) );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->never() )
+                       ->method( 'selectRow' );
+
+               $mockCache = $this->getMockCache();
+               $mockDb->expects( $this->never() )
+                       ->method( 'get' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'set' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $callableCallCounter = 0;
+               $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
+                       function ( $callable ) use ( &$callableCallCounter, $title, $user ) {
+                               $callableCallCounter++;
+                               $this->verifyCallbackJob(
+                                       $callable,
+                                       $title,
+                                       $user->getId(),
+                                       function ( $time ) {
+                                               return $time === null;
+                                       }
+                               );
+                       }
+               );
+
+               $this->assertTrue(
+                       $store->resetNotificationTimestamp(
+                               $user,
+                               $title,
+                               'force',
+                               $oldid
+                       )
+               );
+               $this->assertEquals( 1, $callableCallCounter );
+
+               ScopedCallback::consume( $scopedOverride );
+       }
+
+       public function testResetNotificationTimestamp_oldidSpecifiedNotLatestRevisionForced() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $oldid = 22;
+               $title = $this->getMockTitle( 'SomeDbKey' );
+               $title->expects( $this->once() )
+                       ->method( 'getNextRevisionID' )
+                       ->with( $oldid )
+                       ->will( $this->returnValue( 33 ) );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue(
+                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
+                       ) );
+
+               $mockCache = $this->getMockCache();
+               $mockDb->expects( $this->never() )
+                       ->method( 'get' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'set' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $addUpdateCallCounter = 0;
+               $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
+                       function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
+                               $addUpdateCallCounter++;
+                               $this->verifyCallbackJob(
+                                       $callable,
+                                       $title,
+                                       $user->getId(),
+                                       function ( $time ) {
+                                               return $time !== null && $time > '20151212010101';
+                                       }
+                               );
+                       }
+               );
+
+               $getTimestampCallCounter = 0;
+               $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
+                       function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
+                               $getTimestampCallCounter++;
+                               $this->assertEquals( $title, $titleParam );
+                               $this->assertEquals( $oldid, $oldidParam );
+                       }
+               );
+
+               $this->assertTrue(
+                       $store->resetNotificationTimestamp(
+                               $user,
+                               $title,
+                               'force',
+                               $oldid
+                       )
+               );
+               $this->assertEquals( 1, $addUpdateCallCounter );
+               $this->assertEquals( 1, $getTimestampCallCounter );
+
+               ScopedCallback::consume( $scopedOverrideDeferred );
+               ScopedCallback::consume( $scopedOverrideRevision );
+       }
+
+       public function testResetNotificationTimestamp_notWatchedPageForced() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $oldid = 22;
+               $title = $this->getMockTitle( 'SomeDbKey' );
+               $title->expects( $this->once() )
+                       ->method( 'getNextRevisionID' )
+                       ->with( $oldid )
+                       ->will( $this->returnValue( 33 ) );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue( false ) );
+
+               $mockCache = $this->getMockCache();
+               $mockDb->expects( $this->never() )
+                       ->method( 'get' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'set' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $callableCallCounter = 0;
+               $scopedOverride = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
+                       function ( $callable ) use ( &$callableCallCounter, $title, $user ) {
+                               $callableCallCounter++;
+                               $this->verifyCallbackJob(
+                                       $callable,
+                                       $title,
+                                       $user->getId(),
+                                       function ( $time ) {
+                                               return $time === null;
+                                       }
+                               );
+                       }
+               );
+
+               $this->assertTrue(
+                       $store->resetNotificationTimestamp(
+                               $user,
+                               $title,
+                               'force',
+                               $oldid
+                       )
+               );
+               $this->assertEquals( 1, $callableCallCounter );
+
+               ScopedCallback::consume( $scopedOverride );
+       }
+
+       public function testResetNotificationTimestamp_futureNotificationTimestampForced() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $oldid = 22;
+               $title = $this->getMockTitle( 'SomeDbKey' );
+               $title->expects( $this->once() )
+                       ->method( 'getNextRevisionID' )
+                       ->with( $oldid )
+                       ->will( $this->returnValue( 33 ) );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue(
+                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '30151212010101' ] )
+                       ) );
+
+               $mockCache = $this->getMockCache();
+               $mockDb->expects( $this->never() )
+                       ->method( 'get' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'set' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $addUpdateCallCounter = 0;
+               $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
+                       function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
+                               $addUpdateCallCounter++;
+                               $this->verifyCallbackJob(
+                                       $callable,
+                                       $title,
+                                       $user->getId(),
+                                       function ( $time ) {
+                                               return $time === '30151212010101';
+                                       }
+                               );
+                       }
+               );
+
+               $getTimestampCallCounter = 0;
+               $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
+                       function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
+                               $getTimestampCallCounter++;
+                               $this->assertEquals( $title, $titleParam );
+                               $this->assertEquals( $oldid, $oldidParam );
+                       }
+               );
+
+               $this->assertTrue(
+                       $store->resetNotificationTimestamp(
+                               $user,
+                               $title,
+                               'force',
+                               $oldid
+                       )
+               );
+               $this->assertEquals( 1, $addUpdateCallCounter );
+               $this->assertEquals( 1, $getTimestampCallCounter );
+
+               ScopedCallback::consume( $scopedOverrideDeferred );
+               ScopedCallback::consume( $scopedOverrideRevision );
+       }
+
+       public function testResetNotificationTimestamp_futureNotificationTimestampNotForced() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $oldid = 22;
+               $title = $this->getMockTitle( 'SomeDbKey' );
+               $title->expects( $this->once() )
+                       ->method( 'getNextRevisionID' )
+                       ->with( $oldid )
+                       ->will( $this->returnValue( 33 ) );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->with(
+                               'watchlist',
+                               'wl_notificationtimestamp',
+                               [
+                                       'wl_user' => 1,
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       )
+                       ->will( $this->returnValue(
+                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '30151212010101' ] )
+                       ) );
+
+               $mockCache = $this->getMockCache();
+               $mockDb->expects( $this->never() )
+                       ->method( 'get' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'set' );
+               $mockDb->expects( $this->never() )
+                       ->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $addUpdateCallCounter = 0;
+               $scopedOverrideDeferred = $store->overrideDeferredUpdatesAddCallableUpdateCallback(
+                       function ( $callable ) use ( &$addUpdateCallCounter, $title, $user ) {
+                               $addUpdateCallCounter++;
+                               $this->verifyCallbackJob(
+                                       $callable,
+                                       $title,
+                                       $user->getId(),
+                                       function ( $time ) {
+                                               return $time === false;
+                                       }
+                               );
+                       }
+               );
+
+               $getTimestampCallCounter = 0;
+               $scopedOverrideRevision = $store->overrideRevisionGetTimestampFromIdCallback(
+                       function ( $titleParam, $oldidParam ) use ( &$getTimestampCallCounter, $title, $oldid ) {
+                               $getTimestampCallCounter++;
+                               $this->assertEquals( $title, $titleParam );
+                               $this->assertEquals( $oldid, $oldidParam );
+                       }
+               );
+
+               $this->assertTrue(
+                       $store->resetNotificationTimestamp(
+                               $user,
+                               $title,
+                               '',
+                               $oldid
+                       )
+               );
+               $this->assertEquals( 1, $addUpdateCallCounter );
+               $this->assertEquals( 1, $getTimestampCallCounter );
+
+               ScopedCallback::consume( $scopedOverrideDeferred );
+               ScopedCallback::consume( $scopedOverrideRevision );
+       }
+
+       public function testSetNotificationTimestampsForUser_anonUser() {
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $this->getMockDb() ),
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
+               );
+               $this->assertFalse( $store->setNotificationTimestampsForUser( $this->getAnonUser(), '' ) );
+       }
+
+       public function testSetNotificationTimestampsForUser_allRows() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $timestamp = '20100101010101';
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'update' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_notificationtimestamp' => 'TS' . $timestamp . 'TS' ],
+                               [ 'wl_user' => 1 ]
+                       )
+                       ->will( $this->returnValue( true ) );
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'timestamp' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return 'TS' . $value . 'TS';
+                       } ) );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertTrue(
+                       $store->setNotificationTimestampsForUser( $user, $timestamp )
+               );
+       }
+
+       public function testSetNotificationTimestampsForUser_nullTimestamp() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $timestamp = null;
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'update' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_notificationtimestamp' => null ],
+                               [ 'wl_user' => 1 ]
+                       )
+                       ->will( $this->returnValue( true ) );
+               $mockDb->expects( $this->exactly( 0 ) )
+                       ->method( 'timestamp' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return 'TS' . $value . 'TS';
+                       } ) );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertTrue(
+                       $store->setNotificationTimestampsForUser( $user, $timestamp )
+               );
+       }
+
+       public function testSetNotificationTimestampsForUser_specificTargets() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $timestamp = '20100101010101';
+               $targets = [ new TitleValue( 0, 'Foo' ), new TitleValue( 0, 'Bar' ) ];
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'update' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_notificationtimestamp' => 'TS' . $timestamp . 'TS' ],
+                               [ 'wl_user' => 1, 0 => 'makeWhereFrom2d return value' ]
+                       )
+                       ->will( $this->returnValue( true ) );
+               $mockDb->expects( $this->exactly( 1 ) )
+                       ->method( 'timestamp' )
+                       ->will( $this->returnCallback( function ( $value ) {
+                               return 'TS' . $value . 'TS';
+                       } ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'makeWhereFrom2d' )
+                       ->with(
+                               [ [ 'Foo' => 1, 'Bar' => 1 ] ],
+                               $this->isType( 'string' ),
+                               $this->isType( 'string' )
+                       )
+                       ->will( $this->returnValue( 'makeWhereFrom2d return value' ) );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $this->getMockCache(),
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertTrue(
+                       $store->setNotificationTimestampsForUser( $user, $timestamp, $targets )
+               );
+       }
+
+       public function testUpdateNotificationTimestamp_watchersExist() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectFieldValues' )
+                       ->with(
+                               'watchlist',
+                               'wl_user',
+                               [
+                                       'wl_user != 1',
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                                       'wl_notificationtimestamp IS NULL'
+                               ]
+                       )
+                       ->will( $this->returnValue( [ '2', '3' ] ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'update' )
+                       ->with(
+                               'watchlist',
+                               [ 'wl_notificationtimestamp' => null ],
+                               [
+                                       'wl_user' => [ 2, 3 ],
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                               ]
+                       );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $this->assertEquals(
+                       [ 2, 3 ],
+                       $store->updateNotificationTimestamp(
+                               $this->getMockNonAnonUserWithId( 1 ),
+                               new TitleValue( 0, 'SomeDbKey' ),
+                               '20151212010101'
+                       )
+               );
+       }
+
+       public function testUpdateNotificationTimestamp_noWatchers() {
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectFieldValues' )
+                       ->with(
+                               'watchlist',
+                               'wl_user',
+                               [
+                                       'wl_user != 1',
+                                       'wl_namespace' => 0,
+                                       'wl_title' => 'SomeDbKey',
+                                       'wl_notificationtimestamp IS NULL'
+                               ]
+                       )
+                       ->will(
+                               $this->returnValue( [] )
+                       );
+               $mockDb->expects( $this->never() )
+                       ->method( 'update' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->never() )->method( 'set' );
+               $mockCache->expects( $this->never() )->method( 'get' );
+               $mockCache->expects( $this->never() )->method( 'delete' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               $watchers = $store->updateNotificationTimestamp(
+                       $this->getMockNonAnonUserWithId( 1 ),
+                       new TitleValue( 0, 'SomeDbKey' ),
+                       '20151212010101'
+               );
+               $this->assertInternalType( 'array', $watchers );
+               $this->assertEmpty( $watchers );
+       }
+
+       public function testUpdateNotificationTimestamp_clearsCachedItems() {
+               $user = $this->getMockNonAnonUserWithId( 1 );
+               $titleValue = new TitleValue( 0, 'SomeDbKey' );
+
+               $mockDb = $this->getMockDb();
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectRow' )
+                       ->will( $this->returnValue(
+                               $this->getFakeRow( [ 'wl_notificationtimestamp' => '20151212010101' ] )
+                       ) );
+               $mockDb->expects( $this->once() )
+                       ->method( 'selectFieldValues' )
+                       ->will(
+                               $this->returnValue( [ '2', '3' ] )
+                       );
+               $mockDb->expects( $this->once() )
+                       ->method( 'update' );
+
+               $mockCache = $this->getMockCache();
+               $mockCache->expects( $this->once() )
+                       ->method( 'set' )
+                       ->with( '0:SomeDbKey:1', $this->isType( 'object' ) );
+               $mockCache->expects( $this->once() )
+                       ->method( 'get' )
+                       ->with( '0:SomeDbKey:1' );
+               $mockCache->expects( $this->once() )
+                       ->method( 'delete' )
+                       ->with( '0:SomeDbKey:1' );
+
+               $store = $this->newWatchedItemStore(
+                       $this->getMockLoadBalancer( $mockDb ),
+                       $mockCache,
+                       $this->getMockReadOnlyMode()
+               );
+
+               // This will add the item to the cache
+               $store->getWatchedItem( $user, $titleValue );
+
+               $store->updateNotificationTimestamp(
+                       $this->getMockNonAnonUserWithId( 1 ),
+                       $titleValue,
+                       '20151212010101'
+               );
+       }
+
+}
diff --git a/tests/phpunit/includes/watcheditem/WatchedItemUnitTest.php b/tests/phpunit/includes/watcheditem/WatchedItemUnitTest.php
new file mode 100644 (file)
index 0000000..8897645
--- /dev/null
@@ -0,0 +1,150 @@
+<?php
+use MediaWiki\Linker\LinkTarget;
+
+/**
+ * @author Addshore
+ *
+ * @covers WatchedItem
+ */
+class WatchedItemUnitTest extends MediaWikiTestCase {
+
+       /**
+        * @param int $id
+        *
+        * @return PHPUnit_Framework_MockObject_MockObject|User
+        */
+       private function getMockUser( $id ) {
+               $user = $this->createMock( User::class );
+               $user->expects( $this->any() )
+                       ->method( 'getId' )
+                       ->will( $this->returnValue( $id ) );
+               $user->expects( $this->any() )
+                       ->method( 'isAllowed' )
+                       ->will( $this->returnValue( true ) );
+               return $user;
+       }
+
+       public function provideUserTitleTimestamp() {
+               $user = $this->getMockUser( 111 );
+               return [
+                       [ $user, Title::newFromText( 'SomeTitle' ), null ],
+                       [ $user, Title::newFromText( 'SomeTitle' ), '20150101010101' ],
+                       [ $user, new TitleValue( 0, 'TVTitle', 'frag' ), '20150101010101' ],
+               ];
+       }
+
+       /**
+        * @return PHPUnit_Framework_MockObject_MockObject|WatchedItemStore
+        */
+       private function getMockWatchedItemStore() {
+               return $this->getMockBuilder( WatchedItemStore::class )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+       }
+
+       /**
+        * @dataProvider provideUserTitleTimestamp
+        */
+       public function testConstruction( $user, LinkTarget $linkTarget, $notifTimestamp ) {
+               $item = new WatchedItem( $user, $linkTarget, $notifTimestamp );
+
+               $this->assertSame( $user, $item->getUser() );
+               $this->assertSame( $linkTarget, $item->getLinkTarget() );
+               $this->assertSame( $notifTimestamp, $item->getNotificationTimestamp() );
+
+               // The below tests the internal WatchedItem::getTitle method
+               $this->assertInstanceOf( 'Title', $item->getTitle() );
+               $this->assertSame( $linkTarget->getDBkey(), $item->getTitle()->getDBkey() );
+               $this->assertSame( $linkTarget->getFragment(), $item->getTitle()->getFragment() );
+               $this->assertSame( $linkTarget->getNamespace(), $item->getTitle()->getNamespace() );
+               $this->assertSame( $linkTarget->getText(), $item->getTitle()->getText() );
+       }
+
+       /**
+        * @dataProvider provideUserTitleTimestamp
+        */
+       public function testFromUserTitle( $user, $linkTarget, $timestamp ) {
+               $store = $this->getMockWatchedItemStore();
+               $store->expects( $this->once() )
+                       ->method( 'loadWatchedItem' )
+                       ->with( $user, $linkTarget )
+                       ->will( $this->returnValue( new WatchedItem( $user, $linkTarget, $timestamp ) ) );
+               $this->setService( 'WatchedItemStore', $store );
+
+               $item = WatchedItem::fromUserTitle( $user, $linkTarget, User::IGNORE_USER_RIGHTS );
+
+               $this->assertEquals( $user, $item->getUser() );
+               $this->assertEquals( $linkTarget, $item->getLinkTarget() );
+               $this->assertEquals( $timestamp, $item->getNotificationTimestamp() );
+       }
+
+       public function testAddWatch() {
+               $title = Title::newFromText( 'SomeTitle' );
+               $timestamp = null;
+               $checkRights = 0;
+
+               /** @var User|PHPUnit_Framework_MockObject_MockObject $user */
+               $user = $this->createMock( User::class );
+               $user->expects( $this->once() )
+                       ->method( 'addWatch' )
+                       ->with( $title, $checkRights );
+
+               $item = new WatchedItem( $user, $title, $timestamp, $checkRights );
+               $this->assertTrue( $item->addWatch() );
+       }
+
+       public function testRemoveWatch() {
+               $title = Title::newFromText( 'SomeTitle' );
+               $timestamp = null;
+               $checkRights = 0;
+
+               /** @var User|PHPUnit_Framework_MockObject_MockObject $user */
+               $user = $this->createMock( User::class );
+               $user->expects( $this->once() )
+                       ->method( 'removeWatch' )
+                       ->with( $title, $checkRights );
+
+               $item = new WatchedItem( $user, $title, $timestamp, $checkRights );
+               $this->assertTrue( $item->removeWatch() );
+       }
+
+       public function provideBooleans() {
+               return [
+                       [ true ],
+                       [ false ],
+               ];
+       }
+
+       /**
+        * @dataProvider provideBooleans
+        */
+       public function testIsWatched( $returnValue ) {
+               $title = Title::newFromText( 'SomeTitle' );
+               $timestamp = null;
+               $checkRights = 0;
+
+               /** @var User|PHPUnit_Framework_MockObject_MockObject $user */
+               $user = $this->createMock( User::class );
+               $user->expects( $this->once() )
+                       ->method( 'isWatched' )
+                       ->with( $title, $checkRights )
+                       ->will( $this->returnValue( $returnValue ) );
+
+               $item = new WatchedItem( $user, $title, $timestamp, $checkRights );
+               $this->assertEquals( $returnValue, $item->isWatched() );
+       }
+
+       public function testDuplicateEntries() {
+               $oldTitle = Title::newFromText( 'OldTitle' );
+               $newTitle = Title::newFromText( 'NewTitle' );
+
+               $store = $this->getMockWatchedItemStore();
+               $store->expects( $this->once() )
+                       ->method( 'duplicateAllAssociatedEntries' )
+                       ->with( $oldTitle, $newTitle );
+               $this->setService( 'WatchedItemStore', $store );
+
+               WatchedItem::duplicateEntries( $oldTitle, $newTitle );
+       }
+
+}