MediaWiki  REL1_19
FileRepo Class Reference

Base class for file repositories. More...

Inheritance diagram for FileRepo:

List of all members.

Public Member Functions

 __construct (Array $info=null)
 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.
 cleanupBatch ($files, $flags=0)
 Deletes a batch of files.
 cleanupDeletedBatch ($storageKeys)
 Delete files in the deleted directory if they are not referenced in the filearchive table.
 concatenate ($srcPaths, $dstPath, $flags=0)
 Concatenate a list of files into a target file location.
 delete ($srcRel, $archiveRel)
 Move a file to the deletion archive.
 deleteBatch ($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, $flags=0)
 Checks existence of a a file.
 fileExistsBatch ($files, $flags=0)
 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.
 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 ($items)
 Find many files at once.
 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 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.
 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 an image from its title object.
 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.
 getThumbScriptUrl ()
 Get the URL of thumb.php.
 getUploadStash ()
 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)
 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.
 isHashed ()
 Returns true if the repository uses a multi-level directory structure.
 isLocal ()
 Returns true if this the local file repository.
 makeUrl ($query= '', $entry= 'index')
 Make an url to this repo.
 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)
 Copy or move a file either from a storage path, virtual URL, or FS path, into this repository at the specified destination location.
 publishBatch ($triplets, $flags=0)
 Publish a batch of files.
 resolveVirtualUrl ($url)
 Get the backend storage path corresponding to a virtual URL.
 simpleClean ($param)
 Path disclosure protection function.
 store ($srcPath, $dstZone, $dstRel, $flags=0)
 Store a file to a given destination.
 storeBatch ($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 getHashPathForLevel ($name, $levels)
static isVirtualUrl ($url)
 Determine if a string is an mwrepo:// URL.

Public Attributes

 $articleUrl
 $deletedHashLevels
 $descBaseUrl
 $descriptionCacheExpiry
 $fetchDescription
 $fileFactory = array( 'UnregisteredLocalFile', 'newFromTitle' )
 Factory functions for creating new files Override these in the base class.
 $fileFactoryKey = false
 $hashLevels
 $initialCapital
 $oldFileFactory = false
 $oldFileFactoryKey = false
 $pathDisclosureProtection = 'simple'
 $scriptDirUrl
 $scriptExtension
 $thumbScriptUrl
 $thumbUrl
 $transformVia404
 $url
const DELETE_SOURCE = 1
const FILES_ONLY = 1
const OVERWRITE = 2
const OVERWRITE_SAME = 4
const SKIP_LOCKING = 8

Protected Member Functions

 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.
 initDeletedDir ($dir)
 Take all available measures to prevent web accessibility of new deleted directories, in case the user has not configured offline storage.
 initZones ($doZones=array())
 Prepare a single zone or list of zones for usage.
 resolveToStoragePath ($path)
 If a path is a virtual URL, resolve it to a storage path.

Protected Attributes

 $backend
 $zones = array()

Detailed Description

Base class for file repositories.

Definition at line 22 of file FileRepo.php.


Constructor & Destructor Documentation

FileRepo::__construct ( Array $  info = null)

Definition at line 50 of file FileRepo.php.

References MWNamespace\isCapitalized(), and FileBackendGroup\singleton().

Here is the call graph for this function:


Member Function Documentation

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

Returns:
bool

Definition at line 451 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:
$titleTitle of image
Returns:
Bool

Reimplemented in LocalRepo.

Definition at line 1388 of file FileRepo.php.

Referenced by findFile().

Here is the caller graph for this function:

FileRepo::cleanupBatch ( files,
flags = 0 
)

Deletes a batch of files.

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

Parameters:
$pairsarray List of files to delete
$flagsInteger: bitwise combination of the following flags: self::SKIP_LOCKING Skip any file locking when doing the deletions
Returns:
void

Definition at line 740 of file FileRepo.php.

References $file, $files, $path, getZonePath(), FileBackend\isStoragePath(), resolveVirtualUrl(), wfRestoreWarnings(), and wfSuppressWarnings().

Here is the call graph for this function:

FileRepo::cleanupDeletedBatch ( storageKeys)

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

STUB

Reimplemented in LocalRepo.

Definition at line 1378 of file FileRepo.php.

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

Concatenate a list of files into a target file location.

Parameters:
$srcPathsArray Ordered list of source virtual URLs/storage paths
$dstPathString Target file system path
$flagsInteger: bitwise combination of the following flags: self::DELETE_SOURCE Delete the source files
Returns:
FileRepoStatus

Reimplemented in ForeignAPIRepo, and NullRepo.

Definition at line 813 of file FileRepo.php.

References newGood(), and resolveToStoragePath().

Here is the call graph for this function:

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:
$srcRelMixed: relative path for the file to be deleted
$archiveRelMixed: relative path for the archive location. Relative to a private archive directory.
Returns:
FileRepoStatus object

Definition at line 1052 of file FileRepo.php.

References deleteBatch().

Here is the call graph for this function:

FileRepo::deleteBatch ( 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:
$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.
Returns:
FileRepoStatus

Reimplemented in ForeignAPIRepo, ForeignDBRepo, ForeignDBViaLBRepo, and NullRepo.

Definition at line 1072 of file FileRepo.php.

References $backend, getZonePath(), initDeletedDir(), initZones(), newFatal(), newGood(), and validateFilename().

Referenced by delete().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$callbackArray|string
Returns:
void

Reimplemented in ForeignAPIRepo.

Definition at line 1239 of file FileRepo.php.

References enumFilesInStorage().

Here is the call graph for this function:

FileRepo::enumFilesInStorage ( callback) [protected]

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

May use either the database or the filesystem.

Parameters:
$callbackArray|string
Returns:
void

Definition at line 1250 of file FileRepo.php.

References $path, and getZonePath().

Referenced by enumFiles().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::fileExists ( file,
flags = 0 
)

Checks existence of a a file.

Parameters:
$fileVirtual URL (or storage path) of file to check
$flagsInteger: bitwise combination of the following flags: self::FILES_ONLY Mark file as existing only if it is a file (not directory)
Returns:
bool

Definition at line 1009 of file FileRepo.php.

References $file, $result, and fileExistsBatch().

Referenced by ForeignAPIRepo\getThumbUrlFromCache().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::fileExistsBatch ( files,
flags = 0 
)

Checks existence of an array of files.

Parameters:
$filesArray: Virtual URLs (or storage paths) of files to check
$flagsInteger: bitwise combination of the following flags: self::FILES_ONLY Mark file as existing only if it is a file (not directory)
Returns:
Either array of files and existence flags, or false

Reimplemented in ForeignAPIRepo, and NullRepo.

Definition at line 1022 of file FileRepo.php.

References $file, $files, $result, FileBackend\isStoragePath(), and resolveVirtualUrl().

Referenced by fileExists().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::findBySha1 ( hash)

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

STUB

Reimplemented in LocalRepo, and ForeignAPIRepo.

Definition at line 415 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:
$titleMixed: Title object or string
$optionsarray Associative array of options: time: requested time for an archived image, or false for the current version. An image object will be returned which was created at the specified time.

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.

Returns:
File|false

Reimplemented in NullRepo.

Definition at line 300 of file FileRepo.php.

References $options, $title, checkRedirect(), File\DELETED_FILE, newFile(), and File\normalizeTitle().

Referenced by findFiles().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$sha1String base 36 SHA-1 hash
$optionsOption array, same as findFile().
Returns:
File|false

Definition at line 383 of file FileRepo.php.

References $options, and File\DELETED_FILE.

FileRepo::findFiles ( items)

Find many files at once.

Parameters:
$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 );

Returns:
array

Definition at line 355 of file FileRepo.php.

References $file, $options, $result, $title, and findFile().

Here is the call graph for this function:

FileRepo::freeTemp ( virtualUrl)

Remove a temporary file or mark it for garbage collection.

Parameters:
$virtualUrlString: the virtual URL returned by FileRepo::storeTemp()
Returns:
Boolean: true on success, false on failure

Definition at line 852 of file FileRepo.php.

References $path, resolveVirtualUrl(), and wfDebug().

Here is the call graph for this function:

Get the file backend instance.

Returns:
FileBackend

Definition at line 118 of file FileRepo.php.

Referenced by ForeignAPIRepo\getThumbUrlFromCache().

Here is the caller graph for this function:

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

s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg

Returns:
string

Definition at line 1132 of file FileRepo.php.

References $path.

Referenced by LocalRepo\cleanupDeletedBatch().

Here is the caller graph for this function:

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:
$nameString: name of image to fetch
$langString: language to fetch it in, if any.
Returns:
string

Definition at line 591 of file FileRepo.php.

References getDescriptionUrl(), makeUrl(), wfAppendQuery(), and wfUrlencode().

Here is the call graph for this function:

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

Returns:
string|false

Definition at line 616 of file FileRepo.php.

References Skin\getDynamicStylesheetQuery(), makeUrl(), and wfArrayToCGI().

Here is the call graph for this function:

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:
$namestring
Returns:
string

Definition at line 556 of file FileRepo.php.

References makeUrl(), and wfUrlencode().

Referenced by getDescriptionRenderUrl().

Here is the call graph for this function:

Here is the caller graph for this function:

Get the human-readable name of the repo.

Returns:
string

Definition at line 1406 of file FileRepo.php.

References isLocal(), and wfMessageFallback().

Here is the call graph for this function:

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

Returns:
Array

Definition at line 1303 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:
$virtualUrlstring
Returns:
Array

Reimplemented in ForeignAPIRepo, and NullRepo.

Definition at line 1187 of file FileRepo.php.

References $path, and resolveToStoragePath().

Here is the call graph for this function:

FileRepo::getFileSha1 ( virtualUrl)

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

Parameters:
$virtualUrlstring
Returns:
string|false

Definition at line 1209 of file FileRepo.php.

References $path, and resolveToStoragePath().

Here is the call graph for this function:

FileRepo::getFileTimestamp ( virtualUrl)

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

Parameters:
$virtualUrlstring
Returns:
string|false

Definition at line 1198 of file FileRepo.php.

References $path, and resolveToStoragePath().

Referenced by ForeignAPIRepo\getThumbUrlFromCache().

Here is the call graph for this function:

Here is the caller graph for this function:

Get the number of hash directory levels.

Returns:
integer

Definition at line 516 of file FileRepo.php.

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:
$namestring
Returns:
string

Definition at line 489 of file FileRepo.php.

References getHashPathForLevel().

Referenced by ForeignAPIRepo\getThumbUrlFromCache(), and storeTemp().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 498 of file FileRepo.php.

References $path.

Referenced by getHashPath().

Here is the caller graph for this function:

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 1442 of file FileRepo.php.

References getName().

Referenced by LocalRepo\checkRedirect(), ForeignAPIRepo\fetchImageQuery(), and ForeignAPIRepo\getThumbUrlFromCache().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$virtualUrlstring
Returns:
TempFSFile|null Returns null on failure

Definition at line 1162 of file FileRepo.php.

References $path, and resolveToStoragePath().

Here is the call graph for this function:

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:
$virtualUrlstring
Returns:
FSFile|null Returns null on failure.

Definition at line 1175 of file FileRepo.php.

References $path, and resolveToStoragePath().

Here is the call graph for this function:

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

Returns:
string

Definition at line 525 of file FileRepo.php.

Referenced by getLocalCacheKey(), and isLocal().

Here is the caller graph for this function:

Get the name of an image from its title object.

Parameters:
$titleTitle

Definition at line 460 of file FileRepo.php.

References $wgContLang, Title\getDBkey(), Title\getUserCaseDBKey(), and MWNamespace\isCapitalized().

Here is the call graph for this function:

Get the public zone root storage directory of the repository.

Returns:
string

Definition at line 478 of file FileRepo.php.

References getZonePath().

Here is the call graph for this function:

Get the public root URL of the repository.

Returns:
string|false

Definition at line 424 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

Reimplemented in LocalRepo, ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 1431 of file FileRepo.php.

Get the URL of thumb.php.

Returns:
string

Definition at line 442 of file FileRepo.php.

Get an UploadStash associated with this repo.

Returns:
UploadStash

Definition at line 1453 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:
$suffixstring
Returns:
string

Definition at line 170 of file FileRepo.php.

References $path.

Referenced by storeTemp().

Here is the caller graph for this function:

FileRepo::getZoneLocation ( zone) [protected]

The the storage container and base path of a zone.

Parameters:
$zonestring
Returns:
Array (container, base path) or (null, null)

Definition at line 230 of file FileRepo.php.

Referenced by getZonePath().

Here is the caller graph for this function:

FileRepo::getZonePath ( zone)

Get the storage path corresponding to one of the zones.

Parameters:
$zonestring
Returns:
string|null

Reimplemented in ForeignAPIRepo.

Definition at line 243 of file FileRepo.php.

References getZoneLocation().

Referenced by cleanupBatch(), LocalRepo\cleanupDeletedBatch(), deleteBatch(), enumFilesInStorage(), getRootDirectory(), initZones(), publishBatch(), resolveVirtualUrl(), and storeBatch().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::getZoneUrl ( zone)

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

Parameters:
$zoneString: one of: public, deleted, temp, thumb
Returns:
String or false

Reimplemented in ForeignAPIRepo.

Definition at line 184 of file FileRepo.php.

FileRepo::initDeletedDir ( dir) [protected]

Take all available measures to prevent web accessibility of new deleted directories, in case the user has not configured offline storage.

Parameters:
$dirstring
Returns:
void

Definition at line 147 of file FileRepo.php.

References $dir.

Referenced by deleteBatch(), and storeBatch().

Here is the caller graph for this function:

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

Prepare a single zone or list of zones for usage.

See initDeletedDir() for additional setup needed for the 'deleted' zone.

Parameters:
$doZonesArray Only do a particular zones
Returns:
Status

Definition at line 129 of file FileRepo.php.

References getZonePath(), and newGood().

Referenced by deleteBatch(), and publishBatch().

Here is the call graph for this function:

Here is the caller graph for this function:

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

STUB

Parameters:
$titleTitle of image

Reimplemented in LocalRepo.

Definition at line 1399 of file FileRepo.php.

Returns true if the repository uses a multi-level directory structure.

Returns:
string

Definition at line 433 of file FileRepo.php.

Returns true if this the local file repository.

Returns:
bool

Definition at line 1420 of file FileRepo.php.

References getName().

Referenced by getDisplayName().

Here is the call graph for this function:

Here is the caller graph for this function:

static FileRepo::isVirtualUrl ( url) [static]

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

Parameters:
$urlstring
Returns:
bool

Definition at line 158 of file FileRepo.php.

References $url.

Referenced by RepoGroup\getFileProps(), and resolveToStoragePath().

Here is the caller graph for this function:

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

Make an url to this repo.

Parameters:
$querymixed Query string to append
$entrystring Entry point; defaults to index
Returns:
string|false

Definition at line 536 of file FileRepo.php.

References $ext, and wfAppendQuery().

Referenced by ForeignAPIRepo\fetchImageQuery(), getDescriptionRenderUrl(), getDescriptionStylesheetUrl(), and getDescriptionUrl().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::newFatal ( message)

Create a new fatal error.

Returns:
FileRepoStatus

Definition at line 1358 of file FileRepo.php.

References MWInit\callStaticMethod().

Referenced by deleteBatch(), publishBatch(), and storeBatch().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::newFile ( title,
time = false 
)

Create a new File object from the local repository.

Parameters:
$titleMixed: Title object or string
$timeMixed: Time 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, and NullRepo.

Definition at line 266 of file FileRepo.php.

References $title, and File\normalizeTitle().

Referenced by findFile().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::newGood ( value = null)

Create a new good result.

Returns:
FileRepoStatus

Definition at line 1369 of file FileRepo.php.

Referenced by LocalRepo\cleanupDeletedBatch(), concatenate(), deleteBatch(), initZones(), publishBatch(), and storeBatch().

Here is the caller graph for this function:

Path disclosure protection function.

Parameters:
$paramstring
Returns:
string

Definition at line 1323 of file FileRepo.php.

FileRepo::passThrough ( param)

Path disclosure protection function.

Parameters:
$paramstring
Returns:
string

Definition at line 1349 of file FileRepo.php.

FileRepo::publish ( srcPath,
dstRel,
archiveRel,
flags = 0 
)

Copy or move a file either from a storage path, virtual URL, or FS 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.

Parameters:
$srcPathString: the source FS path, storage path, or URL
$dstRelString: the destination relative path
$archiveRelString: the relative path where the existing file is to be archived, if there is one. Relative to the public zone root.
$flagsInteger: bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source file should be deleted if possible

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 878 of file FileRepo.php.

References publishBatch().

Here is the call graph for this function:

FileRepo::publishBatch ( triplets,
flags = 0 
)

Publish a batch of files.

Parameters:
$tripletsArray: (source, dest, archive) triplets as per publish()
$flagsInteger: bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible
Returns:
FileRepoStatus

Reimplemented in ForeignAPIRepo, and NullRepo.

Definition at line 899 of file FileRepo.php.

References $backend, $file, getZonePath(), initZones(), FileBackend\isStoragePath(), newFatal(), newGood(), resolveVirtualUrl(), validateFilename(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by publish().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$pathstring
Returns:
string
Exceptions:
MWException

Definition at line 1148 of file FileRepo.php.

References $path, isVirtualUrl(), and resolveVirtualUrl().

Referenced by concatenate(), getFileProps(), getFileSha1(), getFileTimestamp(), getLocalCopy(), getLocalReference(), and streamFile().

Here is the call graph for this function:

Here is the caller graph for this function:

Get the backend storage path corresponding to a virtual URL.

Parameters:
$urlstring
Returns:
string

Definition at line 205 of file FileRepo.php.

References $url, and getZonePath().

Referenced by cleanupBatch(), fileExistsBatch(), freeTemp(), publishBatch(), resolveToStoragePath(), and storeBatch().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::simpleClean ( param)

Path disclosure protection function.

Parameters:
$paramstring
Returns:
string

Definition at line 1333 of file FileRepo.php.

References $IP.

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

Store a file to a given destination.

Parameters:
$srcPathString: source FS path, storage path, or virtual URL
$dstZoneString: destination zone
$dstRelString: destination relative path
$flagsInteger: bitwise 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

Reimplemented in ForeignDBRepo, and ForeignDBViaLBRepo.

Definition at line 638 of file FileRepo.php.

References storeBatch().

Referenced by storeTemp().

Here is the call graph for this function:

Here is the caller graph for this function:

FileRepo::storeBatch ( triplets,
flags = 0 
)

Store a batch of files.

Parameters:
$tripletsArray: (src, dest zone, dest rel) triplets as per store()
$flagsInteger: bitwise 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

Reimplemented in ForeignAPIRepo, and NullRepo.

Definition at line 658 of file FileRepo.php.

References $backend, $file, DELETE_SOURCE, getZonePath(), initDeletedDir(), FileBackend\isStoragePath(), newFatal(), newGood(), resolveVirtualUrl(), validateFilename(), wfDebug(), wfRestoreWarnings(), and wfSuppressWarnings().

Referenced by store().

Here is the call graph for this function:

Here is the caller graph for this function:

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:
$originalNameString: the base name of the file as specified by the user. The file extension will be maintained.
$srcPathString: the current location of the file.
Returns:
FileRepoStatus object with the URL in the value.

Reimplemented in ForeignAPIRepo, and NullRepo.

Definition at line 793 of file FileRepo.php.

References $result, getHashPath(), getVirtualUrl(), and store().

Here is the call graph for this function:

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

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

Parameters:
$virtualUrlstring
$headersArray Additional HTTP headers to send on success
Returns:
bool Success

Definition at line 1225 of file FileRepo.php.

References $path, and resolveToStoragePath().

Here is the call graph for this function:

FileRepo::validateFilename ( filename)

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

not blank or involving directory traveral

Parameters:
$filenamestring
Returns:
bool

Definition at line 1275 of file FileRepo.php.

References wfIsWindows().

Referenced by deleteBatch(), ForeignAPIRepo\getThumbUrlFromCache(), publishBatch(), and storeBatch().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

FileRepo::$articleUrl

Definition at line 36 of file FileRepo.php.

FileRepo::$deletedHashLevels

Definition at line 40 of file FileRepo.php.

FileRepo::$descBaseUrl

Definition at line 36 of file FileRepo.php.

FileRepo::$descriptionCacheExpiry

Definition at line 39 of file FileRepo.php.

FileRepo::$fetchDescription

Definition at line 37 of file FileRepo.php.

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

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

Reimplemented in ForeignAPIRepo, ForeignDBRepo, LocalRepo, and ForeignDBViaLBRepo.

Definition at line 46 of file FileRepo.php.

FileRepo::$fileFactoryKey = false

Reimplemented in LocalRepo.

Definition at line 48 of file FileRepo.php.

FileRepo::$hashLevels

Definition at line 40 of file FileRepo.php.

FileRepo::$initialCapital

Definition at line 37 of file FileRepo.php.

FileRepo::$oldFileFactory = false

Reimplemented in LocalRepo.

Definition at line 47 of file FileRepo.php.

FileRepo::$oldFileFactoryKey = false

Reimplemented in LocalRepo.

Definition at line 48 of file FileRepo.php.

FileRepo::$pathDisclosureProtection = 'simple'

Definition at line 38 of file FileRepo.php.

FileRepo::$scriptDirUrl

Definition at line 36 of file FileRepo.php.

FileRepo::$scriptExtension

Definition at line 36 of file FileRepo.php.

FileRepo::$thumbScriptUrl

Definition at line 35 of file FileRepo.php.

FileRepo::$thumbUrl

Definition at line 39 of file FileRepo.php.

FileRepo::$transformVia404

Definition at line 35 of file FileRepo.php.

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

Definition at line 33 of file FileRepo.php.

Definition at line 26 of file FileRepo.php.

Referenced by StoreBatchTest\storecohort().

Definition at line 28 of file FileRepo.php.

Referenced by LocalFile\purgeThumbList(), and ForeignAPIFile\purgeThumbnails().


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