MediaWiki  REL1_24
FileRepo Class Reference

Base class for file repositories. More...

Inheritance diagram for FileRepo:
Collaboration diagram for FileRepo:

List of all members.

Public Member Functions

 __construct (array $info=null)
 backendSupportsUnicodePaths ()
 canTransformVia404 ()
 Returns true if the repository can transform files via a 404 handler.
 checkRedirect (Title $title)
 Checks if there is a redirect named as $title.
 cleanDir ($dir)
 Deletes a directory if empty.
 cleanupBatch (array $files, $flags=0)
 Deletes a batch of files.
 cleanupDeletedBatch (array $storageKeys)
 Delete files in the deleted directory if they are not referenced in the filearchive table.
 concatenate (array $srcPaths, $dstPath, $flags=0)
 Concatenate a list of temporary files into a target file location.
 delete ($srcRel, $archiveRel)
 Move a file to the deletion archive.
 deleteBatch (array $sourceDestPairs)
 Move a group of files to the deletion archive.
 enumFiles ($callback)
 Call a callback function for every public regular file in the repository.
 fileExists ($file)
 Checks existence of a a file.
 fileExistsBatch (array $files)
 Checks existence of an array of files.
 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.
 findFile ($title, $options=array())
 Find an instance of the named file created at the specified time Returns false if the file does not exist.
 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.
 findFiles (array $items, $flags=0)
 Find many files at once.
 findFilesByPrefix ($prefix, $limit)
 Return an array of files where the name starts with $prefix.
 freeTemp ($virtualUrl)
 Remove a temporary file or mark it for garbage collection.
 getBackend ()
 Get the file backend instance.
 getDeletedHashPath ($key)
 Get a relative path for a deletion archive key, e.g.
 getDescriptionRenderUrl ($name, $lang=null)
 Get the URL of the content-only fragment of the description page.
 getDescriptionStylesheetUrl ()
 Get the URL of the stylesheet to apply to description pages.
 getDescriptionUrl ($name)
 Get the URL of an image description page.
 getDisplayName ()
 Get the human-readable name of the repo.
 getErrorCleanupFunction ()
 Get a callback function to use for cleaning error message parameters.
 getFileProps ($virtualUrl)
 Get properties of a file with a given virtual URL/storage path.
 getFileSha1 ($virtualUrl)
 Get the sha1 (base 36) of a file with a given virtual URL/storage path.
 getFileSize ($virtualUrl)
 Get the size of a file with a given virtual URL/storage path.
 getFileTimestamp ($virtualUrl)
 Get the timestamp of a file with a given virtual URL/storage path.
 getHashLevels ()
 Get the number of hash directory levels.
 getHashPath ($name)
 Get a relative path including trailing slash, e.g.
 getInfo ()
 Return information about the repository.
 getLocalCacheKey ()
 Get a key for this repo in the local cache domain.
 getLocalCopy ($virtualUrl)
 Get a local FS copy of a file with a given virtual URL/storage path.
 getLocalReference ($virtualUrl)
 Get a local FS file with a given virtual URL/storage path.
 getName ()
 Get the name of this repository, as specified by $info['name]' to the constructor.
 getNameFromTitle (Title $title)
 Get the name of a file from its title object.
 getReadOnlyReason ()
 Get an explanatory message if this repo is read-only.
 getRootDirectory ()
 Get the public zone root storage directory of the repository.
 getRootUrl ()
 Get the public root URL of the repository.
 getSharedCacheKey ()
 Get a key on the primary cache for this repository.
 getTempHashPath ($suffix)
 Get a relative path including trailing slash, e.g.
 getTempRepo ()
 Get an temporary FileRepo associated with this repo.
 getThumbScriptUrl ()
 Get the URL of thumb.php.
 getUploadStash (User $user=null)
 Get an UploadStash associated with this repo.
 getVirtualUrl ($suffix=false)
 Get a URL referring to this repository, with the private mwrepo protocol.
 getZonePath ($zone)
 Get the storage path corresponding to one of the zones.
 getZoneUrl ($zone, $ext=null)
 Get the URL corresponding to one of the four basic zones.
 invalidateImageRedirect (Title $title)
 Invalidates image redirect cache related to that image Doesn't do anything for repositories that don't support image redirects.
 isLocal ()
 Returns true if this the local file repository.
 makeUrl ($query= '', $entry= 'index')
 Make an url to this repo.
 nameForThumb ($name)
 Get the portion of the file that contains the origin file name.
 newFatal ($message)
 Create a new fatal error.
 newFile ($title, $time=false)
 Create a new File object from the local repository.
 newGood ($value=null)
 Create a new good result.
 paranoidClean ($param)
 Path disclosure protection function.
 passThrough ($param)
 Path disclosure protection function.
 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.
 publishBatch (array $ntuples, $flags=0)
 Publish a batch of files.
 quickCleanDir ($dir)
 Deletes a directory if empty.
 quickImport ($src, $dst, $options=null)
 Import a file from the local file system into the repo.
 quickImportBatch (array $triples)
 Import a batch of files from the local file system into the repo.
 quickPurge ($path)
 Purge a file from the repo.
 quickPurgeBatch (array $paths)
 Purge a batch of files from the repo.
 resolveVirtualUrl ($url)
 Get the backend storage path corresponding to a virtual URL.
 store ($srcPath, $dstZone, $dstRel, $flags=0)
 Store a file to a given destination.
 storeBatch (array $triplets, $flags=0)
 Store a batch of files.
 storeTemp ($originalName, $srcPath)
 Pick a random name in the temp zone and store a file to it.
 streamFile ($virtualUrl, $headers=array())
 Attempt to stream a file with the given virtual URL/storage path.
 validateFilename ($filename)
 Determine if a relative path is valid, i.e.

Static Public Member Functions

static isVirtualUrl ($url)
 Determine if a string is an mwrepo:// URL.

Public Attributes

int $descriptionCacheExpiry
 *
bool $fetchDescription
 Whether to fetch commons image description pages and display them on the local wiki *.
const DELETE_SOURCE = 1
const NAME_AND_TIME_ONLY = 1
const OVERWRITE = 2
const OVERWRITE_SAME = 4
const SKIP_LOCKING = 8

Protected Member Functions

 assertWritableRepo ()
 Throw an exception if this repo is read-only by design.
 enumFilesInStorage ($callback)
 Call a callback function for every public file in the repository.
 getZoneLocation ($zone)
 The the storage container and base path of a zone.
 initDirectory ($dir)
 Creates a directory with the appropriate zone permissions.
 initZones ($doZones=array())
 Check if a single zone or list of zones is defined for usage.
 resolveToStoragePath ($path)
 If a path is a virtual URL, resolve it to a storage path.

Static Protected Member Functions

static getHashPathForLevel ($name, $levels)

Protected Attributes

int $abbrvThreshold
 File names over this size will use the short form of thumbnail names.
 $articleUrl
FileBackend $backend
 *
int $deletedHashLevels
 The number of directory levels for hash-based division of deleted files *.
 $descBaseUrl
string $favicon
 The URL of the repo's favicon, if any *.
 $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' )
 Factory functions for creating new files Override these in the base class.
 $fileFactoryKey = false
int $hashLevels
 The number of directory levels for hash-based division of files *.
bool $initialCapital
 Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter.
 $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.
 $scriptDirUrl
string $scriptExtension
 Script extension of the MediaWiki installation, equivalent to $wgScriptExtension, e.g.
string $thumbScriptUrl
 URL of thumb.php *.
 $thumbUrl
bool $transformVia404
 Whether to skip media file transformation on parse and rely on a 404 handler instead.
bool $url
 Public zone URL.
array $zones = array()
 Map of zones to config *.

Detailed Description

Base class for file repositories.

Definition at line 37 of file FileRepo.php.


Constructor & Destructor Documentation

FileRepo::__construct ( array info = null)
Parameters:
array | null$info
Exceptions:
MWException

Reimplemented in FSRepo.

Definition at line 116 of file FileRepo.php.


Member Function Documentation

Throw an exception if this repo is read-only by design.

This does not and should not check getReadOnlyReason().

Returns:
void
Exceptions:
MWException

Reimplemented in ForeignAPIRepo, ForeignDBRepo, ForeignDBViaLBRepo, and NullRepo.

Definition at line 1827 of file FileRepo.php.

Referenced by storeBatch().

Returns:
bool Whether non-ASCII path characters are allowed

Definition at line 287 of file FileRepo.php.

Returns true if the repository can transform files via a 404 handler.

Returns:
bool

Definition at line 596 of file FileRepo.php.

Checks if there is a redirect named as $title.

If there is, return the title object. If not, return false. STUB

Parameters:
Title$titleTitle of image
Returns:
bool

Reimplemented in LocalRepo.

Definition at line 1692 of file FileRepo.php.

FileRepo::cleanDir ( dir)

Deletes a directory if empty.

Parameters:
string$dirVirtual URL (or storage path) of directory to clean
Returns:
Status

Definition at line 1309 of file FileRepo.php.

FileRepo::cleanupBatch ( array files,
flags = 0 
)

Deletes a batch of files.

Each file can be a (zone, rel) pair, virtual url, storage path. It will try to delete each file, but ignores any errors that may occur.

Parameters:
array$filesList of files to delete
int$flagsBitwise combination of the following flags: self::SKIP_LOCKING Skip any file locking when doing the deletions
Returns:
FileRepoStatus

Definition at line 904 of file FileRepo.php.

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

STUB

Parameters:
array$storageKeys

Reimplemented in LocalRepo.

Definition at line 1442 of file FileRepo.php.

FileRepo::concatenate ( array srcPaths,
dstPath,
flags = 0 
)

Concatenate a list of temporary files into a target file location.

Parameters:
array$srcPathsOrdered list of source virtual URLs/storage paths
string$dstPathTarget file system path
int$flagsBitwise combination of the following flags: self::DELETE_SOURCE Delete the source files
Returns:
FileRepoStatus

Definition at line 1092 of file FileRepo.php.

FileRepo::delete ( srcRel,
archiveRel 
)

Move a file to the deletion archive.

If no valid deletion archive exists, this may either delete the file or throw an exception, depending on the preference of the repository

Parameters:
mixed$srcRelRelative path for the file to be deleted
mixed$archiveRelRelative path for the archive location. Relative to a private archive directory.
Returns:
FileRepoStatus

Definition at line 1360 of file FileRepo.php.

FileRepo::deleteBatch ( array sourceDestPairs)

Move a group of files to the deletion archive.

If no valid deletion archive is configured, this may either delete the file or throw an exception, depending on the preference of the repository.

The overwrite policy is determined by the repository -- currently LocalRepo assumes a naming scheme in the deleted zone based on content hash, as opposed to the public zone which is assumed to be unique.

Parameters:
array$sourceDestPairsArray of source/destination pairs. Each element is a two-element array containing the source file path relative to the public root in the first element, and the archive file path relative to the deleted zone root in the second element.
Exceptions:
MWException
Returns:
FileRepoStatus

Definition at line 1383 of file FileRepo.php.

FileRepo::enumFiles ( callback)

Call a callback function for every public regular file in the repository.

This only acts on the current version of files, not any old versions. May use either the database or the filesystem.

Parameters:
callable$callback
Returns:
void

Reimplemented in ForeignAPIRepo.

Definition at line 1580 of file FileRepo.php.

FileRepo::enumFilesInStorage ( callback) [protected]

Call a callback function for every public file in the repository.

May use either the database or the filesystem.

Parameters:
callable$callback
Returns:
void

Definition at line 1591 of file FileRepo.php.

FileRepo::fileExists ( file)

Checks existence of a a file.

Parameters:
string$fileVirtual URL (or storage path) of file to check
Returns:
bool

Definition at line 1325 of file FileRepo.php.

Checks existence of an array of files.

Parameters:
array$filesVirtual URLs (or storage paths) of files to check
Returns:
array Map of files and existence flags, or false

Reimplemented in ForeignAPIRepo.

Definition at line 1337 of file FileRepo.php.

FileRepo::findBySha1 ( hash)

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

STUB

Parameters:
string$hashSHA-1 hash
Returns:
File[]

Reimplemented in LocalRepo, and ForeignAPIRepo.

Definition at line 537 of file FileRepo.php.

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

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

Reimplemented in LocalRepo.

Definition at line 548 of file FileRepo.php.

FileRepo::findFile ( title,
options = array() 
)

Find an instance of the named file created at the specified time Returns false if the file does not exist.

Repositories not supporting version control should return false if the time is specified.

Parameters:
Title | string$titleTitle object or string
array$optionsAssociative array of options: time: requested time for a specific file version, or false for the current version. An image object will be returned which was created at the specified time (which may be archived or current). 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. If a User object, use that user instead of the current.
Returns:
File|bool False on failure

Definition at line 395 of file FileRepo.php.

FileRepo::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.

Repositories not supporting version control should return false if the time is specified.

Parameters:
string$sha1Base 36 SHA-1 hash
array$optionsOption array, same as findFile().
Returns:
File|bool False on failure

Definition at line 499 of file FileRepo.php.

FileRepo::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 in LocalRepo.

Definition at line 462 of file FileRepo.php.

FileRepo::findFilesByPrefix ( prefix,
limit 
)

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

STUB

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

Reimplemented in LocalRepo.

Definition at line 568 of file FileRepo.php.

FileRepo::freeTemp ( virtualUrl)

Remove a temporary file or mark it for garbage collection.

Parameters:
string$virtualUrlThe virtual URL returned by FileRepo::storeTemp()
Returns:
bool True on success, false on failure

Definition at line 1070 of file FileRepo.php.

Get the file backend instance.

Use this function wisely.

Returns:
FileBackend

Definition at line 190 of file FileRepo.php.

Referenced by UploadStashCleanup\doOperations().

Get a relative path for a deletion archive key, e.g.

s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg

Parameters:
string$key
Exceptions:
MWException
Returns:
string

Definition at line 1454 of file FileRepo.php.

FileRepo::getDescriptionRenderUrl ( name,
lang = null 
)

Get the URL of the content-only fragment of the description page.

For MediaWiki this means action=render. This should only be called by the repository's file class, since it may return invalid results. User code should use File::getDescriptionText().

Parameters:
string$nameName of image to fetch
string$langLanguage to fetch it in, if any.
Returns:
string

Definition at line 755 of file FileRepo.php.

Get the URL of the stylesheet to apply to description pages.

Returns:
string|bool False on failure

Definition at line 780 of file FileRepo.php.

Get the URL of an image description page.

May return false if it is unknown or not applicable. In general this should only be called by the File class, since it may return invalid results for certain kinds of repositories. Use File::getDescriptionUrl() in user code.

In particular, it uses the article paths as specified to the repository constructor, whereas local repositories use the local Title functions.

Parameters:
string$name
Returns:
string

Definition at line 719 of file FileRepo.php.

Get the human-readable name of the repo.

Returns:
string

Definition at line 1711 of file FileRepo.php.

Referenced by ImagePage\printSharedImageText().

Get a callback function to use for cleaning error message parameters.

Returns:
array

Definition at line 1629 of file FileRepo.php.

FileRepo::getFileProps ( virtualUrl)

Get properties of a file with a given virtual URL/storage path.

Properties should ultimately be obtained via FSFile::getProps().

Parameters:
string$virtualUrl
Returns:
array

Reimplemented in ForeignAPIRepo.

Definition at line 1516 of file FileRepo.php.

FileRepo::getFileSha1 ( virtualUrl)

Get the sha1 (base 36) of a file with a given virtual URL/storage path.

Parameters:
string$virtualUrl
Returns:
string|bool

Definition at line 1552 of file FileRepo.php.

FileRepo::getFileSize ( virtualUrl)

Get the size of a file with a given virtual URL/storage path.

Parameters:
string$virtualUrl
Returns:
int|bool False on failure

Definition at line 1540 of file FileRepo.php.

FileRepo::getFileTimestamp ( virtualUrl)

Get the timestamp of a file with a given virtual URL/storage path.

Parameters:
string$virtualUrl
Returns:
string|bool False on failure

Definition at line 1528 of file FileRepo.php.

Get the number of hash directory levels.

Returns:
int

Definition at line 677 of file FileRepo.php.

References $path.

FileRepo::getHashPath ( name)

Get a relative path including trailing slash, e.g.

f/fa/ If the repo is not hashed, returns an empty string

Parameters:
string$nameName of file
Returns:
string

Definition at line 636 of file FileRepo.php.

static FileRepo::getHashPathForLevel ( name,
levels 
) [static, protected]
Parameters:
string$name
int$levels
Returns:
string

Definition at line 658 of file FileRepo.php.

Return information about the repository.

Returns:
array
Since:
1.22

Reimplemented in LocalRepo, ForeignAPIRepo, ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 1836 of file FileRepo.php.

Get a key for this repo in the local cache domain.

These cache keys are not shared with remote instances of the repo. The parameters are the parts of the key, as for wfMemcKey().

Returns:
string

Definition at line 1766 of file FileRepo.php.

FileRepo::getLocalCopy ( virtualUrl)

Get a local FS copy of a file with a given virtual URL/storage path.

Temporary files may be purged when the file object falls out of scope.

Parameters:
string$virtualUrl
Returns:
TempFSFile|null Returns null on failure

Definition at line 1489 of file FileRepo.php.

References resolveVirtualUrl().

FileRepo::getLocalReference ( virtualUrl)

Get a local FS file with a given virtual URL/storage path.

The file is either an original or a copy. It should not be changed. Temporary files may be purged when the file object falls out of scope.

Parameters:
string$virtualUrl
Returns:
FSFile|null Returns null on failure.

Definition at line 1503 of file FileRepo.php.

References array(), and resolveToStoragePath().

Get the name of this repository, as specified by $info['name]' to the constructor.

Returns:
string

Definition at line 686 of file FileRepo.php.

Get the name of a file from its title object.

Parameters:
Title$title
Returns:
string

Definition at line 606 of file FileRepo.php.

Get an explanatory message if this repo is read-only.

This checks if an administrator disabled writes to the backend.

Returns:
string|bool Returns false if the repo is not read-only

Definition at line 200 of file FileRepo.php.

Get the public zone root storage directory of the repository.

Returns:
string

Definition at line 625 of file FileRepo.php.

Get the public root URL of the repository.

Deprecated:
since 1.20
Returns:
string

Definition at line 578 of file FileRepo.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().

STUB

Returns:
bool

Reimplemented in LocalRepo, ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 1755 of file FileRepo.php.

Get a relative path including trailing slash, e.g.

f/fa/ If the repo is not hashed, returns an empty string

Parameters:
string$suffixBasename of file from FileRepo::storeTemp()
Returns:
string

Definition at line 647 of file FileRepo.php.

Get an temporary FileRepo associated with this repo.

Files will be created in the temp zone of this repo and thumbnails in a /temp subdirectory in thumb zone of this repo. It will have the same backend as this repo.

Returns:
TempFileRepo

Reimplemented in TempFileRepo.

Definition at line 1781 of file FileRepo.php.

Get the URL of thumb.php.

Returns:
string

Definition at line 587 of file FileRepo.php.

FileRepo::getUploadStash ( User user = null)

Get an UploadStash associated with this repo.

Parameters:
User$user
Returns:
UploadStash

Definition at line 1816 of file FileRepo.php.

FileRepo::getVirtualUrl ( suffix = false)

Get a URL referring to this repository, with the private mwrepo protocol.

The suffix, if supplied, is considered to be unencoded, and will be URL-encoded before being returned.

Parameters:
string | bool$suffix
Returns:
string

Definition at line 241 of file FileRepo.php.

FileRepo::getZoneLocation ( zone) [protected]

The the storage container and base path of a zone.

Parameters:
string$zone
Returns:
array (container, base path) or (null, null)

Definition at line 325 of file FileRepo.php.

FileRepo::getZonePath ( zone)

Get the storage path corresponding to one of the zones.

Parameters:
string$zone
Returns:
string|null Returns null if the zone is not defined

Reimplemented in ForeignAPIRepo.

Definition at line 339 of file FileRepo.php.

References array().

Referenced by storeBatch().

FileRepo::getZoneUrl ( zone,
ext = null 
)

Get the URL corresponding to one of the four basic zones.

Parameters:
string$zoneOne of: public, deleted, temp, thumb
string | null$extOptional file extension
Returns:
string|bool

Reimplemented in ForeignAPIRepo.

Definition at line 257 of file FileRepo.php.

References $path.

FileRepo::initDirectory ( dir) [protected]

Creates a directory with the appropriate zone permissions.

Callers are responsible for doing read-only and "writable repo" checks.

Parameters:
string$dirVirtual URL (or storage path) of directory to clean
Returns:
Status

Definition at line 1289 of file FileRepo.php.

Referenced by storeBatch().

FileRepo::initZones ( doZones = array()) [protected]

Check if a single zone or list of zones is defined for usage.

Parameters:
array$doZonesOnly do a particular zones
Exceptions:
MWException
Returns:
Status

Definition at line 211 of file FileRepo.php.

Invalidates image redirect cache related to that image Doesn't do anything for repositories that don't support image redirects.

STUB

Parameters:
Title$titleTitle of image

Reimplemented in LocalRepo.

Definition at line 1703 of file FileRepo.php.

Returns true if this the local file repository.

Returns:
bool

Definition at line 1743 of file FileRepo.php.

References $name, and FileBackend\extensionFromPath().

static FileRepo::isVirtualUrl ( url) [static]

Determine if a string is an mwrepo:// URL.

Parameters:
string$url
Returns:
bool

Definition at line 229 of file FileRepo.php.

FileRepo::makeUrl ( query = '',
entry = 'index' 
)

Make an url to this repo.

Parameters:
string$queryQuery string to append
string$entryEntry point; defaults to index
Returns:
string|bool False on failure

Definition at line 697 of file FileRepo.php.

Get the portion of the file that contains the origin file name.

If that name is too long, then the name "thumbnail.<ext>" will be given.

Parameters:
string$name
Returns:
string

Definition at line 1729 of file FileRepo.php.

FileRepo::newFatal ( message)

Create a new fatal error.

Parameters:
string$message
Returns:
FileRepoStatus

Definition at line 1667 of file FileRepo.php.

Referenced by storeBatch().

FileRepo::newFile ( title,
time = false 
)

Create a new File object from the local repository.

Parameters:
Title | string$titleTitle object or string
bool | string$timeTime at which the image was uploaded. If this is specified, the returned object will be an instance of the repository's old file class instead of a current file. Repositories not supporting version control should return false if this parameter is set.
Returns:
File|null A File, or null if passed an invalid Title

Reimplemented in ForeignAPIRepo.

Definition at line 363 of file FileRepo.php.

FileRepo::newGood ( value = null)

Create a new good result.

Parameters:
null | string$value
Returns:
FileRepoStatus

Definition at line 1680 of file FileRepo.php.

Referenced by storeBatch().

Path disclosure protection function.

Parameters:
string$param
Returns:
string

Definition at line 1647 of file FileRepo.php.

FileRepo::passThrough ( param)

Path disclosure protection function.

Parameters:
string$param
Returns:
string

Definition at line 1657 of file FileRepo.php.

FileRepo::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.

Returns a FileRepoStatus object. On success, the value contains "new" or "archived", to indicate whether the file was new with that name.

Options to $options include:

  • headers : name/value map of HTTP headers to use in response to GET/HEAD requests
Parameters:
string$srcPathThe source file system path, storage path, or URL
string$dstRelThe destination relative path
string$archiveRelThe relative path where the existing file is to be archived, if there is one. Relative to the public zone root.
int$flagsBitfield, may be FileRepo::DELETE_SOURCE to indicate that the source file should be deleted if possible
array$optionsOptional additional parameters
Returns:
FileRepoStatus

Definition at line 1141 of file FileRepo.php.

FileRepo::publishBatch ( array ntuples,
flags = 0 
)

Publish a batch of files.

Parameters:
array$ntuples(source, dest, archive) triplets or (source, dest, archive, options) 4-tuples as per publish().
int$flagsBitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible
Exceptions:
MWException
Returns:
FileRepoStatus

Definition at line 1170 of file FileRepo.php.

Deletes a directory if empty.

This function can be used to write to otherwise read-only foreign repos.

Parameters:
string$dirVirtual URL (or storage path) of directory to clean
Returns:
Status

Definition at line 967 of file FileRepo.php.

FileRepo::quickImport ( src,
dst,
options = null 
) [final]

Import a file from the local file system into the repo.

This does no locking nor journaling and overrides existing files. This function can be used to write to otherwise read-only foreign repos. This is intended for copying generated thumbnails into the repo.

Parameters:
string$srcSource file system path, storage path, or virtual URL
string$dstVirtual URL or storage path
array | string | null$optionsAn array consisting of a key named headers listing extra headers. If a string, taken as content-disposition header. (Support for array of options new in 1.23)
Returns:
FileRepoStatus

Definition at line 944 of file FileRepo.php.

References $options, array(), and quickImportBatch().

Import a batch of files from the local file system into the repo.

This does no locking nor journaling and overrides existing files. This function can be used to write to otherwise read-only foreign repos. This is intended for copying generated thumbnails into the repo.

All path parameters may be a file system path, storage path, or virtual URL. When "headers" are given they are used as HTTP headers if supported.

Parameters:
array$triplesList of (source path, destination path, disposition)
Returns:
FileRepoStatus

Definition at line 987 of file FileRepo.php.

Referenced by quickImport().

FileRepo::quickPurge ( path) [final]

Purge a file from the repo.

This does no locking nor journaling. This function can be used to write to otherwise read-only foreign repos. This is intended for purging thumbnails.

Parameters:
string$pathVirtual URL or storage path
Returns:
FileRepoStatus

Definition at line 956 of file FileRepo.php.

Purge a batch of files from the repo.

This function can be used to write to otherwise read-only foreign repos. This does no locking nor journaling and is intended for purging thumbnails.

Parameters:
array$pathsList of virtual URLs or storage paths
Returns:
FileRepoStatus

Definition at line 1025 of file FileRepo.php.

FileRepo::resolveToStoragePath ( path) [protected]

If a path is a virtual URL, resolve it to a storage path.

Otherwise, just return the path as it is.

Parameters:
string$path
Returns:
string
Exceptions:
MWException

Definition at line 1474 of file FileRepo.php.

Referenced by getLocalReference(), and storeBatch().

Get the backend storage path corresponding to a virtual URL.

Use this function wisely.

Parameters:
string$url
Exceptions:
MWException
Returns:
string

Definition at line 299 of file FileRepo.php.

Referenced by getLocalCopy().

FileRepo::store ( srcPath,
dstZone,
dstRel,
flags = 0 
)

Store a file to a given destination.

Parameters:
string$srcPathSource file system path, storage path, or virtual URL
string$dstZoneDestination zone
string$dstRelDestination relative path
int$flagsBitwise combination of the following flags: self::DELETE_SOURCE Delete the source file after upload self::OVERWRITE Overwrite an existing destination file instead of failing self::OVERWRITE_SAME Overwrite the file if the destination exists and has the same contents as the source self::SKIP_LOCKING Skip any file locking when doing the store
Returns:
FileRepoStatus

Definition at line 803 of file FileRepo.php.

FileRepo::storeBatch ( array triplets,
flags = 0 
)

Store a batch of files.

Parameters:
array$triplets(src, dest zone, dest rel) triplets as per store()
int$flagsBitwise combination of the following flags: self::DELETE_SOURCE Delete the source file after upload self::OVERWRITE Overwrite an existing destination file instead of failing self::OVERWRITE_SAME Overwrite the file if the destination exists and has the same contents as the source self::SKIP_LOCKING Skip any file locking when doing the store
Exceptions:
MWException
Returns:
FileRepoStatus

Definition at line 827 of file FileRepo.php.

References $backend, $file, $flags, array(), as, assertWritableRepo(), DELETE_SOURCE, FileBackend\doOperations(), getZonePath(), initDirectory(), FileBackend\isStoragePath(), list, newFatal(), newGood(), resolveToStoragePath(), validateFilename(), wfDebug(), wfRestoreWarnings(), and wfSuppressWarnings().

FileRepo::storeTemp ( originalName,
srcPath 
)

Pick a random name in the temp zone and store a file to it.

Returns a FileRepoStatus object with the file Virtual URL in the value, file can later be disposed using FileRepo::freeTemp().

Parameters:
string$originalNameThe base name of the file as specified by the user. The file extension will be maintained.
string$srcPathThe current location of the file.
Returns:
FileRepoStatus Object with the URL in the value.

Definition at line 1050 of file FileRepo.php.

FileRepo::streamFile ( virtualUrl,
headers = array() 
)

Attempt to stream a file with the given virtual URL/storage path.

Parameters:
string$virtualUrl
array$headersAdditional HTTP headers to send on success
Returns:
bool Success

Definition at line 1565 of file FileRepo.php.

FileRepo::validateFilename ( filename)

Determine if a relative path is valid, i.e.

not blank or involving directory traveral

Parameters:
string$filename
Returns:
bool

Definition at line 1616 of file FileRepo.php.

Referenced by storeBatch().


Member Data Documentation

int FileRepo::$abbrvThreshold [protected]

File names over this size will use the short form of thumbnail names.

Short thumbnail names only have the width, parameters, and the extension.

Definition at line 99 of file FileRepo.php.

FileRepo::$articleUrl [protected]

Definition at line 73 of file FileRepo.php.

FileBackend FileRepo::$backend [protected]

*

Definition at line 50 of file FileRepo.php.

Referenced by FSRepo\__construct(), and storeBatch().

int FileRepo::$deletedHashLevels [protected]

The number of directory levels for hash-based division of deleted files *.

Definition at line 94 of file FileRepo.php.

FileRepo::$descBaseUrl [protected]

Definition at line 62 of file FileRepo.php.

int FileRepo::$descriptionCacheExpiry

*

Definition at line 48 of file FileRepo.php.

string FileRepo::$favicon [protected]

The URL of the repo's favicon, if any *.

Definition at line 101 of file FileRepo.php.

bool FileRepo::$fetchDescription

Whether to fetch commons image description pages and display them on the local wiki *.

Definition at line 46 of file FileRepo.php.

FileRepo::$fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' ) [protected]

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

Reimplemented in ForeignAPIRepo, ForeignDBRepo, ForeignDBViaLBRepo, and LocalRepo.

Definition at line 107 of file FileRepo.php.

FileRepo::$fileFactoryKey = false [protected]

Reimplemented in LocalRepo.

Definition at line 109 of file FileRepo.php.

int FileRepo::$hashLevels [protected]

The number of directory levels for hash-based division of files *.

Definition at line 92 of file FileRepo.php.

bool FileRepo::$initialCapital [protected]

Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter.

The current implementation may give incorrect description page links when the local $wgCapitalLinks and initialCapital are mismatched.

Definition at line 79 of file FileRepo.php.

FileRepo::$oldFileFactory = false [protected]

Reimplemented in LocalRepo.

Definition at line 108 of file FileRepo.php.

FileRepo::$oldFileFactoryKey = false [protected]

Reimplemented in LocalRepo.

Definition at line 110 of file FileRepo.php.

string FileRepo::$pathDisclosureProtection = 'simple' [protected]

May be 'paranoid' to remove all parameters from error messages, 'none' to leave the paths in unchanged, or 'simple' to replace paths with placeholders.

Default for LocalRepo is 'simple'.

Definition at line 85 of file FileRepo.php.

FileRepo::$scriptDirUrl [protected]

Definition at line 67 of file FileRepo.php.

string FileRepo::$scriptExtension [protected]

Script extension of the MediaWiki installation, equivalent to $wgScriptExtension, e.g.

.php5 defaults to .php *

Definition at line 70 of file FileRepo.php.

string FileRepo::$thumbScriptUrl [protected]

URL of thumb.php *.

Definition at line 54 of file FileRepo.php.

FileRepo::$thumbUrl [protected]

Definition at line 90 of file FileRepo.php.

bool FileRepo::$transformVia404 [protected]

Whether to skip media file transformation on parse and rely on a 404 handler instead.

*

Definition at line 57 of file FileRepo.php.

bool FileRepo::$url [protected]

Public zone URL.

*

Definition at line 87 of file FileRepo.php.

array FileRepo::$zones = array() [protected]

Map of zones to config *.

Definition at line 52 of file FileRepo.php.

Definition at line 38 of file FileRepo.php.

Referenced by storeBatch().

Definition at line 43 of file FileRepo.php.

Definition at line 39 of file FileRepo.php.

Definition at line 40 of file FileRepo.php.

Referenced by LocalFileRestoreBatch\addIds().

Definition at line 41 of file FileRepo.php.


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