diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
commit | a2190ac74dd4d7080b12bab90e552d7aa81209ef (patch) | |
tree | 8b31f38de9882d18df54cf8d9e0de74167a094eb /includes/specials/SpecialActiveusers.php | |
parent | 15e69f7b20b6596b9148030acce5b59993b95a45 (diff) | |
parent | 257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff) |
Merge branch 'mw-1.26'
Diffstat (limited to 'includes/specials/SpecialActiveusers.php')
-rw-r--r-- | includes/specials/SpecialActiveusers.php | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index 5e2ee1c2..047e9413 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -267,21 +267,24 @@ class SpecialActiveUsers extends SpecialPage { $out->wrapWikiMsg( "<div class='mw-activeusers-intro'>\n$1\n</div>", array( 'activeusers-intro', $this->getLanguage()->formatNum( $days ) ) ); - // Get the timestamp of the last cache update + // Mention the level of cache staleness... $dbr = wfGetDB( DB_SLAVE, 'recentchanges' ); - $cTime = $dbr->selectField( 'querycache_info', - 'qci_timestamp', - array( 'qci_type' => 'activeusers' ) - ); - - $secondsOld = $cTime - ? time() - wfTimestamp( TS_UNIX, $cTime ) - : $days * 86400; // fully stale :) - - if ( $secondsOld > 0 ) { - // Mention the level of staleness - $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl', + $rcMax = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)' ); + if ( $rcMax ) { + $cTime = $dbr->selectField( 'querycache_info', + 'qci_timestamp', + array( 'qci_type' => 'activeusers' ) + ); + if ( $cTime ) { + $secondsOld = wfTimestamp( TS_UNIX, $rcMax ) - wfTimestamp( TS_UNIX, $cTime ); + } else { + $rcMin = $dbr->selectField( 'recentchanges', 'MIN(rc_timestamp)' ); + $secondsOld = time() - wfTimestamp( TS_UNIX, $rcMin ); + } + if ( $secondsOld > 0 ) { + $out->addWikiMsg( 'cachedspecial-viewing-cached-ttl', $this->getLanguage()->formatDuration( $secondsOld ) ); + } } $up = new ActiveUsersPager( $this->getContext(), null, $par ); |