Merge "jquery.suggestions: Hide the suggestions list asynchronously"
[lhc/web/wiklou.git] / includes / specials / SpecialActiveusers.php
index 641c046..c42c089 100644 (file)
  * @ingroup SpecialPage
  */
 class ActiveUsersPager extends UsersPager {
-
        /**
         * @var FormOptions
         */
        protected $opts;
 
        /**
-        * @var Array
+        * @var array
         */
        protected $hideGroups = array();
 
        /**
-        * @var Array
+        * @var array
         */
        protected $hideRights = array();
 
        /**
-        * @param $context IContextSource
-        * @param $group null Unused
+        * @param IContextSource $context
+        * @param null $group Unused
         * @param string $par Parameter passed to the page
         */
        function __construct( IContextSource $context = null, $group = null, $par = null ) {
@@ -97,7 +96,8 @@ class ActiveUsersPager extends UsersPager {
                        'qcc_type' => 'activeusers',
                        'qcc_namespace' => NS_USER,
                        'user_name = qcc_title',
-                       'rc_user_text = qcc_title'
+                       'rc_user_text = qcc_title',
+                       'rc_type != ' . $dbr->addQuotes( RC_EXTERNAL ) // Don't count wikidata.
                );
                if ( $this->requestedUser != '' ) {
                        $conds[] = 'qcc_title >= ' . $dbr->addQuotes( $this->requestedUser );
@@ -193,20 +193,31 @@ class ActiveUsersPager extends UsersPager {
                $self = $this->getTitle();
                $limit = $this->mLimit ? Html::hidden( 'limit', $this->mLimit ) : '';
 
-               $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); # Form tag
+               # Form tag
+               $out = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
                $out .= Xml::fieldset( $this->msg( 'activeusers' )->text() ) . "\n";
                $out .= Html::hidden( 'title', $self->getPrefixedDBkey() ) . $limit . "\n";
 
+               # Username field
                $out .= Xml::inputLabel( $this->msg( 'activeusers-from' )->text(),
-                       'username', 'offset', 20, $this->requestedUser, array( 'tabindex' => 1 ) ) . '<br />';# Username field
+                       'username', 'offset', 20, $this->requestedUser, array( 'tabindex' => 1 ) ) . '<br />';
 
                $out .= Xml::checkLabel( $this->msg( 'activeusers-hidebots' )->text(),
                        'hidebots', 'hidebots', $this->opts->getValue( 'hidebots' ), array( 'tabindex' => 2 ) );
 
-               $out .= Xml::checkLabel( $this->msg( 'activeusers-hidesysops' )->text(),
-                       'hidesysops', 'hidesysops', $this->opts->getValue( 'hidesysops' ), array( 'tabindex' => 3 ) ) . '<br />';
-
-               $out .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text(), array( 'tabindex' => 4 ) ) . "\n";# Submit button and form bottom
+               $out .= Xml::checkLabel(
+                       $this->msg( 'activeusers-hidesysops' )->text(),
+                       'hidesysops',
+                       'hidesysops',
+                       $this->opts->getValue( 'hidesysops' ),
+                       array( 'tabindex' => 3 )
+               ) . '<br />';
+
+               # Submit button and form bottom
+               $out .= Xml::submitButton(
+                       $this->msg( 'allpagessubmit' )->text(),
+                       array( 'tabindex' => 4 )
+               ) . "\n";
                $out .= Xml::closeElement( 'fieldset' );
                $out .= Xml::closeElement( 'form' );
 
@@ -229,7 +240,7 @@ class SpecialActiveUsers extends SpecialPage {
        /**
         * Show the special page
         *
-        * @param $par Mixed: parameter passed to the page or null
+        * @param string $par Parameter passed to the page or null
         */
        public function execute( $par ) {
                global $wgActiveUserDays;
@@ -242,7 +253,7 @@ class SpecialActiveUsers extends SpecialPage {
                        array( 'activeusers-intro', $this->getLanguage()->formatNum( $wgActiveUserDays ) ) );
 
                // Occasionally merge in new updates
-               $seconds = self::mergeActiveUsers( 600 );
+               $seconds = min( self::mergeActiveUsers( 600 ), $wgActiveUserDays * 86400 );
                // Mention the level of staleness
                $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl',
                        $this->getLanguage()->formatDuration( $seconds ) );
@@ -269,8 +280,8 @@ class SpecialActiveUsers extends SpecialPage {
        }
 
        /**
-        * @param integer $period Seconds (do updates no more often than this)
-        * @return integer How many seconds old the cache is
+        * @param intr $period Seconds (do updates no more often than this)
+        * @return int How many seconds old the cache is
         */
        public static function mergeActiveUsers( $period ) {
                global $wgActiveUserDays;
@@ -283,9 +294,15 @@ class SpecialActiveUsers extends SpecialPage {
                if ( !wfReadOnly() ) {
                        if ( !$cTime || ( time() - wfTimestamp( TS_UNIX, $cTime ) ) > $period ) {
                                $dbw = wfGetDB( DB_MASTER );
-                               self::doQueryCacheUpdate( $dbw, 2 * $period );
+                               if ( $dbw->estimateRowCount( 'recentchanges' ) <= 10000 ) {
+                                       $window = $wgActiveUserDays * 86400; // small wiki
+                               } else {
+                                       $window = $period * 2;
+                               }
+                               self::doQueryCacheUpdate( $dbw, $window );
                        }
                }
+
                return ( time() -
                        ( $cTime ? wfTimestamp( TS_UNIX, $cTime ) : $wgActiveUserDays * 86400 ) );
        }
@@ -304,7 +321,7 @@ class SpecialActiveUsers extends SpecialPage {
         * Update the query cache as needed
         *
         * @param DatabaseBase $dbw
-        * @param integer $window Maximum time range of new data to scan (in seconds)
+        * @param int $window Maximum time range of new data to scan (in seconds)
         * @return bool Success
         */
        protected static function doQueryCacheUpdate( DatabaseBase $dbw, $window ) {
@@ -334,6 +351,7 @@ class SpecialActiveUsers extends SpecialPage {
                        array( 'rc_user_text', 'lastedittime' => 'MAX(rc_timestamp)' ),
                        array(
                                'rc_user > 0', // actual accounts
+                               'rc_type != ' . $dbw->addQuotes( RC_EXTERNAL ), // no wikidata
                                'rc_log_type IS NULL OR rc_log_type != ' . $dbw->addQuotes( 'newusers' ),
                                'rc_timestamp >= ' . $dbw->addQuotes( $dbw->timestamp( $sTimestamp ) ),
                                'rc_timestamp <= ' . $dbw->addQuotes( $dbw->timestamp( $eTimestamp ) )
@@ -378,7 +396,7 @@ class SpecialActiveUsers extends SpecialPage {
                        $newRows = array();
                        foreach ( $names as $name => $lastEditTime ) {
                                $newRows[] = array(
-                                       'qcc_type'  => 'activeusers',
+                                       'qcc_type' => 'activeusers',
                                        'qcc_namespace' => NS_USER,
                                        'qcc_title' => $name,
                                        'qcc_value' => wfTimestamp( TS_UNIX, $lastEditTime ),