aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiWatchlistTrait.php
diff options
context:
space:
mode:
authorAmmar Abdulhamid <ammarpad@yahoo.com>2020-08-23 01:28:34 +0100
committerAmmar Abdulhamid <ammarpad@yahoo.com>2020-09-29 16:20:20 +0100
commit07e547f47cae761489a33e9ebb8a9b108298f34e (patch)
tree04da4a227c70c61afb3152ba6fca29f62e58c6dc /includes/api/ApiWatchlistTrait.php
parentfcd843b5aad0c6df91537b1a8c21bb3f2be1af7d (diff)
downloadmediawikicore-07e547f47cae761489a33e9ebb8a9b108298f34e.tar.gz
mediawikicore-07e547f47cae761489a33e9ebb8a9b108298f34e.zip
ApiEditPage: Show existing watchlist expiry if status is not being changed.
Bug: T261030 Change-Id: I795db12aefeffb1cfbbe2ab00fbb19444df7d37b
Diffstat (limited to 'includes/api/ApiWatchlistTrait.php')
-rw-r--r--includes/api/ApiWatchlistTrait.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/includes/api/ApiWatchlistTrait.php b/includes/api/ApiWatchlistTrait.php
index 675414e3c8da..1ab84d48afb1 100644
--- a/includes/api/ApiWatchlistTrait.php
+++ b/includes/api/ApiWatchlistTrait.php
@@ -140,4 +140,30 @@ trait ApiWatchlistTrait {
return $watchlistExpiry;
}
+
+ /**
+ * Get existing expiry from the database.
+ *
+ * @param WatchedItemStoreInterface $store
+ * @param Title $title
+ * @param User $user The user to get the expiry for.
+ * @return string|null
+ */
+ protected function getWatchlistExpiry(
+ WatchedItemStoreInterface $store,
+ Title $title,
+ User $user
+ ): ?string {
+ $watchedItem = $store->getWatchedItem( $user, $title );
+
+ if ( $watchedItem ) {
+ $expiry = $watchedItem->getExpiry();
+
+ if ( $expiry !== null ) {
+ return ApiResult::formatExpiry( $expiry );
+ }
+ }
+
+ return null;
+ }
}