* 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.
This commit is contained in:
parent
8f4335bb48
commit
cb682a2ca1
5 changed files with 23 additions and 19 deletions
|
|
@ -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 ===
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 . '/';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue