Rename mw.util.wikiGetlink to getUrl
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
index 1fe19d5..7fc9033 100644 (file)
@@ -28,6 +28,8 @@
  * @ingroup Actions
  */
 class InfoAction extends FormlessAction {
+       const CACHE_VERSION = '2013-03-17';
+
        /**
         * Returns the name of the action this object responds to.
         *
@@ -116,7 +118,7 @@ class InfoAction extends FormlessAction {
 
                // Render page information
                foreach ( $pageInfo as $header => $infoTable ) {
-                       // Give grep a chance to find the usages:
+                       // 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";
@@ -201,9 +203,11 @@ class InfoAction extends FormlessAction {
                $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 );
                }
@@ -281,8 +285,8 @@ class InfoAction extends FormlessAction {
 
                // Use robot policy logic
                $policy = $this->page->getRobotPolicy( 'view', $pOutput );
-               // Give grep a chance to find the usages: pageinfo-robot-index, pageinfo-robot-noindex
                $pageInfo['header-basic'][] = array(
+                       // Messages: pageinfo-robot-index, pageinfo-robot-noindex
                        $this->msg( 'pageinfo-robot-policy' ), $this->msg( "pageinfo-robot-${policy['index']}" )
                );
 
@@ -397,8 +401,7 @@ class InfoAction extends FormlessAction {
                                $message = $this->msg( 'protect-default' )->escaped();
                        } else {
                                // Administrators only
-                               // Give grep a chance to find the usages:
-                               // protect-level-autoconfirmed, protect-level-sysop
+                               // Messages: protect-level-autoconfirmed, protect-level-sysop
                                $message = $this->msg( "protect-level-$protectionLevel" );
                                if ( $message->isDisabled() ) {
                                        // Require "$1" permission
@@ -408,8 +411,8 @@ class InfoAction extends FormlessAction {
                                }
                        }
 
-                       // Give grep a chance to find the usages:
-                       // restriction-edit, restriction-move, restriction-create, restriction-upload
+                       // Messages: restriction-edit, restriction-move, restriction-create,
+                       // restriction-upload
                        $pageInfo['header-restrictions'][] = array(
                                $this->msg( "restriction-$restrictionType" ), $message
                        );
@@ -615,7 +618,7 @@ class InfoAction extends FormlessAction {
 
                if ( !$wgDisableCounters ) {
                        // Number of views
-                       $views = (int) $dbr->selectField(
+                       $views = (int)$dbr->selectField(
                                'page',
                                'page_counter',
                                array( 'page_id' => $id ),
@@ -625,7 +628,7 @@ class InfoAction extends FormlessAction {
                }
 
                // Number of page watchers
-               $watchers = (int) $dbr->selectField(
+               $watchers = (int)$dbr->selectField(
                        'watchlist',
                        'COUNT(*)',
                        array(
@@ -637,7 +640,7 @@ class InfoAction extends FormlessAction {
                $result['watchers'] = $watchers;
 
                // Total number of edits
-               $edits = (int) $dbr->selectField(
+               $edits = (int)$dbr->selectField(
                        'revision',
                        'COUNT(rev_page)',
                        array( 'rev_page' => $id ),
@@ -646,7 +649,7 @@ class InfoAction extends FormlessAction {
                $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 ),
@@ -658,7 +661,7 @@ class InfoAction extends FormlessAction {
                $threshold = $dbr->timestamp( time() - $wgRCMaxAge );
 
                // Recent number of edits
-               $edits = (int) $dbr->selectField(
+               $edits = (int)$dbr->selectField(
                        'revision',
                        'COUNT(rev_page)',
                        array(
@@ -670,7 +673,7 @@ class InfoAction extends FormlessAction {
                $result['recent_edits'] = $edits;
 
                // Recent number of distinct authors
-               $authors = (int) $dbr->selectField(
+               $authors = (int)$dbr->selectField(
                        'revision',
                        'COUNT(DISTINCT rev_user_text)',
                        array(
@@ -688,7 +691,7 @@ class InfoAction extends FormlessAction {
 
                        // 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,
@@ -696,7 +699,7 @@ class InfoAction extends FormlessAction {
 
                        // 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,
@@ -709,7 +712,7 @@ class InfoAction extends FormlessAction {
                }
 
                // 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(
@@ -719,7 +722,7 @@ class InfoAction extends FormlessAction {
                        __METHOD__
                );
 
-               $result['transclusion']['from'] = (int) $dbr->selectField(
+               $result['transclusion']['from'] = (int)$dbr->selectField(
                        'templatelinks',
                        'COUNT(*)',
                        array( 'tl_from' => $title->getArticleID() ),