MediaWiki  1.23.15
RepoGroup Class Reference

Prioritized list of file repositories. More...

Collaboration diagram for RepoGroup:

Public Member Functions

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

Static Public Member Functions

static destroySingleton ()
 Destroy the singleton instance, so that a new one will be created next time singleton() is called. More...
 
static setSingleton ( $instance)
 Set the singleton instance to a given object Used by extensions which hook into the Repo chain. More...
 
static singleton ()
 Get a RepoGroup instance. More...
 

Public Attributes

const MAX_CACHE_SIZE = 500
 Maximum number of cache items. More...
 

Protected Member Functions

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

Protected Attributes

ProcessCacheLRU $cache
 
array $foreignInfo
 
FileRepo[] $foreignRepos
 
array $localInfo
 
LocalRepo $localRepo
 
bool $reposInitialised = false
 

Static Protected Attributes

static $instance
 

Detailed Description

Prioritized list of file repositories.

Definition at line 29 of file RepoGroup.php.

Constructor & Destructor Documentation

◆ __construct()

RepoGroup::__construct (   $localInfo,
  $foreignInfo 
)

Construct a group of file repositories.

Parameters
array$localInfoAssociative array for local repo's info
array$foreignInfoof 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.

Definition at line 92 of file RepoGroup.php.

References $foreignInfo, $localInfo, and cache.

Member Function Documentation

◆ checkRedirect()

RepoGroup::checkRedirect ( Title  $title)

Interface for FileRepo::checkRedirect()

Parameters
$titleTitle
Returns
bool

Definition at line 220 of file RepoGroup.php.

References $title, as, and initialiseRepos().

◆ clearCache()

RepoGroup::clearCache ( Title  $title = null)

Clear RepoGroup process cache used for finding a file.

Parameters
Title | null$titleTitle of the file or null to clear all files

Definition at line 448 of file RepoGroup.php.

References $title, and cache.

◆ destroySingleton()

static RepoGroup::destroySingleton ( )
static

Destroy the singleton instance, so that a new one will be created next time singleton() is called.

Definition at line 67 of file RepoGroup.php.

Referenced by UploadFromUrlTestSuite\setUp(), and UploadFromUrlTestSuite\tearDown().

◆ findBySha1()

RepoGroup::findBySha1 (   $hash)

Find all instances of files with this key.

Parameters
string$hashbase 36 SHA-1 hash
Returns
Array of File objects

Definition at line 272 of file RepoGroup.php.

References $hash, as, and initialiseRepos().

◆ findBySha1s()

RepoGroup::findBySha1s ( array  $hashes)

Find all instances of files with this keys.

Parameters
array$hashesbase 36 SHA-1 hashes
Returns
array of array of File objects

Definition at line 292 of file RepoGroup.php.

References $files, $hash, $hashes, as, and initialiseRepos().

◆ findFile()

RepoGroup::findFile (   $title,
  $options = array() 
)

Search repositories for an image.

You can also use wfFindFile() to do this.

Parameters
$titleTitle|string Title object or string
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 true, return restricted (deleted) files if the current 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
Returns
File|bool False if title is not found

Definition at line 114 of file RepoGroup.php.

References $options, $time, $title, array(), as, cache, initialiseRepos(), and File\normalizeTitle().

◆ findFileFromKey()

RepoGroup::findFileFromKey (   $hash,
  $options = array() 
)

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 object or false if it is not found

Definition at line 248 of file RepoGroup.php.

References $file, $hash, $options, as, and initialiseRepos().

◆ findFiles()

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

Search repositories for many files at once.

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

$findItem = array( 'title' => $title, 'private' => true ); $findBatch = array( $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
Parameters
array$inputItems
integer$flags
Returns
array

Definition at line 185 of file RepoGroup.php.

References $flags, $name, array(), as, initialiseRepos(), and File\normalizeTitle().

◆ forEachForeignRepo()

RepoGroup::forEachForeignRepo (   $callback,
  $params = array() 
)

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 363 of file RepoGroup.php.

References $args, $params, array(), and as.

◆ getFileProps()

RepoGroup::getFileProps (   $fileName)
Parameters
string$fileName
Returns
array

Definition at line 430 of file RepoGroup.php.

References FSFile\getPropsFromPath(), getRepo(), FileRepo\isVirtualUrl(), list, and splitVirtualUrl().

◆ getLocalRepo()

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 351 of file RepoGroup.php.

References getRepo().

◆ getRepo()

RepoGroup::getRepo (   $index)

Get the repo instance with a given key.

Parameters
string | int$index
Returns
bool|LocalRepo

Definition at line 314 of file RepoGroup.php.

References $localRepo, and initialiseRepos().

Referenced by getFileProps(), and getLocalRepo().

◆ getRepoByName()

RepoGroup::getRepoByName (   $name)

Get the repo instance by its name.

Parameters
string$name
Returns
bool

Definition at line 332 of file RepoGroup.php.

References $name, as, and initialiseRepos().

◆ hasForeignRepos()

RepoGroup::hasForeignRepos ( )

Does the installation have any foreign repos set up?

Returns
bool

Definition at line 378 of file RepoGroup.php.

References $foreignRepos.

◆ initialiseRepos()

RepoGroup::initialiseRepos ( )

Initialise the $repos array.

Definition at line 385 of file RepoGroup.php.

References array(), as, and newRepo().

Referenced by checkRedirect(), findBySha1(), findBySha1s(), findFile(), findFileFromKey(), findFiles(), getRepo(), and getRepoByName().

◆ newRepo()

RepoGroup::newRepo (   $info)
protected

Create a repo class based on an info structure.

Definition at line 401 of file RepoGroup.php.

Referenced by initialiseRepos().

◆ setSingleton()

static RepoGroup::setSingleton (   $instance)
static

Set the singleton instance to a given object 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()

Parameters
RepoGroup$instance

Definition at line 79 of file RepoGroup.php.

References $instance.

◆ singleton()

static RepoGroup::singleton ( )
static

Get a RepoGroup instance.

At present only one instance of RepoGroup is needed in a MediaWiki invocation, this may change in the future.

Returns
RepoGroup

Definition at line 53 of file RepoGroup.php.

References $instance, and global.

Referenced by ApiQueryAllImages\__construct(), UploadFromChunks\__construct(), UploadFromStash\__construct(), SpecialUploadStash\__construct(), RevDel_FileItem\__construct(), RevertFileAction\checkCanExecute(), ApiDelete\deleteFile(), ApiTestCaseUpload\deleteFileByContent(), DeleteArchivedFilesImplementation\doDelete(), RevDel_FileList\doPreCommitUpdates(), MovePageForm\doSubmit(), ApiMove\execute(), ApiQueryStashImageInfo\execute(), CheckImages\execute(), RefreshFileHeaders\execute(), UploadStashCleanup\execute(), ApiQueryImageInfo\execute(), FileDeleteForm\execute(), RefreshImageMetadata\execute(), LocalFileRestoreBatch\execute(), ImageCleanup\filePath(), ImageListPager\formatValue(), UploadForm\getDescriptionSection(), FileDuplicateSearchPage\getDupes(), WikiFilePage\getDuplicates(), ApiQueryFileRepoInfo\getInitialisedRepoGroup(), ImageBuilder\getRepo(), WikiRevision\importUpload(), Linker\makeBrokenImageLinkObj(), Title\moveTo(), WikiPage\onArticleDelete(), PurgeChangedFiles\purgeFromLogType(), ApiQueryDuplicateFiles\run(), EraseArchivedFile\scrubVersion(), SpecialUndelete\showFile(), UploadStashTest\testBug29408(), SpecialUploadStash\tryClearStashedUploads(), SpecialRevisionDelete\tryShowFile(), WikiPage\updateRedirectOn(), ApiFileRevert\validateParameters(), wfExtractThumbRequestInfo(), wfStreamThumb(), and wfThumbHandle404().

◆ splitVirtualUrl()

RepoGroup::splitVirtualUrl (   $url)

Split a virtual URL into repo, zone and rel parts.

Parameters
string$url
Exceptions
MWException
Returns
array containing repo, zone and rel

Definition at line 413 of file RepoGroup.php.

Referenced by getFileProps().

Member Data Documentation

◆ $cache

ProcessCacheLRU RepoGroup::$cache
protected

Definition at line 40 of file RepoGroup.php.

◆ $foreignInfo

array RepoGroup::$foreignInfo
protected

Definition at line 38 of file RepoGroup.php.

Referenced by __construct().

◆ $foreignRepos

FileRepo [] RepoGroup::$foreignRepos
protected

Definition at line 32 of file RepoGroup.php.

Referenced by hasForeignRepos().

◆ $instance

RepoGroup::$instance
staticprotected

Definition at line 43 of file RepoGroup.php.

Referenced by setSingleton(), and singleton().

◆ $localInfo

array RepoGroup::$localInfo
protected

Definition at line 36 of file RepoGroup.php.

Referenced by __construct().

◆ $localRepo

LocalRepo RepoGroup::$localRepo
protected

Definition at line 30 of file RepoGroup.php.

Referenced by getRepo().

◆ $reposInitialised

bool RepoGroup::$reposInitialised = false
protected

Definition at line 34 of file RepoGroup.php.

◆ MAX_CACHE_SIZE

const RepoGroup::MAX_CACHE_SIZE = 500

Maximum number of cache items.

Definition at line 46 of file RepoGroup.php.


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