- $this->mArticles = $this->db->selectField( $tables, 'COUNT(DISTINCT page_id)',
- $conds, __METHOD__ );
- return $this->mArticles;
- }
-
- /**
- * Count total pages
- * @return int
- */
- public function pages() {
- $this->mPages = $this->db->selectField( 'page', 'COUNT(*)', '', __METHOD__ );
- return $this->mPages;
- }
-
- /**
- * Count total users
- * @return int
- */
- public function users() {
- $this->mUsers = $this->db->selectField( 'user', 'COUNT(*)', '', __METHOD__ );
- return $this->mUsers;
- }
-
- /**
- * Count total files
- * @return int
- */
- public function files() {
- $this->mFiles = $this->db->selectField( 'image', 'COUNT(*)', '', __METHOD__ );
- return $this->mFiles;
- }
-
- /**
- * Do all updates and commit them. More or less a replacement
- * for the original initStats, but without output.
- *
- * @param IDatabase|bool $database
- * - boolean: Whether to use the master DB
- * - IDatabase: Database connection to use
- * @param array $options Array of options, may contain the following values
- * - activeUsers boolean: Whether to update the number of active users (default: false)
- */
- public static function doAllAndCommit( $database, array $options = [] ) {
- $options += [ 'update' => false, 'activeUsers' => false ];
-
- // Grab the object and count everything
- $counter = new SiteStatsInit( $database );
-
- $counter->edits();
- $counter->articles();
- $counter->pages();
- $counter->users();
- $counter->files();
-
- $counter->refresh();
-
- // Count active users if need be
- if ( $options['activeUsers'] ) {
- SiteStatsUpdate::cacheUpdate( wfGetDB( DB_MASTER ) );
- }