diff options
Diffstat (limited to 'includes/watcheditem')
-rw-r--r-- | includes/watcheditem/WatchedItemStore.php | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/includes/watcheditem/WatchedItemStore.php b/includes/watcheditem/WatchedItemStore.php index 33b372b08d38..759b85cc8c8b 100644 --- a/includes/watcheditem/WatchedItemStore.php +++ b/includes/watcheditem/WatchedItemStore.php @@ -250,11 +250,37 @@ class WatchedItemStore implements WatchedItemStoreInterface, StatsdAwareInterfac } $dbw = $this->loadBalancer->getConnectionRef( DB_MASTER ); - $dbw->delete( - 'watchlist', - [ 'wl_user' => $user->getId() ], - __METHOD__ - ); + + if ( $this->expiryEnabled ) { + $ticket = $this->lbFactory->getEmptyTransactionTicket( __METHOD__ ); + // First fetch the wl_ids. + $wlIds = $dbw->selectFieldValues( 'watchlist', 'wl_id', [ + 'wl_user' => $user->getId() + ] ); + + if ( $wlIds ) { + // Delete rows from both the watchlist and watchlist_expiry tables. + $dbw->delete( + 'watchlist', + [ 'wl_id' => $wlIds ], + __METHOD__ + ); + + $dbw->delete( + 'watchlist_expiry', + [ 'we_item' => $wlIds ], + __METHOD__ + ); + } + $this->lbFactory->commitAndWaitForReplication( __METHOD__, $ticket ); + } else { + $dbw->delete( + 'watchlist', + [ 'wl_user' => $user->getId() ], + __METHOD__ + ); + } + $this->uncacheAllItemsForUser( $user ); return true; |