From: Andrew Garrett Date: Wed, 30 Sep 2009 17:58:00 +0000 (+0000) Subject: Randomly generate a watchlist token on-demand if a watchlist is loaded and the user... X-Git-Tag: 1.31.0-rc.0~39457 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=96d307ce12db532ea868269a99e8d2729a183a5d;p=lhc%2Fweb%2Fwiklou.git Randomly generate a watchlist token on-demand if a watchlist is loaded and the user has no watchlist token. --- diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 1d04272368..d43973d7d9 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -16,17 +16,21 @@ function wfSpecialWatchlist( $par ) { // Add feed links $wlToken = $wgUser->getOption( 'watchlisttoken' ); - if ($wlToken) { - global $wgServer, $wgScriptPath, $wgFeedClasses; - $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 'allrev', - 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken ); - $feedTemplate = $wgServer . $wgScriptPath . '/api.php?'; - - foreach( $wgFeedClasses as $format => $class ) { - $theseParams = $apiParams + array( 'feedformat' => $format ); - $url = $feedTemplate . wfArrayToCGI( $theseParams ); - $wgOut->addFeedLink( $format, $url ); - } + if (!$wlToken) { + $wlToken = sha1( mt_rand() . microtime( true ) ); + $wgUser->setOption( 'watchlisttoken', $wlToken ); + $wgUser->saveSettings(); + } + + global $wgServer, $wgScriptPath, $wgFeedClasses; + $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 'allrev', + 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken ); + $feedTemplate = $wgServer . $wgScriptPath . '/api.php?'; + + foreach( $wgFeedClasses as $format => $class ) { + $theseParams = $apiParams + array( 'feedformat' => $format ); + $url = $feedTemplate . wfArrayToCGI( $theseParams ); + $wgOut->addFeedLink( $format, $url ); } $skin = $wgUser->getSkin();