Merge "Move BaseDump into includes/export/"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 9 Jan 2018 14:52:14 +0000 (14:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 9 Jan 2018 14:52:15 +0000 (14:52 +0000)
24 files changed:
autoload.php
docs/extension.schema.v1.json
docs/extension.schema.v2.json
docs/hooks.txt
includes/DefaultSettings.php
includes/ForkController.php
includes/GlobalFunctions.php
includes/ServiceWiring.php
includes/dao/DBAccessBase.php
includes/debug/logger/monolog/WikiProcessor.php
includes/exception/MWExceptionHandler.php
includes/libs/lockmanager/LockManager.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
includes/profiler/Profiler.php
includes/profiler/output/ProfilerOutputText.php
includes/specials/SpecialEditWatchlist.php
includes/utils/UIDGenerator.php
includes/watcheditem/NoWriteWatchedItemStore.php [new file with mode: 0644]
languages/i18n/en.json
maintenance/Maintenance.php
maintenance/generateLocalAutoload.php
maintenance/mwdoc-filter.php
tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php [new file with mode: 0644]

index 058d4f6..4a50894 100644 (file)
@@ -1048,6 +1048,7 @@ $wgAutoloadLocalClasses = [
        'NewFilesPager' => __DIR__ . '/includes/specials/pagers/NewFilesPager.php',
        'NewPagesPager' => __DIR__ . '/includes/specials/pagers/NewPagesPager.php',
        'NewUsersLogFormatter' => __DIR__ . '/includes/logging/NewUsersLogFormatter.php',
+       'NoWriteWatchedItemStore' => __DIR__ . '/includes/watcheditem/NoWriteWatchedItemStore.php',
        'NolinesImageGallery' => __DIR__ . '/includes/gallery/NolinesImageGallery.php',
        'NorthernSamiUppercaseCollation' => __DIR__ . '/includes/collation/NorthernSamiUppercaseCollation.php',
        'NotRecursiveIterator' => __DIR__ . '/includes/libs/iterators/NotRecursiveIterator.php',
index ddf82e8..0763e7d 100644 (file)
                                                                        "description": "Group which this module should be loaded together with"
                                                                },
                                                                "deprecated": {
-                                                                       "type": ["object", "boolean"],
-                                                                       "description": "Whether the module is deprecated and usage is discouraged. Either a boolean or an object with key message can be used to customise deprecation message."
+                                                                       "type": ["object", "string", "boolean"],
+                                                                       "description": "Whether the module is deprecated and usage is discouraged. Either a boolean, or a string or an object with key message can be used to customise deprecation message."
                                                                },
                                                                "position": {
                                                                        "type": "string",
index 0bdf97d..51f9417 100644 (file)
                                                                        "description": "Group with which this module should be loaded"
                                                                },
                                                                "deprecated": {
-                                                                       "type": ["object", "boolean"],
-                                                                       "description": "Whether the module is deprecated and usage is discouraged. Either a boolean or an object with key message can be used to customise deprecation message."
+                                                                       "type": ["object", "string", "boolean"],
+                                                                       "description": "Whether the module is deprecated and usage is discouraged. Either a boolean, or a string or an object with key message can be used to customise deprecation message."
                                                                },
                                                                "position": {
                                                                        "type": "string",
index 45387a3..2c6fc02 100644 (file)
@@ -3917,14 +3917,15 @@ dumps. One, and only one hook should set this, and return false.
 &$opts: Options to use for the query
 &$join: Join conditions
 
-'WikiPageDeletionUpdates': manipulate the list of DataUpdates to be applied when
+'WikiPageDeletionUpdates': manipulate the list of DeferrableUpdates to be applied when
 a page is deleted. Called in WikiPage::getDeletionUpdates(). Note that updates
 specific to a content model should be provided by the respective Content's
 getDeletionUpdates() method.
 $page: the WikiPage
-$content: the Content to generate updates for (or null, if the Content could not be loaded
-due to an error)
-&$updates: the array of DataUpdate objects. Hook function may want to add to it.
+$content: the Content to generate updates for, or null in case the page revision could not be
+  loaded. The delete will succeed despite this.
+&$updates: the array of objects that implement DeferrableUpdate. Hook function may want to add to
+  it.
 
 'WikiPageFactory': Override WikiPage class used for a title
 $title: Title of the page
index 8091428..ee10a6d 100644 (file)
@@ -6623,6 +6623,13 @@ $wgCommandLineDarkBg = false;
  */
 $wgReadOnly = null;
 
+/**
+ * Set this to true to put the wiki watchlists into read-only mode.
+ * @var bool
+ * @since 1.31
+ */
+$wgReadOnlyWatchedItemStore = false;
+
 /**
  * If this lock file exists (size > 0), the wiki will be forced into read-only mode.
  * Its contents will be shown to users as part of the read-only warning
index 2dde17b..cc16964 100644 (file)
@@ -54,7 +54,7 @@ class ForkController {
        const RESTART_ON_ERROR = 1;
 
        public function __construct( $numProcs, $flags = 0 ) {
-               if ( PHP_SAPI != 'cli' ) {
+               if ( !wfIsCLI() ) {
                        throw new MWException( "ForkController cannot be used from the web." );
                }
                $this->procsToStart = $numProcs;
index 310adeb..621dd65 100644 (file)
@@ -2088,6 +2088,16 @@ function wfIsHHVM() {
        return defined( 'HHVM_VERSION' );
 }
 
+/**
+ * Check if we are running from the commandline
+ *
+ * @since 1.31
+ * @return bool
+ */
+function wfIsCLI() {
+       return PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg';
+}
+
 /**
  * Tries to get the system directory for temporary files. First
  * $wgTmpDirectory is checked, and then the TMPDIR, TMP, and TEMP
@@ -3031,7 +3041,7 @@ function wfWaitForSlaves(
        $ifWritesSince = null, $wiki = false, $cluster = false, $timeout = null
 ) {
        if ( $timeout === null ) {
-               $timeout = ( PHP_SAPI === 'cli' ) ? 86400 : 10;
+               $timeout = wfIsCLI() ? 86400 : 10;
        }
 
        if ( $cluster === '*' ) {
index 246b838..79e5b84 100644 (file)
@@ -166,6 +166,11 @@ return [
                        $services->getReadOnlyMode()
                );
                $store->setStatsdDataFactory( $services->getStatsdDataFactory() );
+
+               if ( $services->getMainConfig()->get( 'ReadOnlyWatchedItemStore' ) ) {
+                       $store = new NoWriteWatchedItemStore( $store );
+               }
+
                return $store;
        },
 
index 0f8d7f7..6e171d5 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-use Wikimedia\Rdbms\Database;
+use Wikimedia\Rdbms\IDatabase;
 use Wikimedia\Rdbms\LoadBalancer;
 
 /**
@@ -56,7 +56,7 @@ abstract class DBAccessBase implements IDBAccessObject {
         * @param int $id Which connection to use
         * @param array $groups Query groups
         *
-        * @return Database
+        * @return IDatabase
         */
        protected function getConnection( $id, $groups = [] ) {
                $loadBalancer = wfGetLB( $this->wiki );
@@ -71,9 +71,9 @@ abstract class DBAccessBase implements IDBAccessObject {
         *
         * @since 1.21
         *
-        * @param Database $db The database connection to release.
+        * @param IDatabase $db The database connection to release.
         */
-       protected function releaseConnection( Database $db ) {
+       protected function releaseConnection( IDatabase $db ) {
                if ( $this->wiki !== false ) {
                        $loadBalancer = $this->getLoadBalancer();
                        $loadBalancer->reuseConnection( $db );
index e39a2c3..db5b9bf 100644 (file)
@@ -39,7 +39,7 @@ class WikiProcessor {
                $record['extra']['wiki'] = wfWikiID();
                $record['extra']['mwversion'] = $wgVersion;
                $record['extra']['reqId'] = \WebRequest::getRequestId();
-               if ( PHP_SAPI === 'cli' && isset( $_SERVER['argv'] ) ) {
+               if ( wfIsCLI() && isset( $_SERVER['argv'] ) ) {
                        $record['extra']['cli_argv'] = implode( ' ', $_SERVER['argv'] );
                }
                return $record;
index f3d61f0..d863a2b 100644 (file)
@@ -121,7 +121,7 @@ class MWExceptionHandler {
                self::handleException( $e );
 
                // Make sure we don't claim success on exit for CLI scripts (T177414)
-               if ( PHP_SAPI === 'cli' ) {
+               if ( wfIsCLI() ) {
                        register_shutdown_function(
                                function () {
                                        exit( 255 );
index a6257bf..6b3cfb4 100644 (file)
@@ -83,7 +83,7 @@ abstract class LockManager {
                $this->domain = isset( $config['domain'] ) ? $config['domain'] : 'global';
                if ( isset( $config['lockTTL'] ) ) {
                        $this->lockTTL = max( 5, $config['lockTTL'] );
-               } elseif ( PHP_SAPI === 'cli' ) {
+               } elseif ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) {
                        $this->lockTTL = 3600;
                } else {
                        $met = ini_get( 'max_execution_time' ); // this is 0 in CLI mode
index 0ee10ed..2eb5c54 100644 (file)
@@ -394,7 +394,9 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
                        $p['variables'] = isset( $p['variables'] ) ? $p['variables'] : [];
                        $p['tablePrefix'] = isset( $p['tablePrefix'] ) ? $p['tablePrefix'] : '';
                        $p['schema'] = isset( $p['schema'] ) ? $p['schema'] : '';
-                       $p['cliMode'] = isset( $p['cliMode'] ) ? $p['cliMode'] : ( PHP_SAPI === 'cli' );
+                       $p['cliMode'] = isset( $p['cliMode'] )
+                               ? $p['cliMode']
+                               : ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
                        $p['agent'] = isset( $p['agent'] ) ? $p['agent'] : '';
                        if ( !isset( $p['connLogger'] ) ) {
                                $p['connLogger'] = new \Psr\Log\NullLogger();
index deacc42..a75dc4d 100644 (file)
@@ -232,7 +232,9 @@ class LoadBalancer implements ILoadBalancer {
                $this->host = isset( $params['hostname'] )
                        ? $params['hostname']
                        : ( gethostname() ?: 'unknown' );
-               $this->cliMode = isset( $params['cliMode'] ) ? $params['cliMode'] : PHP_SAPI === 'cli';
+               $this->cliMode = isset( $params['cliMode'] )
+                       ? $params['cliMode']
+                       : ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
                $this->agent = isset( $params['agent'] ) ? $params['agent'] : '';
 
                if ( isset( $params['chronologyProtector'] ) ) {
index 4da7976..81449be 100644 (file)
@@ -74,7 +74,8 @@ abstract class Profiler {
                        }
 
                        $inSample = mt_rand( 0, $params['sampling'] - 1 ) === 0;
-                       if ( PHP_SAPI === 'cli' || !$inSample ) {
+                       // wfIsCLI() is not available yet
+                       if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' || !$inSample ) {
                                $params['class'] = 'ProfilerStub';
                        }
 
index dc24f18..100304f 100644 (file)
@@ -59,7 +59,7 @@ class ProfilerOutputText extends ProfilerOutput {
                        );
 
                        $contentType = $this->collector->getContentType();
-                       if ( PHP_SAPI === 'cli' ) {
+                       if ( wfIsCLI() ) {
                                print "<!--\n{$out}\n-->\n";
                        } elseif ( $contentType === 'text/html' ) {
                                $visible = isset( $this->params['visible'] ) ?
index d2940e4..09ea9ea 100644 (file)
@@ -29,6 +29,7 @@
 use MediaWiki\Linker\LinkRenderer;
 use MediaWiki\Linker\LinkTarget;
 use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\DBReadOnlyError;
 
 /**
  * Provides the UI through which users can perform editing
@@ -451,6 +452,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         * Remove all titles from a user's watchlist
         */
        private function clearWatchlist() {
+               if ( $this->getConfig()->get( 'ReadOnlyWatchedItemStore' ) ) {
+                       throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+               }
+
                $dbw = wfGetDB( DB_MASTER );
                $dbw->delete(
                        'watchlist',
index 736109b..68ef57a 100644 (file)
@@ -367,7 +367,7 @@ class UIDGenerator {
                // Use APC/eAccelerator/xcache if requested, available, and not in CLI mode;
                // Counter values would not survive accross script instances in CLI mode.
                $cache = null;
-               if ( ( $flags & self::QUICK_VOLATILE ) && PHP_SAPI !== 'cli' ) {
+               if ( ( $flags & self::QUICK_VOLATILE ) && !wfIsCLI() ) {
                        $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
                }
                if ( $cache ) {
diff --git a/includes/watcheditem/NoWriteWatchedItemStore.php b/includes/watcheditem/NoWriteWatchedItemStore.php
new file mode 100644 (file)
index 0000000..1439421
--- /dev/null
@@ -0,0 +1,134 @@
+<?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\Linker\LinkTarget;
+use Wikimedia\Rdbms\DBReadOnlyError;
+
+/**
+ * @internal
+ * @since 1.31
+ */
+class NoWriteWatchedItemStore implements WatchedItemStoreInterface {
+
+       /**
+        * @var WatchedItemStoreInterface
+        */
+       private $actualStore;
+
+       /**
+        * Initialy set WatchedItemStore that will be used in cases where writing is not needed.
+        * @param WatchedItemStoreInterface $actualStore
+        */
+       public function __construct( WatchedItemStoreInterface $actualStore ) {
+               $this->actualStore = $actualStore;
+       }
+
+       public function countWatchedItems( User $user ) {
+               return $this->actualStore->countWatchedItems( $user );
+       }
+
+       public function countWatchers( LinkTarget $target ) {
+               return $this->actualStore->countWatchers( $target );
+       }
+
+       public function countVisitingWatchers( LinkTarget $target, $threshold ) {
+               return $this->actualStore->countVisitingWatchers( $target, $threshold );
+       }
+
+       public function countWatchersMultiple( array $targets, array $options = [] ) {
+               return $this->actualStore->countVisitingWatchersMultiple( $targets, $options );
+       }
+
+       public function countVisitingWatchersMultiple(
+               array $targetsWithVisitThresholds,
+               $minimumWatchers = null
+       ) {
+               return $this->actualStore->countVisitingWatchersMultiple(
+                       $targetsWithVisitThresholds,
+                       $minimumWatchers
+               );
+       }
+
+       public function getWatchedItem( User $user, LinkTarget $target ) {
+               return $this->actualStore->getWatchedItem( $user, $target );
+       }
+
+       public function loadWatchedItem( User $user, LinkTarget $target ) {
+               return $this->actualStore->loadWatchedItem( $user, $target );
+       }
+
+       public function getWatchedItemsForUser( User $user, array $options = [] ) {
+               return $this->actualStore->getWatchedItemsForUser( $user, $options );
+       }
+
+       public function isWatched( User $user, LinkTarget $target ) {
+               return $this->actualStore->isWatched( $user, $target );
+       }
+
+       public function getNotificationTimestampsBatch( User $user, array $targets ) {
+               return $this->actualStore->getNotificationTimestampsBatch( $user, $targets );
+       }
+
+       public function countUnreadNotifications( User $user, $unreadLimit = null ) {
+               return $this->actualStore->countUnreadNotifications( $user, $unreadLimit );
+       }
+
+       public function duplicateAllAssociatedEntries( LinkTarget $oldTarget, LinkTarget $newTarget ) {
+               throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+       }
+
+       public function duplicateEntry( LinkTarget $oldTarget, LinkTarget $newTarget ) {
+               throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+       }
+
+       public function addWatch( User $user, LinkTarget $target ) {
+               throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+       }
+
+       public function addWatchBatchForUser( User $user, array $targets ) {
+               throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+       }
+
+       public function removeWatch( User $user, LinkTarget $target ) {
+               throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+       }
+
+       public function setNotificationTimestampsForUser(
+               User $user,
+               $timestamp,
+               array $targets = []
+       ) {
+               throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+       }
+
+       public function updateNotificationTimestamp( User $editor, LinkTarget $target, $timestamp ) {
+               throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+       }
+
+       public function resetNotificationTimestamp(
+               User $user,
+               Title $title,
+               $force = '',
+               $oldid = 0
+       ) {
+               throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
+       }
+
+}
index ab4080d..2b48338 100644 (file)
        "rcfilters-activefilters": "Active filters",
        "rcfilters-advancedfilters": "Advanced filters",
        "rcfilters-limit-title": "Results to show",
-       "rcfilters-limit-and-date-label": "{{PLURAL:$1|change|$1 changes}}, $2",
+       "rcfilters-limit-and-date-label": "$1 {{PLURAL:$1|change|changes}}, $2",
        "rcfilters-date-popup-title": "Time period to search",
        "rcfilters-days-title": "Recent days",
        "rcfilters-hours-title": "Recent hours",
index 8bfead3..861a613 100644 (file)
@@ -414,7 +414,7 @@ abstract class Maintenance {
                        $this->fatalError( $err, intval( $die ) );
                }
                $this->outputChanneled( false );
-               if ( PHP_SAPI == 'cli' ) {
+               if ( PHP_SAPI == 'cli' || PHP_SAPI == 'phpdbg' ) {
                        fwrite( STDERR, $err . "\n" );
                } else {
                        print $err;
@@ -676,7 +676,8 @@ abstract class Maintenance {
                global $IP, $wgCommandLineMode, $wgRequestTime;
 
                # Abort if called from a web server
-               if ( PHP_SAPI !== 'cli' ) {
+               # wfIsCLI() is not available yet
+               if ( PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg' ) {
                        $this->fatalError( 'This script must be run from the command line' );
                }
 
index bec11a0..189858c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-if ( PHP_SAPI != 'cli' ) {
+if ( PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg' ) {
        die( "This script can only be run from the command line.\n" );
 }
 
index feaad12..89fc44b 100644 (file)
@@ -39,7 +39,7 @@
  */
 
 // Warning: Converting this to a Maintenance script may reduce performance.
-if ( PHP_SAPI != 'cli' ) {
+if ( PHP_SAPI != 'cli' && PHP_SAPI != 'phpdbg' ) {
        die( "This filter can only be run from the command line.\n" );
 }
 
diff --git a/tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php b/tests/phpunit/includes/watcheditem/NoWriteWatchedItemStoreUnitTest.php
new file mode 100644 (file)
index 0000000..a8761e3
--- /dev/null
@@ -0,0 +1,246 @@
+<?php
+
+/**
+ * @author Addshore
+ *
+ * @covers NoWriteWatchedItemStore
+ */
+class NoWriteWatchedItemStoreUnitTest extends MediaWikiTestCase {
+
+       public function testAddWatch() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'addWatch' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->addWatch( $this->getTestSysop()->getUser(), new TitleValue( 0, 'Foo' ) );
+       }
+
+       public function testAddWatchBatchForUser() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'addWatchBatchForUser' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->addWatchBatchForUser( $this->getTestSysop()->getUser(), [] );
+       }
+
+       public function testRemoveWatch() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'removeWatch' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->removeWatch( $this->getTestSysop()->getUser(), new TitleValue( 0, 'Foo' ) );
+       }
+
+       public function testSetNotificationTimestampsForUser() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'setNotificationTimestampsForUser' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->setNotificationTimestampsForUser(
+                       $this->getTestSysop()->getUser(),
+                       'timestamp',
+                       []
+               );
+       }
+
+       public function testUpdateNotificationTimestamp() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'updateNotificationTimestamp' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->updateNotificationTimestamp(
+                       $this->getTestSysop()->getUser(),
+                       new TitleValue( 0, 'Foo' ),
+                       'timestamp'
+               );
+       }
+
+       public function testResetNotificationTimestamp() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->never() )->method( 'resetNotificationTimestamp' );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->resetNotificationTimestamp(
+                       $this->getTestSysop()->getUser(),
+                       Title::newFromText( 'Foo' )
+               );
+       }
+
+       public function testCountWatchedItems() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'countWatchedItems' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countWatchedItems(
+                       $this->getTestSysop()->getUser()
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountWatchers() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'countWatchers' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countWatchers(
+                       new TitleValue( 0, 'Foo' )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountVisitingWatchers() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'countVisitingWatchers' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countVisitingWatchers(
+                       new TitleValue( 0, 'Foo' ),
+                       9
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountWatchersMultiple() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'countVisitingWatchersMultiple' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countWatchersMultiple(
+                       [ new TitleValue( 0, 'Foo' ) ],
+                       []
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountVisitingWatchersMultiple() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'countVisitingWatchersMultiple' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countVisitingWatchersMultiple(
+                       [ [ new TitleValue( 0, 'Foo' ), 99 ] ],
+                       11
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testGetWatchedItem() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'getWatchedItem' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->getWatchedItem(
+                       $this->getTestSysop()->getUser(),
+                       new TitleValue( 0, 'Foo' )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testLoadWatchedItem() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'loadWatchedItem' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->loadWatchedItem(
+                       $this->getTestSysop()->getUser(),
+                       new TitleValue( 0, 'Foo' )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testGetWatchedItemsForUser() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'getWatchedItemsForUser' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->getWatchedItemsForUser(
+                       $this->getTestSysop()->getUser(),
+                       []
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testIsWatched() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )->method( 'isWatched' )->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->isWatched(
+                       $this->getTestSysop()->getUser(),
+                       new TitleValue( 0, 'Foo' )
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testGetNotificationTimestampsBatch() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'getNotificationTimestampsBatch' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->getNotificationTimestampsBatch(
+                       $this->getTestSysop()->getUser(),
+                       [ new TitleValue( 0, 'Foo' ) ]
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testCountUnreadNotifications() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $innerService->expects( $this->once() )
+                       ->method( 'countUnreadNotifications' )
+                       ->willReturn( __METHOD__ );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $return = $noWriteService->countUnreadNotifications(
+                       $this->getTestSysop()->getUser(),
+                       88
+               );
+               $this->assertEquals( __METHOD__, $return );
+       }
+
+       public function testDuplicateAllAssociatedEntries() {
+               /** @var WatchedItemStoreInterface|PHPUnit_Framework_MockObject_MockObject $innerService */
+               $innerService = $this->getMockForAbstractClass( WatchedItemStoreInterface::class );
+               $noWriteService = new NoWriteWatchedItemStore( $innerService );
+
+               $this->setExpectedException( DBReadOnlyError::class );
+               $noWriteService->duplicateAllAssociatedEntries(
+                       new TitleValue( 0, 'Foo' ),
+                       new TitleValue( 0, 'Bar' )
+               );
+       }
+
+}