Merge "Localisation updates from https://translatewiki.net."
[lhc/web/wiklou.git] / includes / CategoryViewer.php
index 4c4b8bb..0205d70 100644 (file)
@@ -67,7 +67,7 @@ class CategoryViewer extends ContextSource {
        /** @var Collation */
        public $collation;
 
-       /** @var ImageGallery */
+       /** @var ImageGalleryBase */
        public $gallery;
 
        /** @var Category Category object for this page. */
@@ -632,11 +632,12 @@ class CategoryViewer extends ContextSource {
        private function pagingLinks( $first, $last, $type = '' ) {
                $prevLink = $this->msg( 'prev-page' )->text();
 
+               $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
                if ( $first != '' ) {
                        $prevQuery = $this->query;
                        $prevQuery["{$type}until"] = $first;
                        unset( $prevQuery["{$type}from"] );
-                       $prevLink = Linker::linkKnown(
+                       $prevLink = $linkRenderer->makeKnownLink(
                                $this->addFragmentToTitle( $this->title, $type ),
                                $prevLink,
                                [],
@@ -650,7 +651,7 @@ class CategoryViewer extends ContextSource {
                        $lastQuery = $this->query;
                        $lastQuery["{$type}from"] = $last;
                        unset( $lastQuery["{$type}until"] );
-                       $nextLink = Linker::linkKnown(
+                       $nextLink = $linkRenderer->makeKnownLink(
                                $this->addFragmentToTitle( $this->title, $type ),
                                $nextLink,
                                [],
@@ -741,7 +742,13 @@ class CategoryViewer extends ContextSource {
                        $totalcnt = $rescnt;
                        $category = $this->cat;
                        DeferredUpdates::addCallableUpdate( function () use ( $category ) {
-                               $category->refreshCounts();
+                               # Avoid excess contention on the same category (T162121)
+                               $dbw = wfGetDB( DB_MASTER );
+                               $name = __METHOD__ . ':' . md5( $this->mName );
+                               $scopedLock = $dbw->getScopedLockAndFlush( $name, __METHOD__, 1 );
+                               if ( $scopedLock ) {
+                                       $category->refreshCounts();
+                               }
                        } );
                } else {
                        // Case 3: hopeless.  Don't give a total count at all.