From 086ae52d12011746a75f5588e877347bc0457352 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 21 Mar 2008 11:49:34 +0100 Subject: Update auf MediaWiki 1.12.0 --- includes/SpecialWatchlist.php | 50 +++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'includes/SpecialWatchlist.php') diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index e9aa7e68..2dfa8ae5 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -87,19 +87,11 @@ function wfSpecialWatchlist( $par ) { $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); list( $page, $watchlist, $recentchanges ) = $dbr->tableNamesN( 'page', 'watchlist', 'recentchanges' ); - $sql = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_user=$uid"; - $res = $dbr->query( $sql, $fname ); - $s = $dbr->fetchObject( $res ); - -# Patch *** A1 *** (see A2 below) -# adjust for page X, talk:page X, which are both stored separately, but treated together - $nitems = floor($s->n / 2); -# $nitems = $s->n; - - if($nitems == 0) { - $wgOut->addWikiText( wfMsg( 'nowatchlist' ) ); - return; - } + $watchlistCount = $dbr->selectField( 'watchlist', 'COUNT(*)', + array( 'wl_user' => $uid ), __METHOD__ ); + // Adjust for page X, talk:page X, which are both stored separately, + // but treated together + $nitems = floor($watchlistCount / 2); if( is_null($days) || !is_numeric($days) ) { $big = 1000; /* The magical big */ @@ -122,6 +114,16 @@ function wfSpecialWatchlist( $par ) { wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults ); wfAppendToArrayIfNotDefault('namespace', $nameSpace , $defaults, $nondefaults); + $hookSql = ""; + if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser, &$hookSql)) ) { + return; + } + + if($nitems == 0) { + $wgOut->addWikiMsg( 'nowatchlist' ); + return; + } + if ( $days <= 0 ) { $andcutoff = ''; } else { @@ -180,8 +182,10 @@ function wfSpecialWatchlist( $par ) { '" />' . "\n\n" ); } - - $sql = "SELECT * + if ( $wgShowUpdatedMarker ) { + $wltsfield=", ${watchlist}.wl_notificationtimestamp "; + } + $sql = "SELECT ${recentchanges}.* ${wltsfield} FROM $watchlist,$recentchanges,$page WHERE wl_user=$uid AND wl_namespace=rc_namespace @@ -193,6 +197,7 @@ function wfSpecialWatchlist( $par ) { $andHideBots $andHideMinor $nameSpaceClause + $hookSql ORDER BY rc_timestamp DESC $limitWatchlist"; @@ -251,7 +256,7 @@ function wfSpecialWatchlist( $par ) { # If there's nothing to show, stop here if( $numRows == 0 ) { - $wgOut->addWikiText( wfMsgNoTrans( 'watchnochange' ) ); + $wgOut->addWikiMsg( 'watchnochange' ); return; } @@ -286,10 +291,13 @@ function wfSpecialWatchlist( $par ) { } if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) { - $sql3 = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_title='" .$dbr->strencode($obj->page_title). "' AND wl_namespace='{$obj->page_namespace}'" ; - $res3 = $dbr->query( $sql3, $fname ); - $x = $dbr->fetchObject( $res3 ); - $rc->numberofWatchingusers = $x->n; + $rc->numberofWatchingusers = $dbr->selectField( 'watchlist', + 'COUNT(*)', + array( + 'wl_namespace' => $obj->rc_namespace, + 'wl_title' => $obj->rc_title, + ), + __METHOD__ ); } else { $rc->numberofWatchingusers = 0; } @@ -364,4 +372,4 @@ function wlCountItems( &$user, $talk = true ) { $count = floor( $count / 2 ); return( $count ); -} \ No newline at end of file +} -- cgit v1.2.3-54-g00ecf