MediaWiki  REL1_24
LocalRepo Class Reference

A repository that stores files in the local filesystem and registers them in the wiki's own database. More...

Inheritance diagram for LocalRepo:
Collaboration diagram for LocalRepo:

List of all members.

Public Member Functions

 checkRedirect (Title $title)
 Checks if there is a redirect named as $title.
 cleanupDeletedBatch (array $storageKeys)
 Delete files in the deleted directory if they are not referenced in the filearchive table.
 findBySha1 ($hash)
 Get an array or iterator of file objects for files that have a given SHA-1 content hash.
 findBySha1s (array $hashes)
 Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes.
 findFiles (array $items, $flags=0)
 Find many files at once.
 findFilesByPrefix ($prefix, $limit)
 Return an array of files where the name starts with $prefix.
 getInfo ()
 Return information about the repository.
 getMasterDB ()
 Get a connection to the master DB.
 getSharedCacheKey ()
 Get a key on the primary cache for this repository.
 getSlaveDB ()
 Get a connection to the slave DB.
 invalidateImageRedirect (Title $title)
 Invalidates image redirect cache related to that image.
 newFileFromRow ($row)
 newFromArchiveName ($title, $archiveName)

Static Public Member Functions

static getHashFromKey ($key)
 Gets the SHA1 hash from a storage key.

Protected Member Functions

 deletedFileHasKey ($key, $lock=null)
 Check if a deleted (filearchive) file has this sha1 key.
 getArticleID ($title)
 Function link Title::getArticleID().
 hiddenFileHasKey ($key, $lock=null)
 Check if a hidden (revision delete) file has this sha1 key.

Protected Attributes

array $fileFactory = array( 'LocalFile', 'newFromTitle' )
 *
array $fileFactoryKey = array( 'LocalFile', 'newFromKey' )
 *
array $fileFromRowFactory = array( 'LocalFile', 'newFromRow' )
 *
array $oldFileFactory = array( 'OldLocalFile', 'newFromTitle' )
 *
array $oldFileFactoryKey = array( 'OldLocalFile', 'newFromKey' )
 *
array $oldFileFromRowFactory = array( 'OldLocalFile', 'newFromRow' )
 *

Detailed Description

A repository that stores files in the local filesystem and registers them in the wiki's own database.

This is the most commonly used repository class.

Definition at line 31 of file LocalRepo.php.


Member Function Documentation

Checks if there is a redirect named as $title.

Parameters:
Title$titleTitle of file
Returns:
bool|Title

Reimplemented from FileRepo.

Definition at line 166 of file LocalRepo.php.

Delete files in the deleted directory if they are not referenced in the filearchive table.

This needs to be done in the repo because it needs to interleave database locks with file operations, which is potentially a remote operation.

Parameters:
array$storageKeys
Returns:
FileRepoStatus

Reimplemented from FileRepo.

Definition at line 78 of file LocalRepo.php.

LocalRepo::deletedFileHasKey ( key,
lock = null 
) [protected]

Check if a deleted (filearchive) file has this sha1 key.

Parameters:
string$keyFile storage key (base-36 sha1 key with file extension)
string | null$lockUse "lock" to lock the row via FOR UPDATE
Returns:
bool File with this key is in use

Definition at line 116 of file LocalRepo.php.

LocalRepo::findBySha1 ( hash)

Get an array or iterator of file objects for files that have a given SHA-1 content hash.

Parameters:
string$hashA sha1 hash to look for
Returns:
File[]

Reimplemented from FileRepo.

Definition at line 369 of file LocalRepo.php.

Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes.

Overrides generic implementation in FileRepo for performance reason

Parameters:
array$hashesAn array of hashes
Returns:
array An Array of arrays or iterators of file objects and the hash as key

Reimplemented from FileRepo.

Definition at line 397 of file LocalRepo.php.

LocalRepo::findFiles ( array items,
flags = 0 
)

Find 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

Reimplemented from FileRepo.

Definition at line 237 of file LocalRepo.php.

LocalRepo::findFilesByPrefix ( prefix,
limit 
)

Return an array of files where the name starts with $prefix.

Parameters:
string$prefixThe prefix to search for
int$limitThe maximum amount of files to return
Returns:
array

Reimplemented from FileRepo.

Definition at line 428 of file LocalRepo.php.

LocalRepo::getArticleID ( title) [protected]

Function link Title::getArticleID().

We can't say Title object, what database it should use, so we duplicate that function here.

Parameters:
Title$title
Returns:
bool|int|mixed

Definition at line 219 of file LocalRepo.php.

static LocalRepo::getHashFromKey ( key) [static]

Gets the SHA1 hash from a storage key.

Parameters:
string$key
Returns:
string

Definition at line 156 of file LocalRepo.php.

Referenced by LocalFileRestoreBatch\addIds(), PopulateFilearchiveSha1\doDBUpdates(), and DeleteArchivedFilesImplementation\doDelete().

Return information about the repository.

Returns:
array
Since:
1.22

Reimplemented from FileRepo.

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 503 of file LocalRepo.php.

Get a connection to the master DB.

Returns:
DatabaseBase

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 462 of file LocalRepo.php.

Get a key on the primary cache for this repository.

Returns false if the repository's cache is not accessible at this site. The parameters are the parts of the key, as for wfMemcKey().

Returns:
string

Reimplemented from FileRepo.

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 473 of file LocalRepo.php.

Get a connection to the slave DB.

Returns:
DatabaseBase

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 454 of file LocalRepo.php.

LocalRepo::hiddenFileHasKey ( key,
lock = null 
) [protected]

Check if a hidden (revision delete) file has this sha1 key.

Parameters:
string$keyFile storage key (base-36 sha1 key with file extension)
string | null$lockUse "lock" to lock the row via FOR UPDATE
Returns:
bool File with this key is in use

Definition at line 134 of file LocalRepo.php.

Invalidates image redirect cache related to that image.

Parameters:
Title$titleTitle of page
Returns:
void

Reimplemented from FileRepo.

Definition at line 485 of file LocalRepo.php.

Exceptions:
MWException
Parameters:
stdClass$row
Returns:
LocalFile

Definition at line 49 of file LocalRepo.php.

LocalRepo::newFromArchiveName ( title,
archiveName 
)
Parameters:
Title$title
string$archiveName
Returns:
OldLocalFile

Definition at line 64 of file LocalRepo.php.

References $title.


Member Data Documentation

array LocalRepo::$fileFactory = array( 'LocalFile', 'newFromTitle' ) [protected]

*

Reimplemented from FileRepo.

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 32 of file LocalRepo.php.

array LocalRepo::$fileFactoryKey = array( 'LocalFile', 'newFromKey' ) [protected]

*

Reimplemented from FileRepo.

Definition at line 34 of file LocalRepo.php.

array LocalRepo::$fileFromRowFactory = array( 'LocalFile', 'newFromRow' ) [protected]

*

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 36 of file LocalRepo.php.

array LocalRepo::$oldFileFactory = array( 'OldLocalFile', 'newFromTitle' ) [protected]

*

Reimplemented from FileRepo.

Definition at line 40 of file LocalRepo.php.

array LocalRepo::$oldFileFactoryKey = array( 'OldLocalFile', 'newFromKey' ) [protected]

*

Reimplemented from FileRepo.

Definition at line 42 of file LocalRepo.php.

array LocalRepo::$oldFileFromRowFactory = array( 'OldLocalFile', 'newFromRow' ) [protected]

*

Definition at line 38 of file LocalRepo.php.


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