From: jenkins-bot Date: Thu, 5 Sep 2013 22:15:07 +0000 (+0000) Subject: Merge "Add cache versioning to InfoAction." X-Git-Tag: 1.31.0-rc.0~18801 X-Git-Url: http://git.cyclocoop.org/%22%20.%20%20%20%24self2%20.%20%20%20%22&var_mode_affiche=boucle?a=commitdiff_plain;h=8fe0cf970401f2796ca39165a2d0a311b551c47a;hp=-c;p=lhc%2Fweb%2Fwiklou.git Merge "Add cache versioning to InfoAction." --- 8fe0cf970401f2796ca39165a2d0a311b551c47a diff --combined includes/actions/InfoAction.php index 2c0a87534d,f46314a175..7fc903399d --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@@ -28,6 -28,8 +28,8 @@@ * @ingroup Actions */ class InfoAction extends FormlessAction { + const CACHE_VERSION = '2013-03-17'; + /** * Returns the name of the action this object responds to. * @@@ -66,8 -68,8 +68,8 @@@ // Clear page info. $revision = WikiPage::factory( $title )->getRevision(); if ( $revision !== null ) { - $memcKey = wfMemcKey( 'infoaction', $title->getPrefixedText(), $revision->getId() ); - $wgMemc->delete( $memcKey ); + $key = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $revision->getId() ); + $wgMemc->delete( $key ); } } @@@ -116,16 -118,12 +118,16 @@@ // Render page information foreach ( $pageInfo as $header => $infoTable ) { + // Messages: + // pageinfo-header-basic, pageinfo-header-edits, pageinfo-header-restrictions, + // pageinfo-header-properties, pageinfo-category-info $content .= $this->makeHeader( $this->msg( "pageinfo-${header}" )->escaped() ) . "\n"; $table = "\n"; foreach ( $infoTable as $infoRow ) { $name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0]; $value = ( $infoRow[1] instanceof Message ) ? $infoRow[1]->escaped() : $infoRow[1]; - $table = $this->addRow( $table, $name, $value ) . "\n"; + $id = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->getKey() : null; + $table = $this->addRow( $table, $name, $value, $id ) . "\n"; } $content = $this->addTable( $content, $table ) . "\n"; } @@@ -160,11 -158,10 +162,11 @@@ * @param string $table The table that will be added to the content * @param string $name The name of the row * @param string $value The value of the row + * @param string $id The ID to use for the 'tr' element * @return string The table with the row added */ - protected function addRow( $table, $name, $value ) { - return $table . Html::rawElement( 'tr', array(), + protected function addRow( $table, $name, $value, $id ) { + return $table . Html::rawElement( 'tr', $id === null ? array() : array( 'id' => 'mw-' . $id ), Html::rawElement( 'td', array( 'style' => 'vertical-align: top;' ), $name ) . Html::rawElement( 'td', array(), $value ) ); @@@ -190,20 -187,20 +192,22 @@@ * @return array */ protected function pageInfo() { - global $wgContLang, $wgRCMaxAge, $wgMemc, $wgUnwatchedPageThreshold, $wgPageInfoTransclusionLimit; + global $wgContLang, $wgRCMaxAge, $wgMemc, + $wgUnwatchedPageThreshold, $wgPageInfoTransclusionLimit; $user = $this->getUser(); $lang = $this->getLanguage(); $title = $this->getTitle(); $id = $title->getArticleID(); - $memcKey = wfMemcKey( 'infoaction', sha1( $title->getPrefixedText() ), $this->page->getLatest() ); + $memcKey = wfMemcKey( 'infoaction', + sha1( $title->getPrefixedText() ), $this->page->getLatest() ); $pageCounts = $wgMemc->get( $memcKey ); - if ( $pageCounts === false ) { + $version = isset( $pageCounts['cacheversion'] ) ? $pageCounts['cacheversion'] : false; + if ( $pageCounts === false || $version !== self::CACHE_VERSION ) { // Get page information that would be too "expensive" to retrieve by normal means $pageCounts = self::pageCounts( $title ); + $pageCounts['cacheversion'] = self::CACHE_VERSION; $wgMemc->set( $memcKey, $pageCounts ); } @@@ -282,7 -279,6 +286,7 @@@ // Use robot policy logic $policy = $this->page->getRobotPolicy( 'view', $pOutput ); $pageInfo['header-basic'][] = array( + // Messages: pageinfo-robot-index, pageinfo-robot-noindex $this->msg( 'pageinfo-robot-policy' ), $this->msg( "pageinfo-robot-${policy['index']}" ) ); @@@ -397,7 -393,6 +401,7 @@@ $message = $this->msg( 'protect-default' )->escaped(); } else { // Administrators only + // Messages: protect-level-autoconfirmed, protect-level-sysop $message = $this->msg( "protect-level-$protectionLevel" ); if ( $message->isDisabled() ) { // Require "$1" permission @@@ -407,8 -402,6 +411,8 @@@ } } + // Messages: restriction-edit, restriction-move, restriction-create, + // restriction-upload $pageInfo['header-restrictions'][] = array( $this->msg( "restriction-$restrictionType" ), $message ); @@@ -614,7 -607,7 +618,7 @@@ if ( !$wgDisableCounters ) { // Number of views - $views = (int) $dbr->selectField( + $views = (int)$dbr->selectField( 'page', 'page_counter', array( 'page_id' => $id ), @@@ -624,7 -617,7 +628,7 @@@ } // Number of page watchers - $watchers = (int) $dbr->selectField( + $watchers = (int)$dbr->selectField( 'watchlist', 'COUNT(*)', array( @@@ -636,7 -629,7 +640,7 @@@ $result['watchers'] = $watchers; // Total number of edits - $edits = (int) $dbr->selectField( + $edits = (int)$dbr->selectField( 'revision', 'COUNT(rev_page)', array( 'rev_page' => $id ), @@@ -645,7 -638,7 +649,7 @@@ $result['edits'] = $edits; // Total number of distinct authors - $authors = (int) $dbr->selectField( + $authors = (int)$dbr->selectField( 'revision', 'COUNT(DISTINCT rev_user_text)', array( 'rev_page' => $id ), @@@ -657,7 -650,7 +661,7 @@@ $threshold = $dbr->timestamp( time() - $wgRCMaxAge ); // Recent number of edits - $edits = (int) $dbr->selectField( + $edits = (int)$dbr->selectField( 'revision', 'COUNT(rev_page)', array( @@@ -669,7 -662,7 +673,7 @@@ $result['recent_edits'] = $edits; // Recent number of distinct authors - $authors = (int) $dbr->selectField( + $authors = (int)$dbr->selectField( 'revision', 'COUNT(DISTINCT rev_user_text)', array( @@@ -687,7 -680,7 +691,7 @@@ // Subpages of this page (redirects) $conds['page_is_redirect'] = 1; - $result['subpages']['redirects'] = (int) $dbr->selectField( + $result['subpages']['redirects'] = (int)$dbr->selectField( 'page', 'COUNT(page_id)', $conds, @@@ -695,7 -688,7 +699,7 @@@ // Subpages of this page (non-redirects) $conds['page_is_redirect'] = 0; - $result['subpages']['nonredirects'] = (int) $dbr->selectField( + $result['subpages']['nonredirects'] = (int)$dbr->selectField( 'page', 'COUNT(page_id)', $conds, @@@ -708,7 -701,7 +712,7 @@@ } // Counts for the number of transclusion links (to/from) - $result['transclusion']['to'] = (int) $dbr->selectField( + $result['transclusion']['to'] = (int)$dbr->selectField( 'templatelinks', 'COUNT(tl_from)', array( @@@ -718,7 -711,7 +722,7 @@@ __METHOD__ ); - $result['transclusion']['from'] = (int) $dbr->selectField( + $result['transclusion']['from'] = (int)$dbr->selectField( 'templatelinks', 'COUNT(*)', array( 'tl_from' => $title->getArticleID() ),