X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Factions%2FInfoAction.php;h=d9324e7527daaeb20621ee19c2fead50f4b49d98;hb=8d1c5a70f753fe6b7d2533a30b07fe03e6583a1d;hp=0c1a34486448d150138b900dde8d77d011918792;hpb=a11c087105849e3e4fe4ee79524c056b5a64180c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 0c1a344864..d9324e7527 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -62,13 +62,17 @@ class InfoAction extends FormlessAction { * * @since 1.22 * @param Title $title Title to clear cache for + * @param int|null $revid Revision id to clear */ - public static function invalidateCache( Title $title ) { + public static function invalidateCache( Title $title, $revid = null ) { $cache = ObjectCache::getMainWANInstance(); - $revision = Revision::newFromTitle( $title, 0, Revision::READ_LATEST ); - if ( $revision !== null ) { - $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revision->getId() ); + if ( !$revid ) { + $revision = Revision::newFromTitle( $title, 0, Revision::READ_LATEST ); + $revid = $revision ? $revision->getId() : null; + } + if ( $revid !== null ) { + $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revid ); $cache->delete( $key ); } } @@ -551,9 +555,11 @@ class InfoAction extends FormlessAction { ); // Total number of distinct authors - $pageInfo['header-edits'][] = array( - $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] ) - ); + if ( $pageCounts['authors'] > 0 ) { + $pageInfo['header-edits'][] = array( + $this->msg( 'pageinfo-authors' ), $lang->formatNum( $pageCounts['authors'] ) + ); + } // Recent number of edits (within past 30 days) $pageInfo['header-edits'][] = array( @@ -675,11 +681,11 @@ class InfoAction extends FormlessAction { $id = $title->getArticleID(); $config = $this->context->getConfig(); - $dbr = wfGetDB( DB_SLAVE ); + $dbrWatchlist = wfGetDB( DB_SLAVE, 'watchlist' ); $result = array(); // Number of page watchers - $watchers = (int)$dbr->selectField( + $watchers = (int)$dbrWatchlist->selectField( 'watchlist', 'COUNT(*)', array( @@ -694,15 +700,15 @@ class InfoAction extends FormlessAction { // Threshold: last visited about 26 weeks before latest edit $updated = wfTimestamp( TS_UNIX, $this->page->getTimestamp() ); $age = $config->get( 'WatchersMaxAge' ); - $threshold = $dbr->timestamp( $updated - $age ); + $threshold = $dbrWatchlist->timestamp( $updated - $age ); // Number of page watchers who also visited a "recent" edit - $visitingWatchers = (int)$dbr->selectField( + $visitingWatchers = (int)$dbrWatchlist->selectField( 'watchlist', 'COUNT(*)', array( 'wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey(), - 'wl_notificationtimestamp >= ' . $dbr->addQuotes( $threshold ) . + 'wl_notificationtimestamp >= ' . $dbrWatchlist->addQuotes( $threshold ) . ' OR wl_notificationtimestamp IS NULL' ), __METHOD__ @@ -710,23 +716,27 @@ class InfoAction extends FormlessAction { $result['visitingWatchers'] = $visitingWatchers; } + $dbr = wfGetDB( DB_SLAVE ); // Total number of edits $edits = (int)$dbr->selectField( 'revision', - 'COUNT(rev_page)', + 'COUNT(*)', array( 'rev_page' => $id ), __METHOD__ ); $result['edits'] = $edits; // Total number of distinct authors - $authors = (int)$dbr->selectField( - 'revision', - 'COUNT(DISTINCT rev_user_text)', - array( 'rev_page' => $id ), - __METHOD__ - ); - $result['authors'] = $authors; + if ( $config->get( 'MiserMode' ) ) { + $result['authors'] = 0; + } else { + $result['authors'] = (int)$dbr->selectField( + 'revision', + 'COUNT(DISTINCT rev_user_text)', + array( 'rev_page' => $id ), + __METHOD__ + ); + } // "Recent" threshold defined by RCMaxAge setting $threshold = $dbr->timestamp( time() - $config->get( 'RCMaxAge' ) ); @@ -744,7 +754,7 @@ class InfoAction extends FormlessAction { $result['recent_edits'] = $edits; // Recent number of distinct authors - $authors = (int)$dbr->selectField( + $result['recent_authors'] = (int)$dbr->selectField( 'revision', 'COUNT(DISTINCT rev_user_text)', array( @@ -753,7 +763,6 @@ class InfoAction extends FormlessAction { ), __METHOD__ ); - $result['recent_authors'] = $authors; // Subpages (if enabled) if ( MWNamespace::hasSubpages( $title->getNamespace() ) ) {