MediaWiki master
MediaWiki\FileRepo\RepoGroup Class Reference

Prioritized list of file repositories. More...

Collaboration diagram for MediaWiki\FileRepo\RepoGroup:

Public Member Functions

 __construct ( $localInfo, $foreignInfo, WANObjectCache $wanCache, MimeAnalyzer $mimeAnalyzer)
 Construct a group of file repositories.
 
 checkRedirect ( $title)
 Interface for FileRepo::checkRedirect()
 
 clearCache ( $title=null)
 Clear RepoGroup process cache used for finding a file.
 
 findBySha1 ( $hash)
 Find all instances of files with this key.
 
 findBySha1s (array $hashes)
 Find all instances of files with this keys.
 
 findFile ( $title, $options=[])
 Search repositories for an image.
 
 findFileFromKey ( $hash, $options=[])
 Find an instance of the file with this key, created at the specified time Returns false if the file does not exist.
 
 findFiles (array $inputItems, $flags=0)
 Search repositories for many files at once.
 
 forEachForeignRepo ( $callback, $params=[])
 Call a function for each foreign repo, with the repo object as the first parameter.
 
 getFileProps ( $fileName)
 
 getLocalRepo ()
 Get the local repository, i.e.
 
 getRepo ( $index)
 Get the repo instance with a given key.
 
 getRepoByName ( $name)
 Get the repo instance by its name.
 
 hasForeignRepos ()
 Does the installation have any foreign repos set up?
 
 initialiseRepos ()
 Initialise the $repos array.
 
 newCustomLocalRepo ( $info=[])
 Create a local repo with the specified option overrides.
 

Protected Member Functions

 newRepo ( $info)
 Create a repo class based on an info structure.
 

Protected Attributes

MapCacheLRU $cache
 
array $foreignInfo
 
FileRepo[] $foreignRepos
 
array $localInfo
 
LocalRepo $localRepo
 
bool $reposInitialised = false
 
WANObjectCache $wanCache
 

Detailed Description

Prioritized list of file repositories.

Definition at line 38 of file RepoGroup.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\FileRepo\RepoGroup::__construct ( $localInfo,
$foreignInfo,
WANObjectCache $wanCache,
MimeAnalyzer $mimeAnalyzer )

Construct a group of file repositories.

Do not call this – use MediaWikiServices::getRepoGroup.

Parameters
array$localInfoAssociative array for local repo's info
array$foreignInfoArray of repository info arrays. Each info array is an associative array with the 'class' member giving the class name. The entire array is passed to the repository constructor as the first parameter.
WANObjectCache$wanCache
MimeAnalyzer$mimeAnalyzer

Definition at line 78 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\$foreignInfo, MediaWiki\FileRepo\RepoGroup\$localInfo, and MediaWiki\FileRepo\RepoGroup\$wanCache.

Member Function Documentation

◆ checkRedirect()

MediaWiki\FileRepo\RepoGroup::checkRedirect ( $title)

Interface for FileRepo::checkRedirect()

Parameters
PageIdentity | LinkTarget | string$title
Returns
Title|false

Definition at line 218 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\initialiseRepos().

◆ clearCache()

MediaWiki\FileRepo\RepoGroup::clearCache ( $title = null)

Clear RepoGroup process cache used for finding a file.

Parameters
PageIdentity | string | null$titleFile page or file name, or null to clear all files

Definition at line 467 of file RepoGroup.php.

◆ findBySha1()

MediaWiki\FileRepo\RepoGroup::findBySha1 ( $hash)

Find all instances of files with this key.

Parameters
string$hashBase 36 SHA-1 hash
Returns
File[]

Definition at line 272 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\initialiseRepos().

◆ findBySha1s()

MediaWiki\FileRepo\RepoGroup::findBySha1s ( array $hashes)

Find all instances of files with this keys.

Parameters
string[]$hashesBase 36 SHA-1 hashes
Returns
File[][]

Definition at line 292 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\initialiseRepos().

◆ findFile()

MediaWiki\FileRepo\RepoGroup::findFile ( $title,
$options = [] )

Search repositories for an image.

Parameters
PageIdentity | LinkTarget | string$titleThe file to find
array$optionsAssociative array of options: 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 private: If Authority object, return restricted (deleted) files if the performer is allowed to view them. Otherwise, such files will not be found. Authority is only accepted since 1.37, User was required before. latest: If true, load from the latest available data into File objects @phpcs:ignore Generic.Files.LineLength
Returns
File|false False if title is not found

Definition at line 109 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\initialiseRepos(), and wfTimestamp().

◆ findFileFromKey()

MediaWiki\FileRepo\RepoGroup::findFileFromKey ( $hash,
$options = [] )

Find an instance of the file with this key, created at the specified time Returns false if the file does not exist.

Parameters
string$hashBase 36 SHA-1 hash
array$optionsOption array, same as findFile()
Returns
File|false File object or false if it is not found

Definition at line 248 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\initialiseRepos().

◆ findFiles()

MediaWiki\FileRepo\RepoGroup::findFiles ( array $inputItems,
$flags = 0 )

Search repositories for many files at once.

Parameters
array$inputItemsAn array of titles, or an array of findFile() options with the "title" option giving the title. Example:

$findItem = [ 'title' => $title, 'private' => true ]; $findBatch = [ $findItem ]; $repo->findFiles( $findBatch );

No title should appear in $items twice, as the result use titles as keys

Parameters
int$flagsSupports:
  • FileRepo::NAME_AND_TIME_ONLY : return a (search title => (title,timestamp)) map. The search title uses the input titles; the other is the final post-redirect title. All titles are returned as string DB keys and the inner array is associative.
Returns
array Map of (file name => File objects) for matches or (search title => (title,timestamp))

Definition at line 186 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\initialiseRepos().

◆ forEachForeignRepo()

MediaWiki\FileRepo\RepoGroup::forEachForeignRepo ( $callback,
$params = [] )

Call a function for each foreign repo, with the repo object as the first parameter.

Parameters
callable$callbackThe function to call
array$paramsOptional additional parameters to pass to the function
Returns
bool

Definition at line 361 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\initialiseRepos().

◆ getFileProps()

MediaWiki\FileRepo\RepoGroup::getFileProps ( $fileName)
Parameters
string$fileName
Returns
array

Definition at line 447 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\getRepo(), and MediaWiki\FileRepo\FileRepo\isVirtualUrl().

◆ getLocalRepo()

MediaWiki\FileRepo\RepoGroup::getLocalRepo ( )

Get the local repository, i.e.

the one corresponding to the local image table. Files are typically uploaded to the local repository.

Returns
LocalRepo

Definition at line 348 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\getRepo().

Referenced by MediaWiki\Api\ApiQueryAllImages\__construct(), MediaWiki\Pager\ImageListPager\__construct(), MediaWiki\Specials\SpecialUndelete\__construct(), and MediaWiki\Specials\SpecialUploadStash\__construct().

◆ getRepo()

MediaWiki\FileRepo\RepoGroup::getRepo ( $index)

Get the repo instance with a given key.

Parameters
string | int$index
Returns
FileRepo|false

Definition at line 314 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\$localRepo, and MediaWiki\FileRepo\RepoGroup\initialiseRepos().

Referenced by MediaWiki\FileRepo\RepoGroup\getFileProps(), and MediaWiki\FileRepo\RepoGroup\getLocalRepo().

◆ getRepoByName()

MediaWiki\FileRepo\RepoGroup::getRepoByName ( $name)

Get the repo instance by its name.

Parameters
string$name
Returns
FileRepo|false

Definition at line 329 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\initialiseRepos().

◆ hasForeignRepos()

MediaWiki\FileRepo\RepoGroup::hasForeignRepos ( )

Does the installation have any foreign repos set up?

Returns
bool

Definition at line 378 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\$foreignRepos, and MediaWiki\FileRepo\RepoGroup\initialiseRepos().

◆ initialiseRepos()

◆ newCustomLocalRepo()

MediaWiki\FileRepo\RepoGroup::newCustomLocalRepo ( $info = [])

Create a local repo with the specified option overrides.

Parameters
array$info
Returns
LocalRepo

Definition at line 407 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\newRepo().

◆ newRepo()

MediaWiki\FileRepo\RepoGroup::newRepo ( $info)
protected

Create a repo class based on an info structure.

Parameters
array$info
Returns
FileRepo

Definition at line 417 of file RepoGroup.php.

References MediaWiki\FileRepo\RepoGroup\$wanCache.

Referenced by MediaWiki\FileRepo\RepoGroup\initialiseRepos(), and MediaWiki\FileRepo\RepoGroup\newCustomLocalRepo().

Member Data Documentation

◆ $cache

MapCacheLRU MediaWiki\FileRepo\RepoGroup::$cache
protected

Definition at line 58 of file RepoGroup.php.

◆ $foreignInfo

array MediaWiki\FileRepo\RepoGroup::$foreignInfo
protected

Definition at line 55 of file RepoGroup.php.

Referenced by MediaWiki\FileRepo\RepoGroup\__construct().

◆ $foreignRepos

FileRepo [] MediaWiki\FileRepo\RepoGroup::$foreignRepos
protected

Definition at line 43 of file RepoGroup.php.

Referenced by MediaWiki\FileRepo\RepoGroup\hasForeignRepos().

◆ $localInfo

array MediaWiki\FileRepo\RepoGroup::$localInfo
protected

Definition at line 52 of file RepoGroup.php.

Referenced by MediaWiki\FileRepo\RepoGroup\__construct().

◆ $localRepo

LocalRepo MediaWiki\FileRepo\RepoGroup::$localRepo
protected

Definition at line 40 of file RepoGroup.php.

Referenced by MediaWiki\FileRepo\RepoGroup\getRepo().

◆ $reposInitialised

bool MediaWiki\FileRepo\RepoGroup::$reposInitialised = false
protected

Definition at line 49 of file RepoGroup.php.

◆ $wanCache

WANObjectCache MediaWiki\FileRepo\RepoGroup::$wanCache
protected

The documentation for this class was generated from the following file: