From e01c7b8a87fa0263e4389c25927592b3f042842b Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Fri, 1 Feb 2019 16:55:29 +0100 Subject: [PATCH] watcheditem: Replace error message strings with constant string As the messages are the same and in addition using the same class DBReadOnlyError, make the error message a constant and pass it as self::DB_READONLY_ERROR argument to this class. Changing the error will apply to the class as intended rather than change it in each single place that this string appears. Change-Id: I7f978cc334020746b4c4405fa2a0a73219bdacac --- .../watcheditem/NoWriteWatchedItemStore.php | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/includes/watcheditem/NoWriteWatchedItemStore.php b/includes/watcheditem/NoWriteWatchedItemStore.php index f4e3af2370..28012078d0 100644 --- a/includes/watcheditem/NoWriteWatchedItemStore.php +++ b/includes/watcheditem/NoWriteWatchedItemStore.php @@ -32,6 +32,11 @@ class NoWriteWatchedItemStore implements WatchedItemStoreInterface { */ private $actualStore; + /** + * @var string + */ + const DB_READONLY_ERROR = 'The watchlist is currently readonly.'; + /** * Initialy set WatchedItemStore that will be used in cases where writing is not needed. * @param WatchedItemStoreInterface $actualStore @@ -91,23 +96,23 @@ class NoWriteWatchedItemStore implements WatchedItemStoreInterface { } public function duplicateAllAssociatedEntries( LinkTarget $oldTarget, LinkTarget $newTarget ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function duplicateEntry( LinkTarget $oldTarget, LinkTarget $newTarget ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function addWatch( User $user, LinkTarget $target ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function addWatchBatchForUser( User $user, array $targets ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function removeWatch( User $user, LinkTarget $target ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function setNotificationTimestampsForUser( @@ -115,15 +120,15 @@ class NoWriteWatchedItemStore implements WatchedItemStoreInterface { $timestamp, array $targets = [] ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function updateNotificationTimestamp( User $editor, LinkTarget $target, $timestamp ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function resetAllNotificationTimestampsForUser( User $user ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function resetNotificationTimestamp( @@ -132,19 +137,19 @@ class NoWriteWatchedItemStore implements WatchedItemStoreInterface { $force = '', $oldid = 0 ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function clearUserWatchedItems( User $user ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function clearUserWatchedItemsUsingJobQueue( User $user ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } public function removeWatchBatchForUser( User $user, array $titles ) { - throw new DBReadOnlyError( null, 'The watchlist is currently readonly.' ); + throw new DBReadOnlyError( null, self::DB_READONLY_ERROR ); } } -- 2.20.1