diff options
author | Ammar Abdulhamid <ammarpad@yahoo.com> | 2020-08-23 01:28:34 +0100 |
---|---|---|
committer | Ammar Abdulhamid <ammarpad@yahoo.com> | 2020-09-29 16:20:20 +0100 |
commit | 07e547f47cae761489a33e9ebb8a9b108298f34e (patch) | |
tree | 04da4a227c70c61afb3152ba6fca29f62e58c6dc /includes/api/ApiWatchlistTrait.php | |
parent | fcd843b5aad0c6df91537b1a8c21bb3f2be1af7d (diff) | |
download | mediawikicore-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.php | 26 |
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; + } } |