2007-05-30 21:02:32 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2010-09-04 18:13:18 +00:00
|
|
|
* Prioritized list of file repositories
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup FileRepo
|
|
|
|
|
*/
|
2007-05-30 21:02:32 +00:00
|
|
|
|
2010-09-04 18:13:18 +00:00
|
|
|
/**
|
2007-05-31 01:43:41 +00:00
|
|
|
* Prioritized list of file repositories
|
2010-09-04 18:13:18 +00:00
|
|
|
*
|
|
|
|
|
* @ingroup FileRepo
|
2007-05-31 01:43:41 +00:00
|
|
|
*/
|
2007-05-30 21:02:32 +00:00
|
|
|
class RepoGroup {
|
2011-02-18 23:56:08 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var LocalRepo
|
|
|
|
|
*/
|
|
|
|
|
var $localRepo;
|
|
|
|
|
|
|
|
|
|
var $foreignRepos, $reposInitialised = false;
|
2007-05-30 21:02:32 +00:00
|
|
|
var $localInfo, $foreignInfo;
|
2009-08-15 09:59:59 +00:00
|
|
|
var $cache;
|
2007-05-30 21:02:32 +00:00
|
|
|
|
2011-05-28 18:59:42 +00:00
|
|
|
/**
|
|
|
|
|
* @var RepoGroup
|
|
|
|
|
*/
|
2007-05-30 21:02:32 +00:00
|
|
|
protected static $instance;
|
2009-08-15 09:59:59 +00:00
|
|
|
const MAX_CACHE_SIZE = 1000;
|
2007-05-30 21:02:32 +00:00
|
|
|
|
2007-05-31 01:43:41 +00:00
|
|
|
/**
|
|
|
|
|
* Get a RepoGroup instance. At present only one instance of RepoGroup is
|
|
|
|
|
* needed in a MediaWiki invocation, this may change in the future.
|
2011-01-12 00:29:17 +00:00
|
|
|
* @return RepoGroup
|
2007-05-31 01:43:41 +00:00
|
|
|
*/
|
2007-06-03 09:05:29 +00:00
|
|
|
static function singleton() {
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( self::$instance ) {
|
|
|
|
|
return self::$instance;
|
|
|
|
|
}
|
|
|
|
|
global $wgLocalFileRepo, $wgForeignFileRepos;
|
|
|
|
|
self::$instance = new RepoGroup( $wgLocalFileRepo, $wgForeignFileRepos );
|
|
|
|
|
return self::$instance;
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-03 09:05:29 +00:00
|
|
|
/**
|
|
|
|
|
* Destroy the singleton instance, so that a new one will be created next
|
|
|
|
|
* time singleton() is called.
|
|
|
|
|
*/
|
|
|
|
|
static function destroySingleton() {
|
|
|
|
|
self::$instance = null;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-09 00:21:16 +00:00
|
|
|
/**
|
|
|
|
|
* Set the singleton instance to a given object
|
2011-10-11 19:49:29 +00:00
|
|
|
* Used by extensions which hook into the Repo chain.
|
|
|
|
|
* It's not enough to just create a superclass ... you have
|
|
|
|
|
* to get people to call into it even though all they know is RepoGroup::singleton()
|
2011-05-28 18:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @param $instance RepoGroup
|
2008-01-09 00:21:16 +00:00
|
|
|
*/
|
|
|
|
|
static function setSingleton( $instance ) {
|
|
|
|
|
self::$instance = $instance;
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
/**
|
2008-04-14 07:45:50 +00:00
|
|
|
* Construct a group of file repositories.
|
2010-03-26 21:55:13 +00:00
|
|
|
*
|
2012-02-09 18:01:54 +00:00
|
|
|
* @param $localInfo array Associative array for local repo's info
|
2010-03-26 21:55:13 +00:00
|
|
|
* @param $foreignInfo Array of repository info arrays.
|
2008-04-14 07:45:50 +00:00
|
|
|
* Each info array is an associative array with the 'class' member
|
2007-05-30 21:02:32 +00:00
|
|
|
* giving the class name. The entire array is passed to the repository
|
|
|
|
|
* constructor as the first parameter.
|
|
|
|
|
*/
|
|
|
|
|
function __construct( $localInfo, $foreignInfo ) {
|
|
|
|
|
$this->localInfo = $localInfo;
|
|
|
|
|
$this->foreignInfo = $foreignInfo;
|
2009-08-15 09:59:59 +00:00
|
|
|
$this->cache = array();
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Search repositories for an image.
|
2010-01-23 14:25:10 +00:00
|
|
|
* You can also use wfFindFile() to do this.
|
2010-03-26 21:55:13 +00:00
|
|
|
*
|
2011-05-28 18:59:42 +00:00
|
|
|
* @param $title Title|string Title object or string
|
|
|
|
|
* @param $options array Associative array of options:
|
2009-08-15 09:59:59 +00:00
|
|
|
* time: requested time for an archived image, or false for the
|
|
|
|
|
* current version. An image object will be returned which was
|
|
|
|
|
* created at the specified time.
|
|
|
|
|
*
|
|
|
|
|
* ignoreRedirect: If true, do not follow file redirects
|
|
|
|
|
*
|
2010-01-22 03:14:52 +00:00
|
|
|
* private: If true, return restricted (deleted) files if the current
|
2009-08-15 09:59:59 +00:00
|
|
|
* user is allowed to view them. Otherwise, such files will not
|
|
|
|
|
* be found.
|
|
|
|
|
*
|
|
|
|
|
* bypassCache: If true, do not use the process-local cache of File objects
|
2007-05-30 21:02:32 +00:00
|
|
|
* @return File object or false if it is not found
|
|
|
|
|
*/
|
2009-08-15 09:59:59 +00:00
|
|
|
function findFile( $title, $options = array() ) {
|
|
|
|
|
if ( !is_array( $options ) ) {
|
|
|
|
|
// MW 1.15 compat
|
|
|
|
|
$options = array( 'time' => $options );
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( !$this->reposInitialised ) {
|
|
|
|
|
$this->initialiseRepos();
|
|
|
|
|
}
|
2011-11-04 23:49:03 +00:00
|
|
|
$title = File::normalizeTitle( $title );
|
|
|
|
|
if ( !$title ) {
|
|
|
|
|
return false;
|
2010-11-10 09:16:28 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-15 09:59:59 +00:00
|
|
|
# Check the cache
|
2010-01-22 03:14:52 +00:00
|
|
|
if ( empty( $options['ignoreRedirect'] )
|
|
|
|
|
&& empty( $options['private'] )
|
2011-11-04 23:49:03 +00:00
|
|
|
&& empty( $options['bypassCache'] ) )
|
2009-08-15 09:59:59 +00:00
|
|
|
{
|
|
|
|
|
$useCache = true;
|
|
|
|
|
$time = isset( $options['time'] ) ? $options['time'] : '';
|
|
|
|
|
$dbkey = $title->getDBkey();
|
|
|
|
|
if ( isset( $this->cache[$dbkey][$time] ) ) {
|
|
|
|
|
wfDebug( __METHOD__.": got File:$dbkey from process cache\n" );
|
|
|
|
|
# Move it to the end of the list so that we can delete the LRU entry later
|
|
|
|
|
$tmp = $this->cache[$dbkey];
|
|
|
|
|
unset( $this->cache[$dbkey] );
|
|
|
|
|
$this->cache[$dbkey] = $tmp;
|
|
|
|
|
# Return the entry
|
|
|
|
|
return $this->cache[$dbkey][$time];
|
|
|
|
|
} else {
|
|
|
|
|
# Add a negative cache entry, may be overridden
|
|
|
|
|
$this->trimCache();
|
|
|
|
|
$this->cache[$dbkey][$time] = false;
|
|
|
|
|
$cacheEntry =& $this->cache[$dbkey][$time];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$useCache = false;
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
|
2009-08-15 09:59:59 +00:00
|
|
|
# Check the local repo
|
|
|
|
|
$image = $this->localRepo->findFile( $title, $options );
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( $image ) {
|
2009-08-15 09:59:59 +00:00
|
|
|
if ( $useCache ) {
|
|
|
|
|
$cacheEntry = $image;
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
return $image;
|
|
|
|
|
}
|
2009-08-15 09:59:59 +00:00
|
|
|
|
|
|
|
|
# Check the foreign repos
|
2007-05-30 21:02:32 +00:00
|
|
|
foreach ( $this->foreignRepos as $repo ) {
|
2009-08-15 09:59:59 +00:00
|
|
|
$image = $repo->findFile( $title, $options );
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( $image ) {
|
2009-08-15 09:59:59 +00:00
|
|
|
if ( $useCache ) {
|
|
|
|
|
$cacheEntry = $image;
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
return $image;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-08-15 09:59:59 +00:00
|
|
|
# Not found, do not override negative cache
|
2007-05-30 21:02:32 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2009-08-15 09:59:59 +00:00
|
|
|
|
|
|
|
|
function findFiles( $inputItems ) {
|
2008-05-20 17:05:57 +00:00
|
|
|
if ( !$this->reposInitialised ) {
|
|
|
|
|
$this->initialiseRepos();
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-15 09:59:59 +00:00
|
|
|
$items = array();
|
|
|
|
|
foreach ( $inputItems as $item ) {
|
|
|
|
|
if ( !is_array( $item ) ) {
|
|
|
|
|
$item = array( 'title' => $item );
|
|
|
|
|
}
|
2011-11-11 22:14:21 +00:00
|
|
|
$item['title'] = File::normalizeTitle( $item['title'] );
|
|
|
|
|
if ( $item['title'] ) {
|
2009-08-15 09:59:59 +00:00
|
|
|
$items[$item['title']->getDBkey()] = $item;
|
2011-11-11 22:14:21 +00:00
|
|
|
}
|
2008-05-30 13:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
2009-08-15 09:59:59 +00:00
|
|
|
$images = $this->localRepo->findFiles( $items );
|
2008-05-20 17:05:57 +00:00
|
|
|
|
|
|
|
|
foreach ( $this->foreignRepos as $repo ) {
|
2009-08-15 09:59:59 +00:00
|
|
|
// Remove found files from $items
|
|
|
|
|
foreach ( $images as $name => $image ) {
|
|
|
|
|
unset( $items[$name] );
|
|
|
|
|
}
|
2010-01-22 03:14:52 +00:00
|
|
|
|
2009-08-15 09:59:59 +00:00
|
|
|
$images = array_merge( $images, $repo->findFiles( $items ) );
|
2008-05-20 17:05:57 +00:00
|
|
|
}
|
|
|
|
|
return $images;
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
|
2008-01-16 18:27:43 +00:00
|
|
|
/**
|
|
|
|
|
* Interface for FileRepo::checkRedirect()
|
|
|
|
|
*/
|
2011-11-04 23:49:03 +00:00
|
|
|
function checkRedirect( Title $title ) {
|
2008-01-16 18:27:43 +00:00
|
|
|
if ( !$this->reposInitialised ) {
|
|
|
|
|
$this->initialiseRepos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$redir = $this->localRepo->checkRedirect( $title );
|
|
|
|
|
if( $redir ) {
|
|
|
|
|
return $redir;
|
|
|
|
|
}
|
|
|
|
|
foreach ( $this->foreignRepos as $repo ) {
|
|
|
|
|
$redir = $repo->checkRedirect( $title );
|
|
|
|
|
if ( $redir ) {
|
|
|
|
|
return $redir;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-01-22 03:14:52 +00:00
|
|
|
|
2011-03-28 21:40:50 +00:00
|
|
|
/**
|
|
|
|
|
* Find an instance of the file with this key, created at the specified time
|
|
|
|
|
* Returns false if the file does not exist.
|
|
|
|
|
*
|
|
|
|
|
* @param $hash String base 36 SHA-1 hash
|
2012-02-09 19:30:01 +00:00
|
|
|
* @param $options array Option array, same as findFile()
|
2011-03-28 21:40:50 +00:00
|
|
|
* @return File object or false if it is not found
|
|
|
|
|
*/
|
|
|
|
|
function findFileFromKey( $hash, $options = array() ) {
|
|
|
|
|
if ( !$this->reposInitialised ) {
|
|
|
|
|
$this->initialiseRepos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$file = $this->localRepo->findFileFromKey( $hash, $options );
|
|
|
|
|
if ( !$file ) {
|
|
|
|
|
foreach ( $this->foreignRepos as $repo ) {
|
|
|
|
|
$file = $repo->findFileFromKey( $hash, $options );
|
|
|
|
|
if ( $file ) break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $file;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-20 20:34:03 +00:00
|
|
|
/**
|
|
|
|
|
* Find all instances of files with this key
|
|
|
|
|
*
|
2011-03-20 20:50:05 +00:00
|
|
|
* @param $hash String base 36 SHA-1 hash
|
2011-03-20 20:34:03 +00:00
|
|
|
* @return Array of File objects
|
|
|
|
|
*/
|
2008-05-14 15:11:48 +00:00
|
|
|
function findBySha1( $hash ) {
|
|
|
|
|
if ( !$this->reposInitialised ) {
|
|
|
|
|
$this->initialiseRepos();
|
|
|
|
|
}
|
2010-01-22 03:14:52 +00:00
|
|
|
|
2008-05-14 15:11:48 +00:00
|
|
|
$result = $this->localRepo->findBySha1( $hash );
|
2011-03-20 20:34:03 +00:00
|
|
|
foreach ( $this->foreignRepos as $repo ) {
|
2008-05-14 15:11:48 +00:00
|
|
|
$result = array_merge( $result, $repo->findBySha1( $hash ) );
|
2011-03-20 20:34:03 +00:00
|
|
|
}
|
2010-01-22 03:14:52 +00:00
|
|
|
return $result;
|
2008-05-14 15:11:48 +00:00
|
|
|
}
|
2008-01-16 18:27:43 +00:00
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
/**
|
|
|
|
|
* Get the repo instance with a given key.
|
|
|
|
|
*/
|
|
|
|
|
function getRepo( $index ) {
|
|
|
|
|
if ( !$this->reposInitialised ) {
|
|
|
|
|
$this->initialiseRepos();
|
|
|
|
|
}
|
2007-11-19 09:43:47 +00:00
|
|
|
if ( $index === 'local' ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
return $this->localRepo;
|
|
|
|
|
} elseif ( isset( $this->foreignRepos[$index] ) ) {
|
|
|
|
|
return $this->foreignRepos[$index];
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-02-09 13:40:16 +00:00
|
|
|
/**
|
|
|
|
|
* Get the repo instance by its name
|
|
|
|
|
*/
|
|
|
|
|
function getRepoByName( $name ) {
|
|
|
|
|
if ( !$this->reposInitialised ) {
|
|
|
|
|
$this->initialiseRepos();
|
|
|
|
|
}
|
2010-10-14 20:53:04 +00:00
|
|
|
foreach ( $this->foreignRepos as $repo ) {
|
2008-02-09 13:40:16 +00:00
|
|
|
if ( $repo->name == $name)
|
|
|
|
|
return $repo;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
|
2007-05-31 01:43:41 +00:00
|
|
|
/**
|
|
|
|
|
* Get the local repository, i.e. the one corresponding to the local image
|
|
|
|
|
* table. Files are typically uploaded to the local repository.
|
2011-07-01 02:25:19 +00:00
|
|
|
*
|
|
|
|
|
* @return LocalRepo
|
2007-05-31 01:43:41 +00:00
|
|
|
*/
|
2007-05-30 21:02:32 +00:00
|
|
|
function getLocalRepo() {
|
|
|
|
|
return $this->getRepo( 'local' );
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-03 13:50:37 +00:00
|
|
|
/**
|
2010-01-22 03:14:52 +00:00
|
|
|
* Call a function for each foreign repo, with the repo object as the
|
2008-09-16 06:13:31 +00:00
|
|
|
* first parameter.
|
|
|
|
|
*
|
2010-03-26 21:55:13 +00:00
|
|
|
* @param $callback Callback: the function to call
|
|
|
|
|
* @param $params Array: optional additional parameters to pass to the function
|
2008-09-03 13:50:37 +00:00
|
|
|
*/
|
2008-05-01 22:16:23 +00:00
|
|
|
function forEachForeignRepo( $callback, $params = array() ) {
|
|
|
|
|
foreach( $this->foreignRepos as $repo ) {
|
|
|
|
|
$args = array_merge( array( $repo ), $params );
|
|
|
|
|
if( call_user_func_array( $callback, $args ) ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-03 13:50:37 +00:00
|
|
|
/**
|
2008-09-16 06:13:31 +00:00
|
|
|
* Does the installation have any foreign repos set up?
|
2010-03-26 21:55:13 +00:00
|
|
|
* @return Boolean
|
2008-09-03 13:50:37 +00:00
|
|
|
*/
|
2008-05-01 22:16:23 +00:00
|
|
|
function hasForeignRepos() {
|
2008-09-16 06:13:31 +00:00
|
|
|
return (bool)$this->foreignRepos;
|
2008-05-01 22:16:23 +00:00
|
|
|
}
|
|
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
/**
|
|
|
|
|
* Initialise the $repos array
|
|
|
|
|
*/
|
|
|
|
|
function initialiseRepos() {
|
|
|
|
|
if ( $this->reposInitialised ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$this->reposInitialised = true;
|
|
|
|
|
|
|
|
|
|
$this->localRepo = $this->newRepo( $this->localInfo );
|
|
|
|
|
$this->foreignRepos = array();
|
|
|
|
|
foreach ( $this->foreignInfo as $key => $info ) {
|
|
|
|
|
$this->foreignRepos[$key] = $this->newRepo( $info );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-31 01:43:41 +00:00
|
|
|
/**
|
|
|
|
|
* Create a repo class based on an info structure
|
|
|
|
|
*/
|
|
|
|
|
protected function newRepo( $info ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
$class = $info['class'];
|
|
|
|
|
return new $class( $info );
|
|
|
|
|
}
|
2007-06-16 02:55:25 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Split a virtual URL into repo, zone and rel parts
|
2012-02-09 19:30:01 +00:00
|
|
|
* @param $url string
|
|
|
|
|
* @return array containing repo, zone and rel
|
2007-06-16 02:55:25 +00:00
|
|
|
*/
|
|
|
|
|
function splitVirtualUrl( $url ) {
|
|
|
|
|
if ( substr( $url, 0, 9 ) != 'mwrepo://' ) {
|
2011-03-21 18:38:45 +00:00
|
|
|
throw new MWException( __METHOD__.': unknown protocol' );
|
2007-06-16 02:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$bits = explode( '/', substr( $url, 9 ), 3 );
|
|
|
|
|
if ( count( $bits ) != 3 ) {
|
|
|
|
|
throw new MWException( __METHOD__.": invalid mwrepo URL: $url" );
|
|
|
|
|
}
|
|
|
|
|
return $bits;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getFileProps( $fileName ) {
|
|
|
|
|
if ( FileRepo::isVirtualUrl( $fileName ) ) {
|
2007-08-21 03:57:54 +00:00
|
|
|
list( $repoName, /* $zone */, /* $rel */ ) = $this->splitVirtualUrl( $fileName );
|
2007-06-16 02:55:25 +00:00
|
|
|
if ( $repoName === '' ) {
|
|
|
|
|
$repoName = 'local';
|
|
|
|
|
}
|
|
|
|
|
$repo = $this->getRepo( $repoName );
|
|
|
|
|
return $repo->getFileProps( $fileName );
|
|
|
|
|
} else {
|
2011-12-20 03:52:06 +00:00
|
|
|
return FSFile::getPropsFromPath( $fileName );
|
2007-06-16 02:55:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-08-15 09:59:59 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Limit cache memory
|
|
|
|
|
*/
|
2011-09-21 20:51:26 +00:00
|
|
|
protected function trimCache() {
|
2009-08-15 09:59:59 +00:00
|
|
|
while ( count( $this->cache ) >= self::MAX_CACHE_SIZE ) {
|
|
|
|
|
reset( $this->cache );
|
|
|
|
|
$key = key( $this->cache );
|
|
|
|
|
wfDebug( __METHOD__.": evicting $key\n" );
|
|
|
|
|
unset( $this->cache[$key] );
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-21 21:32:24 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clear RepoGroup process cache used for finding a file
|
|
|
|
|
* @param $title Title|null Title of the file or null to clear all files
|
|
|
|
|
*/
|
|
|
|
|
public function clearCache( Title $title = null ) {
|
|
|
|
|
if ( $title == null ) {
|
|
|
|
|
$this->cache = array();
|
|
|
|
|
} else {
|
|
|
|
|
$dbKey = $title->getDBkey();
|
|
|
|
|
if ( isset( $this->cache[$dbKey] ) ) {
|
|
|
|
|
unset( $this->cache[$dbKey] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|