From: Chad Horohoe Date: Sat, 8 Nov 2008 22:20:23 +0000 (+0000) Subject: * Redo thumb caching and make it a part of the default /thumb/ structure with hashes... X-Git-Tag: 1.31.0-rc.0~44395 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=cb682a2ca179e30d004a04ebcb4f48f98362bb05;p=lhc%2Fweb%2Fwiklou.git * Redo thumb caching and make it a part of the default /thumb/ structure with hashes as needed. * Move the generic getHashPath accessor up a level to the FileRepo. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0ed6095aeb..1350b7013b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -58,6 +58,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN $wgDefaultSkin. * Added $wgEnotifUseRealName, which allows UserMailer to send out e-mails based on the user's real name if one is set. Defaults to false (use the username) +* Removed the 'apiThumbCacheDir' option from $wgForeignFileRepos (only used in + ForeignAPIRepo) === Migrated extensions === The following extensions are migrated into MediaWiki 1.14: @@ -323,9 +325,11 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 5101) Image from Commons doesn't show up when searched in Wikipedia search box * (bug 4362) [[MediaWiki:History copyright]] no more used with most recent revision when passing oldid parameter in the url -* (bug 16265) When caching thumbs with the ForeignApiRepo, we now use the same filename - as the remote site. +* (bug 16265) When caching thumbs with the ForeignApiRepo, we now use the same + filename as the remote site. * (bug 8345) Don't autosummarize where a redirect was left unchanged +* Made thumb caching in ForeignApiFile objects integrated with normal thumb path + naming (/thumbs/hash/file), retired 'apiThumbCacheDir' as a result. === API changes in 1.14 === diff --git a/includes/filerepo/FSRepo.php b/includes/filerepo/FSRepo.php index 08ec151438..17f3f16447 100644 --- a/includes/filerepo/FSRepo.php +++ b/includes/filerepo/FSRepo.php @@ -6,7 +6,7 @@ * @ingroup FileRepo */ class FSRepo extends FileRepo { - var $directory, $deletedDir, $url, $hashLevels, $deletedHashLevels; + var $directory, $deletedDir, $url, $deletedHashLevels; var $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' ); var $oldFileFactory = false; var $pathDisclosureProtection = 'simple'; @@ -440,14 +440,6 @@ class FSRepo extends FileRepo { return $status; } - /** - * Get a relative path including trailing slash, e.g. f/fa/ - * If the repo is not hashed, returns an empty string - */ - function getHashPath( $name ) { - return FileRepo::getHashPathForLevel( $name, $this->hashLevels ); - } - /** * Get a relative path for a deletion archive key, * e.g. s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 02d0d1fbb0..729e38d86f 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -15,7 +15,7 @@ abstract class FileRepo { var $thumbScriptUrl, $transformVia404; var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital; var $pathDisclosureProtection = 'paranoid'; - var $descriptionCacheExpiry, $apiThumbCacheExpiry, $apiThumbCacheDir; + var $descriptionCacheExpiry, $apiThumbCacheExpiry, $hashLevels; /** * Factory functions for creating new files @@ -32,7 +32,7 @@ abstract class FileRepo { $this->initialCapital = true; // by default foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription', 'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection', - 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'apiThumbCacheDir' ) as $var ) + 'descriptionCacheExpiry', 'apiThumbCacheExpiry', 'hashLevels' ) as $var ) { if ( isset( $info[$var] ) ) { $this->$var = $info[$var]; @@ -238,6 +238,14 @@ abstract class FileRepo { return $path; } } + + /** + * Get a relative path including trailing slash, e.g. f/fa/ + * If the repo is not hashed, returns an empty string + */ + function getHashPath( $name ) { + return self::getHashPathForLevel( $name, $this->hashLevels ); + } /** * Get the name of this repository, as specified by $info['name]' to the constructor diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 22f23160c9..847f9dc71d 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -102,10 +102,9 @@ class ForeignAPIFile extends File { * Only useful if we're locally caching thumbs anyway... */ function getThumbPath( $suffix = '' ) { - $ret = null; if ( $this->repo->canCacheThumbs() ) { global $wgUploadDirectory; - $path = $wgUploadDirectory . '/' . $this->repo->apiThumbCacheDir . '/' . $this->repo->name . '/'; + $path = $wgUploadDirectory . '/thumb/' . $this->getHashPath( $this->getName() ); if ( $suffix ) { $path = $path . $suffix . '/'; } diff --git a/includes/filerepo/ForeignAPIRepo.php b/includes/filerepo/ForeignAPIRepo.php index ad9764b657..b1c442bf6e 100644 --- a/includes/filerepo/ForeignAPIRepo.php +++ b/includes/filerepo/ForeignAPIRepo.php @@ -31,10 +31,12 @@ class ForeignAPIRepo extends FileRepo { } } +/** + * No-ops + */ function storeBatch( $triplets, $flags = 0 ) { return false; } - function storeTemp( $originalName, $srcPath ) { return false; } @@ -128,8 +130,7 @@ class ForeignAPIRepo extends FileRepo { // We need the same filename as the remote one :) $fileName = ltrim( substr( $foreignUrl, strrpos( $foreignUrl, '/' ), strlen ( $foreignUrl ) ), '/' ); - $path = $this->apiThumbCacheDir . '/' . - $name . '/'; + $path = 'thumb/' . $this->getHashPath( $this->getName() ); if ( !is_dir($wgUploadDirectory . '/' . $path) ) { wfMkdirParents($wgUploadDirectory . '/' . $path); } @@ -149,6 +150,6 @@ class ForeignAPIRepo extends FileRepo { * @return bool */ public function canCacheThumbs() { - return ( $this->apiThumbCacheExpiry > 0 && $this->apiThumbCacheDir ); + return ( $this->apiThumbCacheExpiry > 0 ); } }