X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSiteStats.php;h=3dc17933b02d8c6cc8ae36a94896416138c371bf;hb=50a12ff5ca4fa1bfcc6e4baaa10aa306ffd69812;hp=4e737d136e3bba5fd1f6e94f27f18816d72db31a;hpb=4f42c2bbe4184830986910f9374bf913590b0096;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 4e737d136e..3dc17933b0 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -170,7 +170,7 @@ class SiteStats { /** * Find the number of users in a given user group. - * @param string $group name of group + * @param string $group Name of group * @return int */ static function numberingroup( $group ) { @@ -273,7 +273,8 @@ class SiteStatsInit { private $db; // Various stats - private $mEdits, $mArticles, $mPages, $mUsers, $mViews, $mFiles = 0; + private $mEdits = null, $mArticles = null, $mPages = null; + private $mUsers = null, $mViews = null, $mFiles = null; /** * Constructor @@ -372,7 +373,7 @@ class SiteStatsInit { * @param DatabaseBase|bool $database * - Boolean: whether to use the master DB * - DatabaseBase: database connection to use - * @param array $options of options, may contain the following values + * @param array $options Array of options, may contain the following values * - views Boolean: when true, do not update the number of page views (default: true) * - activeUsers Boolean: whether to update the number of active users (default: false) */ @@ -402,16 +403,17 @@ class SiteStatsInit { } /** - * Refresh site_stats. + * Refresh site_stats. If you want ss_total_views to be updated, be sure to + * call views() first. */ - protected function refresh() { + public function refresh() { $values = array( 'ss_row_id' => 1, - 'ss_total_edits' => $this->mEdits, - 'ss_good_articles' => $this->mArticles, - 'ss_total_pages' => $this->mPages, - 'ss_users' => $this->mUsers, - 'ss_images' => $this->mFiles, + 'ss_total_edits' => ( $this->mEdits === null ? $this->edits() : $this->mEdits ), + 'ss_good_articles' => ( $this->mArticles === null ? $this->articles() : $this->mArticles ), + 'ss_total_pages' => ( $this->mPages === null ? $this->pages() : $this->mPages ), + 'ss_users' => ( $this->mUsers === null ? $this->users() : $this->mUsers ), + 'ss_images' => ( $this->mFiles === null ? $this->files() : $this->mFiles ), ) + ( $this->mViews ? array( 'ss_total_views' => $this->mViews ) : array() );