private function getWatchlist() {
$list = [];
- $index = $this->getRequest()->wasPosted() ? DB_MASTER : DB_SLAVE;
- $dbr = wfGetDB( $index );
-
- $res = $dbr->select(
- 'watchlist',
- [
- 'wl_namespace', 'wl_title'
- ], [
- 'wl_user' => $this->getUser()->getId(),
- ],
- __METHOD__
+ $watchedItems = WatchedItemStore::getDefaultInstance()->getWatchedItemsForUser(
+ $this->getUser(),
+ [ 'forWrite' => $this->getRequest()->wasPosted() ]
);
- if ( $res->numRows() > 0 ) {
+ if ( $watchedItems ) {
/** @var Title[] $titles */
$titles = [];
- foreach ( $res as $row ) {
- $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
+ foreach ( $watchedItems as $watchedItem ) {
+ $namespace = $watchedItem->getLinkTarget()->getNamespace();
+ $dbKey = $watchedItem->getLinkTarget()->getDBkey();
+ $title = Title::makeTitleSafe( $namespace, $dbKey );
- if ( $this->checkTitle( $title, $row->wl_namespace, $row->wl_title )
+ if ( $this->checkTitle( $title, $namespace, $dbKey )
&& !$title->isTalkPage()
) {
$titles[] = $title;
}
}
- $res->free();
GenderCache::singleton()->doTitlesArray( $titles );