Revert "Adding a bunch of hooks from wikiHow into DifferenceEngine"
[lhc/web/wiklou.git] / includes / api / ApiQueryUserInfo.php
index 9e7e62e..d3cd0c4 100644 (file)
@@ -24,6 +24,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Query module to get information about the currently logged-in user
  *
@@ -225,23 +227,16 @@ class ApiQueryUserInfo extends ApiQueryBase {
                }
 
                if ( isset( $this->prop['unreadcount'] ) ) {
-                       $dbr = $this->getQuery()->getNamedDB( 'watchlist', DB_SLAVE, 'watchlist' );
-
-                       $count = $dbr->selectRowCount(
-                               'watchlist',
-                               '1',
-                               [
-                                       'wl_user' => $user->getId(),
-                                       'wl_notificationtimestamp IS NOT NULL',
-                               ],
-                               __METHOD__,
-                               [ 'LIMIT' => self::WL_UNREAD_LIMIT ]
+                       $store = MediaWikiServices::getInstance()->getWatchedItemStore();
+                       $unreadNotifications = $store->countUnreadNotifications(
+                               $user,
+                               self::WL_UNREAD_LIMIT
                        );
 
-                       if ( $count >= self::WL_UNREAD_LIMIT ) {
+                       if ( $unreadNotifications === true ) {
                                $vals['unreadcount'] = self::WL_UNREAD_LIMIT . '+';
                        } else {
-                               $vals['unreadcount'] = $count;
+                               $vals['unreadcount'] = $unreadNotifications;
                        }
                }