From: umherirrender Date: Thu, 31 May 2012 15:23:50 +0000 (+0200) Subject: cleanup EditWatchlist a bit X-Git-Tag: 1.31.0-rc.0~23456^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_add%27%29%20%7D%7D?a=commitdiff_plain;h=af74e25d7114ceaec0ff7eee4f72dff2dc3728a1;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ); } } }