Merge "Migrate more callers away from $wgMemc"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 27 Oct 2015 01:44:43 +0000 (01:44 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 27 Oct 2015 01:44:43 +0000 (01:44 +0000)
1  2 
includes/filerepo/file/File.php

@@@ -1137,6 -1137,7 +1137,7 @@@ abstract class File implements IDBAcces
                if ( !$thumb ) { // bad params?
                        $thumb = false;
                } elseif ( $thumb->isError() ) { // transform error
+                       /** @var $thumb MediaTransformError */
                        $this->lastError = $thumb->toText();
                        // Ignore errors if requested
                        if ( $wgIgnoreImageErrors && !( $flags & self::RENDER_NOW ) ) {
         * @param string $reason
         * @param bool $suppress Hide content from sysops?
         * @param User|null $user
 -       * @return bool Boolean on success, false on some kind of failure
 +       * @return FileRepoStatus
         * STUB
         * Overridden by LocalFile
         */
         * @return string
         */
        function getDescriptionText( $lang = false ) {
-               global $wgMemc, $wgLang;
+               global $wgLang;
                if ( !$this->repo || !$this->repo->fetchDescription ) {
                        return false;
                }
-               if ( !$lang ) {
-                       $lang = $wgLang;
-               }
+               $lang = $lang ?: $wgLang;
                $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName(), $lang->getCode() );
                if ( $renderUrl ) {
+                       $cache = ObjectCache::getMainWANInstance();
+                       $key = null;
                        if ( $this->repo->descriptionCacheExpiry > 0 ) {
                                wfDebug( "Attempting to get the description from cache..." );
                                $key = $this->repo->getLocalCacheKey(
                                        $lang->getCode(),
                                        $this->getName()
                                );
-                               $obj = $wgMemc->get( $key );
+                               $obj = $cache->get( $key );
                                if ( $obj ) {
                                        wfDebug( "success!\n" );
  
                        }
                        wfDebug( "Fetching shared description from $renderUrl\n" );
                        $res = Http::get( $renderUrl, array(), __METHOD__ );
-                       if ( $res && $this->repo->descriptionCacheExpiry > 0 ) {
-                               $wgMemc->set( $key, $res, $this->repo->descriptionCacheExpiry );
+                       if ( $res && $key ) {
+                               $cache->set( $key, $res, $this->repo->descriptionCacheExpiry );
                        }
  
                        return $res;