* Remove manual query building in search mysql
[lhc/web/wiklou.git] / includes / SiteStats.php
index b07bdbb..5a0d7a5 100644 (file)
@@ -163,8 +163,8 @@ class SiteStats {
        private static function isSane( $row ) {
                if(
                        $row === false
-                       or $row->ss_total_pages < $row->ss_good_articles
-                       or $row->ss_total_edits < $row->ss_total_pages
+                       || $row->ss_total_pages < $row->ss_good_articles
+                       || $row->ss_total_edits < $row->ss_total_pages
                ) {
                        return false;
                }
@@ -173,7 +173,7 @@ class SiteStats {
                'total_pages', 'users', 'admins', 'images' ) as $member ) {
                        if(
                                $row->{"ss_$member"} > 2000000000
-                               or $row->{"ss_$member"} < 0
+                               || $row->{"ss_$member"} < 0
                        ) {
                                return false;
                        }
@@ -234,6 +234,7 @@ class SiteStatsUpdate {
        }
 
        public static function cacheUpdate( $dbw ) {
+               global $wgActiveUserDays;
                $dbr = wfGetDB( DB_SLAVE, array( 'SpecialStatistics', 'vslow' ) );
                # Get non-bot users than did some recent action other than making accounts.
                # If account creation is included, the number gets inflated ~20+ fold on enwiki.
@@ -243,7 +244,8 @@ class SiteStatsUpdate {
                        array(
                                'rc_user != 0',
                                'rc_bot' => 0,
-                               "rc_log_type != 'newusers' OR rc_log_type IS NULL"
+                               "rc_log_type != 'newusers' OR rc_log_type IS NULL",
+                               "rc_timestamp >= '{$dbw->timestamp( wfTimestamp( TS_UNIX ) - $wgActiveUserDays*24*3600 )}'",
                        ),
                        __METHOD__
                );
@@ -291,17 +293,22 @@ class SiteStatsInit {
         * @return Integer
         */
        public function articles() {
-               global $wgContentNamespaces;
-               $this->mArticles = $this->db->selectField(
-                       'page',
-                       'COUNT(*)',
-                       array(
-                               'page_namespace' => $wgContentNamespaces,
-                               'page_is_redirect' => 0,
-                               'page_len > 0'
-                       ),
-                       __METHOD__
+               global $wgUseCommaCount;
+
+               $tables = array( 'page' );
+               $conds = array(
+                       'page_namespace' => MWNamespace::getContentNamespaces(),
+                       'page_is_redirect' => 0,
+                       'page_len > 0'
                );
+
+               if ( !$wgUseCommaCount ) {
+                       $tables[] = 'pagelinks';
+                       $conds[] = 'pl_from=page_id';
+               }
+
+               $this->mArticles = $this->db->selectField( $tables, 'COUNT(DISTINCT page_id)',
+                       $conds, __METHOD__ );
                return $this->mArticles;
        }