MediaWiki
1.23.2
|
A repository that stores files in the local filesystem and registers them in the wiki's own database. More...
Public Member Functions | |
checkRedirect (Title $title) | |
Checks if there is a redirect named as $title. More... | |
cleanupDeletedBatch (array $storageKeys) | |
Delete files in the deleted directory if they are not referenced in the filearchive table. More... | |
findBySha1 ( $hash) | |
Get an array or iterator of file objects for files that have a given SHA-1 content hash. More... | |
findBySha1s (array $hashes) | |
Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes. More... | |
findFiles (array $items, $flags=0) | |
Find many files at once. More... | |
findFilesByPrefix ( $prefix, $limit) | |
Return an array of files where the name starts with $prefix. More... | |
getInfo () | |
Return information about the repository. More... | |
getMasterDB () | |
Get a connection to the master DB. More... | |
getSharedCacheKey () | |
Get a key on the primary cache for this repository. More... | |
getSlaveDB () | |
Get a connection to the slave DB. More... | |
invalidateImageRedirect (Title $title) | |
Invalidates image redirect cache related to that image. More... | |
newFileFromRow ( $row) | |
newFromArchiveName ( $title, $archiveName) | |
Public Member Functions inherited from FileRepo | |
__construct (array $info=null) | |
canTransformVia404 () | |
Returns true if the repository can transform files via a 404 handler. More... | |
cleanDir ( $dir) | |
Deletes a directory if empty. More... | |
cleanupBatch (array $files, $flags=0) | |
Deletes a batch of files. More... | |
concatenate (array $srcPaths, $dstPath, $flags=0) | |
Concatenate a list of temporary files into a target file location. More... | |
delete ( $srcRel, $archiveRel) | |
Move a file to the deletion archive. More... | |
deleteBatch (array $sourceDestPairs) | |
Move a group of files to the deletion archive. More... | |
enumFiles ( $callback) | |
Call a callback function for every public regular file in the repository. More... | |
fileExists ( $file) | |
Checks existence of a a file. More... | |
fileExistsBatch (array $files) | |
Checks existence of an array of files. More... | |
findFile ( $title, $options=array()) | |
Find an instance of the named file created at the specified time Returns false if the file does not exist. More... | |
findFileFromKey ( $sha1, $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... | |
freeTemp ( $virtualUrl) | |
Remove a temporary file or mark it for garbage collection. More... | |
getBackend () | |
Get the file backend instance. More... | |
getDeletedHashPath ( $key) | |
Get a relative path for a deletion archive key, e.g. More... | |
getDescriptionRenderUrl ( $name, $lang=null) | |
Get the URL of the content-only fragment of the description page. More... | |
getDescriptionStylesheetUrl () | |
Get the URL of the stylesheet to apply to description pages. More... | |
getDescriptionUrl ( $name) | |
Get the URL of an image description page. More... | |
getDisplayName () | |
Get the human-readable name of the repo. More... | |
getErrorCleanupFunction () | |
Get a callback function to use for cleaning error message parameters. More... | |
getFileProps ( $virtualUrl) | |
Get properties of a file with a given virtual URL/storage path. More... | |
getFileSha1 ( $virtualUrl) | |
Get the sha1 (base 36) of a file with a given virtual URL/storage path. More... | |
getFileSize ( $virtualUrl) | |
Get the size of a file with a given virtual URL/storage path. More... | |
getFileTimestamp ( $virtualUrl) | |
Get the timestamp of a file with a given virtual URL/storage path. More... | |
getHashLevels () | |
Get the number of hash directory levels. More... | |
getHashPath ( $name) | |
Get a relative path including trailing slash, e.g. More... | |
getLocalCacheKey () | |
Get a key for this repo in the local cache domain. More... | |
getLocalCopy ( $virtualUrl) | |
Get a local FS copy of a file with a given virtual URL/storage path. More... | |
getLocalReference ( $virtualUrl) | |
Get a local FS file with a given virtual URL/storage path. More... | |
getName () | |
Get the name of this repository, as specified by $info['name]' to the constructor. More... | |
getNameFromTitle (Title $title) | |
Get the name of a file from its title object. More... | |
getReadOnlyReason () | |
Get an explanatory message if this repo is read-only. More... | |
getRootDirectory () | |
Get the public zone root storage directory of the repository. More... | |
getRootUrl () | |
Get the public root URL of the repository. More... | |
getTempHashPath ( $suffix) | |
Get a relative path including trailing slash, e.g. More... | |
getTempRepo () | |
Get an temporary FileRepo associated with this repo. More... | |
getThumbScriptUrl () | |
Get the URL of thumb.php. More... | |
getUploadStash (User $user=null) | |
Get an UploadStash associated with this repo. More... | |
getVirtualUrl ( $suffix=false) | |
Get a URL referring to this repository, with the private mwrepo protocol. More... | |
getZoneHandlerUrl ( $zone) | |
Get the thumb zone URL configured to be handled by scripts like thumb_handler.php. More... | |
getZonePath ( $zone) | |
Get the storage path corresponding to one of the zones. More... | |
getZoneUrl ( $zone, $ext=null) | |
Get the URL corresponding to one of the four basic zones. More... | |
isLocal () | |
Returns true if this the local file repository. More... | |
makeUrl ( $query='', $entry='index') | |
Make an url to this repo. More... | |
nameForThumb ( $name) | |
Get the portion of the file that contains the origin file name. More... | |
newFatal ( $message) | |
Create a new fatal error. More... | |
newFile ( $title, $time=false) | |
Create a new File object from the local repository. More... | |
newGood ( $value=null) | |
Create a new good result. More... | |
paranoidClean ( $param) | |
Path disclosure protection function. More... | |
passThrough ( $param) | |
Path disclosure protection function. More... | |
publish ( $srcPath, $dstRel, $archiveRel, $flags=0, array $options=array()) | |
Copy or move a file either from a storage path, virtual URL, or file system path, into this repository at the specified destination location. More... | |
publishBatch (array $ntuples, $flags=0) | |
Publish a batch of files. More... | |
quickCleanDir ( $dir) | |
Deletes a directory if empty. More... | |
quickImport ( $src, $dst, $options=null) | |
Import a file from the local file system into the repo. More... | |
quickImportBatch (array $triples) | |
Import a batch of files from the local file system into the repo. More... | |
quickPurge ( $path) | |
Purge a file from the repo. More... | |
quickPurgeBatch (array $paths) | |
Purge a batch of files from the repo. More... | |
resolveVirtualUrl ( $url) | |
Get the backend storage path corresponding to a virtual URL. More... | |
store ( $srcPath, $dstZone, $dstRel, $flags=0) | |
Store a file to a given destination. More... | |
storeBatch (array $triplets, $flags=0) | |
Store a batch of files. More... | |
storeTemp ( $originalName, $srcPath) | |
Pick a random name in the temp zone and store a file to it. More... | |
streamFile ( $virtualUrl, $headers=array()) | |
Attempt to stream a file with the given virtual URL/storage path. More... | |
validateFilename ( $filename) | |
Determine if a relative path is valid, i.e. More... | |
Static Public Member Functions | |
static | getHashFromKey ( $key) |
Gets the SHA1 hash from a storage key. More... | |
Static Public Member Functions inherited from FileRepo | |
static | isVirtualUrl ( $url) |
Determine if a string is an mwrepo:// URL. More... | |
Protected Member Functions | |
deletedFileHasKey ( $key, $lock=null) | |
Check if a deleted (filearchive) file has this sha1 key. More... | |
getArticleID ( $title) | |
Function link Title::getArticleID(). More... | |
hiddenFileHasKey ( $key, $lock=null) | |
Check if a hidden (revision delete) file has this sha1 key. More... | |
Protected Member Functions inherited from FileRepo | |
assertWritableRepo () | |
Throw an exception if this repo is read-only by design. More... | |
enumFilesInStorage ( $callback) | |
Call a callback function for every public file in the repository. More... | |
getZoneLocation ( $zone) | |
The the storage container and base path of a zone. More... | |
initDirectory ( $dir) | |
Creates a directory with the appropriate zone permissions. More... | |
initZones ( $doZones=array()) | |
Check if a single zone or list of zones is defined for usage. More... | |
resolveToStoragePath ( $path) | |
If a path is a virtual URL, resolve it to a storage path. More... | |
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' ) |
Protected Attributes inherited from FileRepo | |
int | $abbrvThreshold |
File names over this size will use the short form of thumbnail names. More... | |
$articleUrl | |
FileBackend | $backend |
int | $deletedHashLevels |
The number of directory levels for hash-based division of deleted files *. More... | |
$descBaseUrl | |
string | $favicon |
The URL of the repo's favicon, if any *. More... | |
$fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' ) | |
Factory functions for creating new files Override these in the base class. More... | |
$fileFactoryKey = false | |
int | $hashLevels |
The number of directory levels for hash-based division of files *. More... | |
bool | $initialCapital |
Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter. More... | |
$oldFileFactory = false | |
$oldFileFactoryKey = false | |
string | $pathDisclosureProtection = 'simple' |
May be 'paranoid' to remove all parameters from error messages, 'none' to leave the paths in unchanged, or 'simple' to replace paths with placeholders. More... | |
$scriptDirUrl | |
string | $scriptExtension |
Script extension of the MediaWiki installation, equivalent to $wgScriptExtension, e.g. More... | |
string | $thumbScriptUrl |
URL of thumb.php *. More... | |
$thumbUrl | |
bool | $transformVia404 |
Whether to skip media file transformation on parse and rely on a 404 handler instead. More... | |
bool | $url |
Public zone URL. More... | |
Array | $zones = array() |
Map of zones to config *. More... | |
Additional Inherited Members | |
Public Attributes inherited from FileRepo | |
int | $descriptionCacheExpiry |
bool | $fetchDescription |
Whether to fetch commons image description pages and display them on the local wiki *. More... | |
const | DELETE_SOURCE = 1 |
const | NAME_AND_TIME_ONLY = 1 |
const | OVERWRITE = 2 |
const | OVERWRITE_SAME = 4 |
const | SKIP_LOCKING = 8 |
Static Protected Member Functions inherited from FileRepo | |
static | getHashPathForLevel ( $name, $levels) |
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.
LocalRepo::checkRedirect | ( | Title | $title | ) |
Checks if there is a redirect named as $title.
Reimplemented from FileRepo.
Definition at line 166 of file LocalRepo.php.
References $dbr, $title, $wgMemc, array(), getArticleID(), FileRepo\getLocalCacheKey(), getSharedCacheKey(), getSlaveDB(), global, Title\makeTitle(), Title\newFromText(), File\normalizeTitle(), and NS_FILE.
Referenced by findFiles().
LocalRepo::cleanupDeletedBatch | ( | array | $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.
array | $storageKeys |
Reimplemented from FileRepo.
Definition at line 78 of file LocalRepo.php.
References FileRepo\$backend, $path, array(), as, deletedFileHasKey(), FileBackend\doOperation(), FileRepo\getDeletedHashPath(), getMasterDB(), FileRepo\getZonePath(), hiddenFileHasKey(), FileRepo\newGood(), and wfDebug().
|
protected |
Check if a deleted (filearchive) file has this sha1 key.
string | $key | File storage key (base-36 sha1 key with file extension) |
string | null | $lock | Use "lock" to lock the row via FOR UPDATE |
Definition at line 116 of file LocalRepo.php.
References $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.
string | $hash | a sha1 hash to look for |
Reimplemented from FileRepo.
Definition at line 369 of file LocalRepo.php.
References $dbr, $hash, $res, array(), as, getSlaveDB(), newFileFromRow(), and LocalFile\selectFields().
LocalRepo::findBySha1s | ( | array | $hashes | ) |
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
array | $hashes | An array of hashes |
Reimplemented from FileRepo.
Definition at line 397 of file LocalRepo.php.
References $dbr, $file, $hashes, $res, array(), as, getSlaveDB(), newFileFromRow(), and LocalFile\selectFields().
LocalRepo::findFiles | ( | array | $items, |
$flags = 0 |
|||
) |
Find many files at once.
array | $items | An 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
int | $flags | Supports:
|
Reimplemented from FileRepo.
Definition at line 237 of file LocalRepo.php.
References $dbr, $file, $flags, $res, $title, $user, $wgContLang, array(), as, checkRedirect(), File\DELETED_FILE, FileRepo\getNameFromTitle(), getSlaveDB(), global, LIST_AND, LIST_OR, FileRepo\NAME_AND_TIME_ONLY, FileRepo\newFile(), File\normalizeTitle(), NS_FILE, OldLocalFile\selectFields(), LocalFile\selectFields(), and User.
LocalRepo::findFilesByPrefix | ( | $prefix, | |
$limit | |||
) |
Return an array of files where the name starts with $prefix.
string | $prefix | The prefix to search for |
int | $limit | The maximum amount of files to return |
Reimplemented from FileRepo.
Definition at line 428 of file LocalRepo.php.
References $dbr, $files, $limit, $res, array(), as, getSlaveDB(), newFileFromRow(), and LocalFile\selectFields().
|
protected |
Function link Title::getArticleID().
We can't say Title object, what database it should use, so we duplicate that function here.
Title | $title |
Definition at line 219 of file LocalRepo.php.
References $dbr, $title, array(), and getSlaveDB().
Referenced by checkRedirect().
|
static |
Gets the SHA1 hash from a storage key.
string | $key |
Definition at line 156 of file LocalRepo.php.
Referenced by PopulateFilearchiveSha1\doDBUpdates(), DeleteArchivedFilesImplementation\doDelete(), LocalFileRestoreBatch\execute(), hiddenFileHasKey(), and ArchivedFile\loadFromRow().
LocalRepo::getInfo | ( | ) |
Return information about the repository.
Reimplemented from FileRepo.
Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.
Definition at line 503 of file LocalRepo.php.
References array(), global, and wfExpandUrl().
LocalRepo::getMasterDB | ( | ) |
Get a connection to the master DB.
Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.
Definition at line 462 of file LocalRepo.php.
References DB_MASTER, and wfGetDB().
Referenced by cleanupDeletedBatch(), deletedFileHasKey(), and hiddenFileHasKey().
LocalRepo::getSharedCacheKey | ( | ) |
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().
Reimplemented from FileRepo.
Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.
Definition at line 473 of file LocalRepo.php.
References $args.
Referenced by checkRedirect(), and invalidateImageRedirect().
LocalRepo::getSlaveDB | ( | ) |
Get a connection to the slave DB.
Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.
Definition at line 454 of file LocalRepo.php.
References DB_SLAVE, and wfGetDB().
Referenced by checkRedirect(), findBySha1(), findBySha1s(), findFiles(), findFilesByPrefix(), getArticleID(), and PurgeChangedFiles\purgeFromArchiveTable().
|
protected |
Check if a hidden (revision delete) file has this sha1 key.
string | $key | File storage key (base-36 sha1 key with file extension) |
string | null | $lock | Use "lock" to lock the row via FOR UPDATE |
Definition at line 134 of file LocalRepo.php.
References $ext, $options, array(), File\DELETED_FILE, getHashFromKey(), getMasterDB(), and File\normalizeExtension().
Referenced by cleanupDeletedBatch().
LocalRepo::invalidateImageRedirect | ( | Title | $title | ) |
Invalidates image redirect cache related to that image.
Reimplemented from FileRepo.
Definition at line 485 of file LocalRepo.php.
References $title, $wgMemc, getSharedCacheKey(), and global.
LocalRepo::newFileFromRow | ( | $row | ) |
MWException |
array | $row |
Definition at line 49 of file LocalRepo.php.
Referenced by findBySha1(), findBySha1s(), and findFilesByPrefix().
LocalRepo::newFromArchiveName | ( | $title, | |
$archiveName | |||
) |
Title | $title | |
string | $archiveName |
Definition at line 64 of file LocalRepo.php.
References $title, and OldLocalFile\newFromArchiveName().
Referenced by PurgeChangedFiles\purgeFromArchiveTable().
Definition at line 32 of file LocalRepo.php.
Definition at line 34 of file LocalRepo.php.
Definition at line 36 of file LocalRepo.php.
|
protected |
Definition at line 40 of file LocalRepo.php.
|
protected |
Definition at line 42 of file LocalRepo.php.
|
protected |
Definition at line 38 of file LocalRepo.php.