MediaWiki  REL1_19
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 ($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.
 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 16 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 143 of file LocalRepo.php.

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

Here is the call graph for this function:

LocalRepo::cleanupDeletedBatch ( storageKeys)

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

References FileRepo\$backend, $path, deletedFileHasKey(), FileRepo\getDeletedHashPath(), getMasterDB(), FileRepo\getZonePath(), hiddenFileHasKey(), FileRepo\newGood(), and wfDebug().

Here is the call graph for this function:

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

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

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

Definition at line 95 of file LocalRepo.php.

References $options, and getMasterDB().

Referenced by cleanupDeletedBatch().

Here is the call graph for this function:

Here is the caller graph for this function:

LocalRepo::findBySha1 ( hash)

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

Parameters:
$hashString a sha1 hash to look for
Returns:
Array

Reimplemented from FileRepo.

Definition at line 217 of file LocalRepo.php.

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

Here is the call graph for this function:

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

Definition at line 193 of file LocalRepo.php.

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

Referenced by checkRedirect().

Here is the call graph for this function:

Here is the caller graph for this function:

static LocalRepo::getHashFromKey ( key) [static]

Gets the SHA1 hash from a storage key.

Parameters:
string$key
Returns:
string

Definition at line 133 of file LocalRepo.php.

Referenced by ApiQueryFilearchive\execute(), and hiddenFileHasKey().

Here is the caller graph for this function:

Get a connection to the master DB.

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 244 of file LocalRepo.php.

References wfGetDB().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Referenced by checkRedirect(), and invalidateImageRedirect().

Here is the caller graph for this function:

Get a connection to the slave DB.

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 237 of file LocalRepo.php.

References wfGetDB().

Referenced by checkRedirect(), findBySha1(), and getArticleID().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

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

Definition at line 112 of file LocalRepo.php.

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

Referenced by cleanupDeletedBatch().

Here is the call graph for this function:

Here is the caller graph for this function:

Invalidates image redirect cache related to that image.

Parameters:
$titleTitle of page
Returns:
void

Reimplemented from FileRepo.

Definition at line 266 of file LocalRepo.php.

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

Here is the call graph for this function:

Exceptions:
MWException
Parameters:
$row
Returns:
File

Definition at line 29 of file LocalRepo.php.

Referenced by findBySha1().

Here is the caller graph for this function:

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

Definition at line 44 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 17 of file LocalRepo.php.

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

Reimplemented from FileRepo.

Definition at line 18 of file LocalRepo.php.

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

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 19 of file LocalRepo.php.

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

Reimplemented from FileRepo.

Definition at line 20 of file LocalRepo.php.

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

Reimplemented from FileRepo.

Definition at line 21 of file LocalRepo.php.

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

Definition at line 22 of file LocalRepo.php.


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