60 if ( self::$instance ) {
74 self::$instance =
null;
125 if ( isset(
$options[
'bypassCache'] ) ) {
130 if ( !$this->reposInitialised ) {
140 $dbkey = $title->getDBkey();
142 if ( empty(
$options[
'ignoreRedirect'] )
146 if ( $this->
cache->hasField( $dbkey, $timeKey, 60 ) ) {
147 return $this->
cache->getField( $dbkey, $timeKey );
154 # Check the local repo
157 # Check the foreign repos
159 foreach ( $this->foreignRepos as $repo ) {
168 # Cache file existence or non-existence
169 if ( $useCache && ( !
$image ||
$image->isCacheable() ) ) {
170 $this->
cache->setField( $dbkey, $timeKey,
$image );
194 if ( !$this->reposInitialised ) {
199 foreach ( $inputItems as $item ) {
200 if ( !is_array( $item ) ) {
201 $item = [
'title' => $item ];
204 if ( $item[
'title'] ) {
205 $items[$item[
'title']->getDBkey()] = $item;
209 $images = $this->localRepo->findFiles( $items, $flags );
211 foreach ( $this->foreignRepos as $repo ) {
213 foreach ( $images as $name =>
$image ) {
214 unset( $items[$name] );
217 $images = array_merge( $images, $repo->findFiles( $items, $flags ) );
229 if ( !$this->reposInitialised ) {
233 $redir = $this->localRepo->checkRedirect( $title );
238 foreach ( $this->foreignRepos as $repo ) {
239 $redir = $repo->checkRedirect( $title );
257 if ( !$this->reposInitialised ) {
261 $file = $this->localRepo->findFileFromKey( $hash,
$options );
263 foreach ( $this->foreignRepos as $repo ) {
264 $file = $repo->findFileFromKey( $hash,
$options );
281 if ( !$this->reposInitialised ) {
285 $result = $this->localRepo->findBySha1( $hash );
286 foreach ( $this->foreignRepos as $repo ) {
287 $result = array_merge( $result, $repo->findBySha1( $hash ) );
289 usort( $result,
'File::compare' );
301 if ( !$this->reposInitialised ) {
305 $result = $this->localRepo->findBySha1s(
$hashes );
306 foreach ( $this->foreignRepos as $repo ) {
307 $result = array_merge_recursive( $result, $repo->findBySha1s(
$hashes ) );
310 foreach ( $result as $hash => $files ) {
311 usort( $result[$hash],
'File::compare' );
323 if ( !$this->reposInitialised ) {
326 if ( $index ===
'local' ) {
329 return $this->foreignRepos[$index] ??
false;
338 if ( !$this->reposInitialised ) {
341 foreach ( $this->foreignRepos as $repo ) {
342 if ( $repo->name == $name ) {
357 return $this->
getRepo(
'local' );
369 if ( !$this->reposInitialised ) {
372 foreach ( $this->foreignRepos as $repo ) {
373 if ( $callback( $repo, ...
$params ) ) {
386 if ( !$this->reposInitialised ) {
396 if ( $this->reposInitialised ) {
399 $this->reposInitialised =
true;
401 $this->localRepo = $this->
newRepo( $this->localInfo );
402 $this->foreignRepos = [];
403 foreach ( $this->foreignInfo as $key => $info ) {
404 $this->foreignRepos[$key] = $this->
newRepo( $info );
414 $class = $info[
'class'];
416 return new $class( $info );
426 if ( substr( $url, 0, 9 ) !=
'mwrepo://' ) {
427 throw new MWException( __METHOD__ .
': unknown protocol' );
430 $bits = explode(
'/', substr( $url, 9 ), 3 );
431 if ( count( $bits ) != 3 ) {
432 throw new MWException( __METHOD__ .
": invalid mwrepo URL: $url" );
445 if ( $repoName ===
'' ) {
448 $repo = $this->
getRepo( $repoName );
450 return $repo->getFileProps( $fileName );
454 return $mwProps->getPropsFromPath( $fileName,
true );
463 if ( $title ==
null ) {
464 $this->
cache->clear();
466 $this->
cache->clear( $title->getDBkey() );
$wgLocalFileRepo
File repository structures.
$wgForeignFileRepos
Enable the use of files from one or more other wikis.
Base class for file repositories.
static isVirtualUrl( $url)
Determine if a string is an mwrepo:// URL.
static normalizeTitle( $title, $exception=false)
Given a string or Title object return either a valid Title object with namespace NS_FILE or null.
A repository that stores files in the local filesystem and registers them in the wiki's own database.
MimeMagic helper wrapper.
Handles a simple LRU key/value map with a maximum number of entries.
Class for process caching individual properties of expiring items.
Prioritized list of file repositories.
initialiseRepos()
Initialise the $repos array.
getRepoByName( $name)
Get the repo instance by its name.
splitVirtualUrl( $url)
Split a virtual URL into repo, zone and rel parts.
const MAX_CACHE_SIZE
Maximum number of cache items.
hasForeignRepos()
Does the installation have any foreign repos set up?
findFileFromKey( $hash, $options=[])
Find an instance of the file with this key, created at the specified time Returns false if the file d...
__construct( $localInfo, $foreignInfo)
Construct a group of file repositories.
findFile( $title, $options=[])
Search repositories for an image.
getLocalRepo()
Get the local repository, i.e.
findBySha1s(array $hashes)
Find all instances of files with this keys.
checkRedirect(Title $title)
Interface for FileRepo::checkRedirect()
static RepoGroup $instance
getRepo( $index)
Get the repo instance with a given key.
clearCache(Title $title=null)
Clear RepoGroup process cache used for finding a file.
static singleton()
Get a RepoGroup instance.
findBySha1( $hash)
Find all instances of files with this key.
findFiles(array $inputItems, $flags=0)
Search repositories for many files at once.
static setSingleton( $instance)
Set the singleton instance to a given object Used by extensions which hook into the Repo chain.
newRepo( $info)
Create a repo class based on an info structure.
static destroySingleton()
Destroy the singleton instance, so that a new one will be created next time singleton() is called.
forEachForeignRepo( $callback, $params=[])
Call a function for each foreign repo, with the repo object as the first parameter.
Represents a title within MediaWiki.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
namespace being checked & $result
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check $image
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
processing should stop and the error should be shown to the user * false
you have access to all of the normal MediaWiki so you can get a DB use the cache
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))