Simplify configuration and make a better caching key.
authorChad Horohoe <demon@users.mediawiki.org>
Thu, 3 Jul 2008 21:33:09 +0000 (21:33 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Thu, 3 Jul 2008 21:33:09 +0000 (21:33 +0000)
includes/filerepo/File.php
includes/filerepo/FileRepo.php

index 0e634eb..ea6bdad 100644 (file)
@@ -1068,9 +1068,9 @@ abstract class File {
                }
                $renderUrl = $this->repo->getDescriptionRenderUrl( $this->getName() );
                if ( $renderUrl ) {
-                       if ( $this->repo->useLocalCache ) {
+                       if ( $this->repo->descriptionCacheExpiry > 0 ) {
                                wfDebug("Attempting to get the description from the transwiki cache...");
-                               $key = md5($renderUrl);
+                               $key = wfMemcKey( 'filedesc', 'url', md5($link));
                                $obj = $wgMemc->get($key);
                                if ($obj) {
                                        wfDebug("success!\n");
@@ -1080,7 +1080,7 @@ abstract class File {
                        }
                        wfDebug( "Fetching shared description from $renderUrl\n" );
                        $res = Http::get( $renderUrl );
-                       if ( $res && $this->repo->useLocalCache ) $wgMemc->set( $key, $res, $this->repo->localCacheExpiry );
+                       if ( $res && $this->repo->descriptionCacheExpiry > 0 ) $wgMemc->set( $key, $res, $this->repo->descriptionCacheExpiry );
                        return $res;
                } else {
                        return false;
index b6318d6..edfc2a9 100644 (file)
@@ -30,8 +30,7 @@ abstract class FileRepo {
                // Optional settings
                $this->initialCapital = true; // by default
                foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription',
-                       'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection', 
-                       'useLocalCache', 'localCacheExpiry' ) as $var )
+                       'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection', 'descriptionCacheExpiry' ) as $var )
                {
                        if ( isset( $info[$var] ) ) {
                                $this->$var = $info[$var];