Merge "SpecialNewFiles: Swap from/to date serverside"
[lhc/web/wiklou.git] / includes / actions / InfoAction.php
index df7afca..baec944 100644 (file)
@@ -73,8 +73,9 @@ class InfoAction extends FormlessAction {
                        $revid = $revision ? $revision->getId() : null;
                }
                if ( $revid !== null ) {
-                       $key = self::getCacheKey( $title, $revid );
-                       ObjectCache::getMainWANInstance()->delete( $key );
+                       $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
+                       $key = self::getCacheKey( $cache, $title, $revid );
+                       $cache->delete( $key );
                }
        }
 
@@ -126,7 +127,10 @@ class InfoAction extends FormlessAction {
                        // 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";
+                       $content .= $this->makeHeader(
+                               $this->msg( "pageinfo-${header}" )->escaped(),
+                               "mw-pageinfo-${header}"
+                       ) . "\n";
                        $table = "\n";
                        foreach ( $infoTable as $infoRow ) {
                                $name = ( $infoRow[0] instanceof Message ) ? $infoRow[0]->escaped() : $infoRow[0];
@@ -151,10 +155,11 @@ class InfoAction extends FormlessAction {
         * @param string $header The header text.
         * @return string The HTML.
         */
-       protected function makeHeader( $header ) {
+       protected function makeHeader( $header, $canonicalId ) {
                $spanAttribs = [ 'class' => 'mw-headline', 'id' => Sanitizer::escapeId( $header ) ];
+               $h2Attribs = [ 'id' => Sanitizer::escapeId( $canonicalId ) ];
 
-               return Html::rawElement( 'h2', [], Html::element( 'span', $spanAttribs, $header ) );
+               return Html::rawElement( 'h2', $h2Attribs, Html::element( 'span', $spanAttribs, $header ) );
        }
 
        /**
@@ -389,7 +394,10 @@ class InfoAction extends FormlessAction {
                        $prefixIndex = SpecialPage::getTitleFor(
                                'Prefixindex', $title->getPrefixedText() . '/' );
                        $pageInfo['header-basic'][] = [
-                               Linker::link( $prefixIndex, $this->msg( 'pageinfo-subpages-name' )->escaped() ),
+                               $linkRenderer->makeLink(
+                                       $prefixIndex,
+                                       $this->msg( 'pageinfo-subpages-name' )->text()
+                               ),
                                $this->msg( 'pageinfo-subpages-value' )
                                        ->numParams(
                                                $pageCounts['subpages']['total'],
@@ -690,9 +698,10 @@ class InfoAction extends FormlessAction {
        protected function pageCounts( Page $page ) {
                $fname = __METHOD__;
                $config = $this->context->getConfig();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
 
-               return ObjectCache::getMainWANInstance()->getWithSetCallback(
-                       self::getCacheKey( $page->getTitle(), $page->getLatest() ),
+               return $cache->getWithSetCallback(
+                       self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ),
                        WANObjectCache::TTL_WEEK,
                        function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) {
                                $title = $page->getTitle();
@@ -903,11 +912,12 @@ class InfoAction extends FormlessAction {
        }
 
        /**
+        * @param WANObjectCache $cache
         * @param Title $title
         * @param int $revId
         * @return string
         */
-       protected static function getCacheKey( Title $title, $revId ) {
-               return wfMemcKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION );
+       protected static function getCacheKey( WANObjectCache $cache, Title $title, $revId ) {
+               return $cache->makeKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION );
        }
 }