MediaWiki  REL1_22
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.
 findFilesByPrefix ($prefix, $limit)
 Return an array of files where the name starts with $prefix.
 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.

Public Attributes

 $fileFactory = array( 'LocalFile' , 'newFromTitle' )
 Factory functions for creating new files Override these in the base class.
 $fileFactoryKey = array( 'LocalFile' , 'newFromKey' )
 $fileFromRowFactory = array( 'LocalFile' , 'newFromRow' )
 $oldFileFactory = array( 'OldLocalFile', 'newFromTitle' )
 $oldFileFactoryKey = array( 'OldLocalFile', 'newFromKey' )
 $oldFileFromRowFactory = array( 'OldLocalFile', 'newFromRow' )

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.

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:
$titleTitle of file
Returns:
bool

Reimplemented from FileRepo.

Definition at line 158 of file LocalRepo.php.

References $dbr, $wgMemc, array(), getArticleID(), Title\getDBkey(), FileRepo\getLocalCacheKey(), getSharedCacheKey(), getSlaveDB(), global, Title\makeTitle(), Title\newFromText(), and File\normalizeTitle().

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:
$storageKeysarray
Returns:
FileRepoStatus

Reimplemented from FileRepo.

Definition at line 73 of file LocalRepo.php.

References FileRepo\$backend, $key, $path, array(), as, deletedFileHasKey(), FileBackend\doOperation(), FileRepo\getDeletedHashPath(), getMasterDB(), FileRepo\getZonePath(), hiddenFileHasKey(), FileRepo\newGood(), and wfDebug().

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 110 of file LocalRepo.php.

References $key, $options, array(), and getMasterDB().

Referenced by cleanupDeletedBatch().

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:
Array

Reimplemented from FileRepo.

Definition at line 232 of file LocalRepo.php.

References $dbr, $hash, $res, $result, array(), as, getSlaveDB(), newFileFromRow(), and LocalFile\selectFields().

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 260 of file LocalRepo.php.

References $dbr, $file, $res, $result, array(), as, getSlaveDB(), newFileFromRow(), and LocalFile\selectFields().

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 291 of file LocalRepo.php.

References $dbr, $files, $limit, $res, array(), as, getSlaveDB(), newFileFromRow(), and LocalFile\selectFields().

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:
$titleTitle
Returns:
bool|int|mixed

Definition at line 208 of file LocalRepo.php.

References $dbr, $title, array(), and getSlaveDB().

Referenced by checkRedirect().

static LocalRepo::getHashFromKey ( key) [static]

Gets the SHA1 hash from a storage key.

Parameters:
string$key
Returns:
string

Definition at line 148 of file LocalRepo.php.

References $key.

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

Get a connection to the master DB.

Returns:
DatabaseBase

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 324 of file LocalRepo.php.

References wfGetDB().

Referenced by cleanupDeletedBatch(), deletedFileHasKey(), and hiddenFileHasKey().

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 335 of file LocalRepo.php.

Referenced by checkRedirect(), and invalidateImageRedirect().

Get a connection to the slave DB.

Returns:
DatabaseBase

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 316 of file LocalRepo.php.

References wfGetDB().

Referenced by checkRedirect(), findBySha1(), findBySha1s(), findFilesByPrefix(), getArticleID(), and OldLocalFile\newFromKey().

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 127 of file LocalRepo.php.

References $ext, $key, $options, array(), File\DELETED_FILE, getHashFromKey(), getMasterDB(), and File\normalizeExtension().

Referenced by cleanupDeletedBatch().

Invalidates image redirect cache related to that image.

Parameters:
$titleTitle of page
Returns:
void

Reimplemented from FileRepo.

Definition at line 346 of file LocalRepo.php.

References $wgMemc, Title\getDBkey(), getSharedCacheKey(), and global.

Exceptions:
MWException
Parameters:
$row
Returns:
LocalFile

Definition at line 44 of file LocalRepo.php.

Referenced by findBySha1(), findBySha1s(), and findFilesByPrefix().

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

Definition at line 59 of file LocalRepo.php.

References $title.


Member Data Documentation

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

Factory functions for creating new files Override these in the base class.

Reimplemented from FileRepo.

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 32 of file LocalRepo.php.

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

Reimplemented from FileRepo.

Definition at line 33 of file LocalRepo.php.

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

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 34 of file LocalRepo.php.

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

Reimplemented from FileRepo.

Definition at line 35 of file LocalRepo.php.

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

Reimplemented from FileRepo.

Definition at line 36 of file LocalRepo.php.

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

Definition at line 37 of file LocalRepo.php.


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