From af74e25d7114ceaec0ff7eee4f72dff2dc3728a1 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Thu, 31 May 2012 17:23:50 +0200 Subject: [PATCH] cleanup EditWatchlist a bit * set fields explict in select statement * get database connection only, if there is anything to do * store often used object in local var Change-Id: I41325ee0fdd935e48e2539668dfa0a46ff04af51 --- includes/specials/SpecialEditWatchlist.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index b7f1e61686..3d43831b1d 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -241,8 +241,9 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { $dbr = wfGetDB( DB_MASTER ); $res = $dbr->select( 'watchlist', - '*', array( + 'wl_namespace', 'wl_title' + ), array( 'wl_user' => $this->getUser()->getId(), ), __METHOD__ @@ -321,16 +322,20 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { * Attempts to clean up broken items */ private function cleanupWatchlist() { + if( !count( $this->badItems ) ) { + return; //nothing to do + } $dbw = wfGetDB( DB_MASTER ); + $user = $this->getUser(); foreach ( $this->badItems as $row ) { list( $title, $namespace, $dbKey ) = $row; - wfDebug( "User {$this->getUser()} has broken watchlist item ns($namespace):$dbKey, " + wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, " . ( $title ? 'cleaning up' : 'deleting' ) . ".\n" ); $dbw->delete( 'watchlist', array( - 'wl_user' => $this->getUser()->getId(), + 'wl_user' => $user->getId(), 'wl_namespace' => $namespace, 'wl_title' => $dbKey, ), @@ -339,7 +344,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { // Can't just do an UPDATE instead of DELETE/INSERT due to unique index if ( $title ) { - $this->getUser()->addWatch( $title ); + $user->addWatch( $title ); } } } -- 2.20.1