60 if ( self::$instance ) {
74 self::$instance =
null;
125 if ( isset(
$options[
'bypassCache'] ) ) {
129 if ( !$this->reposInitialised ) {
138 $dbkey = $title->getDBkey();
139 if ( empty(
$options[
'ignoreRedirect'] )
144 if ( $this->
cache->has( $dbkey,
$time, 60 ) ) {
153 # Check the local repo
156 # Check the foreign repos
158 foreach ( $this->foreignRepos as $repo ) {
167 # Cache file existence or non-existence
168 if ( $useCache && ( !
$image ||
$image->isCacheable() ) ) {
193 if ( !$this->reposInitialised ) {
198 foreach ( $inputItems as $item ) {
199 if ( !is_array( $item ) ) {
200 $item = [
'title' => $item ];
203 if ( $item[
'title'] ) {
204 $items[$item[
'title']->getDBkey()] = $item;
208 $images = $this->localRepo->findFiles( $items, $flags );
210 foreach ( $this->foreignRepos as $repo ) {
212 foreach ( $images as $name =>
$image ) {
213 unset( $items[$name] );
216 $images = array_merge( $images, $repo->findFiles( $items, $flags ) );
228 if ( !$this->reposInitialised ) {
232 $redir = $this->localRepo->checkRedirect( $title );
237 foreach ( $this->foreignRepos as $repo ) {
238 $redir = $repo->checkRedirect( $title );
256 if ( !$this->reposInitialised ) {
260 $file = $this->localRepo->findFileFromKey( $hash,
$options );
262 foreach ( $this->foreignRepos as $repo ) {
263 $file = $repo->findFileFromKey( $hash,
$options );
280 if ( !$this->reposInitialised ) {
284 $result = $this->localRepo->findBySha1( $hash );
285 foreach ( $this->foreignRepos as $repo ) {
286 $result = array_merge( $result, $repo->findBySha1( $hash ) );
288 usort( $result,
'File::compare' );
300 if ( !$this->reposInitialised ) {
304 $result = $this->localRepo->findBySha1s(
$hashes );
305 foreach ( $this->foreignRepos as $repo ) {
306 $result = array_merge_recursive( $result, $repo->findBySha1s(
$hashes ) );
309 foreach ( $result as $hash => $files ) {
310 usort( $result[$hash],
'File::compare' );
322 if ( !$this->reposInitialised ) {
325 if ( $index ===
'local' ) {
327 } elseif ( isset( $this->foreignRepos[$index] ) ) {
328 return $this->foreignRepos[$index];
340 if ( !$this->reposInitialised ) {
343 foreach ( $this->foreignRepos as $repo ) {
344 if ( $repo->name == $name ) {
359 return $this->
getRepo(
'local' );
371 if ( !$this->reposInitialised ) {
374 foreach ( $this->foreignRepos as $repo ) {
376 if ( call_user_func_array( $callback,
$args ) ) {
389 if ( !$this->reposInitialised ) {
399 if ( $this->reposInitialised ) {
402 $this->reposInitialised =
true;
404 $this->localRepo = $this->
newRepo( $this->localInfo );
405 $this->foreignRepos = [];
406 foreach ( $this->foreignInfo as $key => $info ) {
407 $this->foreignRepos[$key] = $this->
newRepo( $info );
417 $class = $info[
'class'];
419 return new $class( $info );
429 if ( substr( $url, 0, 9 ) !=
'mwrepo://' ) {
430 throw new MWException( __METHOD__ .
': unknown protocol' );
433 $bits = explode(
'/', substr( $url, 9 ), 3 );
434 if ( count( $bits ) != 3 ) {
435 throw new MWException( __METHOD__ .
": invalid mwrepo URL: $url" );
448 if ( $repoName ===
'' ) {
451 $repo = $this->
getRepo( $repoName );
453 return $repo->getFileProps( $fileName );
457 return $mwProps->getPropsFromPath( $fileName,
true );
466 if ( $title ==
null ) {
467 $this->
cache->clear();
469 $this->
cache->clear( $title->getDBkey() );
$wgLocalFileRepo
File repository structures.
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.
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
see documentation in includes Linker php for Linker::makeImageLink & $time
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
you have access to all of the normal MediaWiki so you can get a DB use the cache