Merge "resourceloader: Optimise getCombinedVersion() with string concat"
[lhc/web/wiklou.git] / includes / filerepo / file / ForeignDBFile.php
index 388e950..ee4df1d 100644 (file)
@@ -21,6 +21,7 @@
  * @ingroup FileAbstraction
  */
 
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\DBUnexpectedError;
 
 /**
@@ -125,14 +126,14 @@ class ForeignDBFile extends LocalFile {
         * @param Language|null $lang Optional language to fetch description in.
         * @return string|false
         */
-       function getDescriptionText( $lang = null ) {
+       function getDescriptionText( Language $lang = null ) {
                global $wgLang;
 
                if ( !$this->repo->fetchDescription ) {
                        return false;
                }
 
-               $lang = $lang ?: $wgLang;
+               $lang = $lang ?? $wgLang;
                $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
                if ( !$renderUrl ) {
                        return false;
@@ -150,14 +151,13 @@ class ForeignDBFile extends LocalFile {
                        return false; // no description page
                }
 
-               $cache = ObjectCache::getMainWANInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
 
                return $cache->getWithSetCallback(
                        $this->repo->getLocalCacheKey(
-                               'RemoteFileDescription',
-                               'url',
+                               'ForeignFileDescription',
                                $lang->getCode(),
-                               $this->getName(),
+                               md5( $this->getName() ),
                                $touched
                        ),
                        $this->repo->descriptionCacheExpiry ?: $cache::TTL_UNCACHEABLE,