NoWriteWatchedItemStore.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /**
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. * http://www.gnu.org/copyleft/gpl.html
  17. *
  18. * @file
  19. * @ingroup Watchlist
  20. */
  21. use MediaWiki\Linker\LinkTarget;
  22. use Wikimedia\Rdbms\DBReadOnlyError;
  23. /**
  24. * @internal
  25. * @since 1.31
  26. */
  27. class NoWriteWatchedItemStore implements WatchedItemStoreInterface {
  28. /**
  29. * @var WatchedItemStoreInterface
  30. */
  31. private $actualStore;
  32. /**
  33. * Initialy set WatchedItemStore that will be used in cases where writing is not needed.
  34. * @param WatchedItemStoreInterface $actualStore
  35. */
  36. public function __construct( WatchedItemStoreInterface $actualStore ) {
  37. $this->actualStore = $actualStore;
  38. }
  39. public function countWatchedItems( User $user ) {
  40. return $this->actualStore->countWatchedItems( $user );
  41. }
  42. public function countWatchers( LinkTarget $target ) {
  43. return $this->actualStore->countWatchers( $target );
  44. }
  45. public function countVisitingWatchers( LinkTarget $target, $threshold ) {
  46. return $this->actualStore->countVisitingWatchers( $target, $threshold );
  47. }
  48. public function countWatchersMultiple( array $targets, array $options = [] ) {
  49. return $this->actualStore->countVisitingWatchersMultiple( $targets, $options );
  50. }
  51. public function countVisitingWatchersMultiple(
  52. array $targetsWithVisitThresholds,
  53. $minimumWatchers = null
  54. ) {
  55. return $this->actualStore->countVisitingWatchersMultiple(
  56. $targetsWithVisitThresholds,
  57. $minimumWatchers
  58. );
  59. }
  60. public function getWatchedItem( User $user, LinkTarget $target ) {
  61. return $this->actualStore->getWatchedItem( $user, $target );
  62. }
  63. public function loadWatchedItem( User $user, LinkTarget $target ) {
  64. return $this->actualStore->loadWatchedItem( $user, $target );
  65. }
  66. public function getWatchedItemsForUser( User $user, array $options = [] ) {
  67. return $this->actualStore->getWatchedItemsForUser( $user, $options );
  68. }
  69. public function isWatched( User $user, LinkTarget $target ) {
  70. return $this->actualStore->isWatched( $user, $target );
  71. }
  72. public function getNotificationTimestampsBatch( User $user, array $targets ) {
  73. return $this->actualStore->getNotificationTimestampsBatch( $user, $targets );
  74. }
  75. public function countUnreadNotifications( User $user, $unreadLimit = null ) {
  76. return $this->actualStore->countUnreadNotifications( $user, $unreadLimit );
  77. }
  78. public function duplicateAllAssociatedEntries( LinkTarget $oldTarget, LinkTarget $newTarget ) {
  79. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  80. }
  81. public function duplicateEntry( LinkTarget $oldTarget, LinkTarget $newTarget ) {
  82. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  83. }
  84. public function addWatch( User $user, LinkTarget $target ) {
  85. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  86. }
  87. public function addWatchBatchForUser( User $user, array $targets ) {
  88. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  89. }
  90. public function removeWatch( User $user, LinkTarget $target ) {
  91. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  92. }
  93. public function setNotificationTimestampsForUser(
  94. User $user,
  95. $timestamp,
  96. array $targets = []
  97. ) {
  98. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  99. }
  100. public function updateNotificationTimestamp( User $editor, LinkTarget $target, $timestamp ) {
  101. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  102. }
  103. public function resetAllNotificationTimestampsForUser( User $user ) {
  104. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  105. }
  106. public function resetNotificationTimestamp(
  107. User $user,
  108. Title $title,
  109. $force = '',
  110. $oldid = 0
  111. ) {
  112. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  113. }
  114. public function clearUserWatchedItems( User $user ) {
  115. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  116. }
  117. public function clearUserWatchedItemsUsingJobQueue( User $user ) {
  118. throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' );
  119. }
  120. }