MediaWiki  1.33.0
MockLocalRepo Class Reference

Class simulating a local file repo. More...

Inheritance diagram for MockLocalRepo:
Collaboration diagram for MockLocalRepo:

Public Member Functions

 getFileProps ( $virtualUrl)
 Get properties of a file with a given virtual URL/storage path. 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...
 
- Public Member Functions inherited from LocalRepo
 __construct (array $info=null)
 
 checkRedirect (Title $title)
 Checks if there is a redirect named as $title. More...
 
 cleanupBatch (array $files, $flags=0)
 Deletes a batch of files. More...
 
 cleanupDeletedBatch (array $storageKeys)
 Delete files in the deleted directory if they are not referenced in the filearchive table. 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...
 
 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...
 
 getReplicaDB ()
 Get a connection to the replica DB. More...
 
 getSharedCacheKey ()
 Get a key on the primary cache for this repository. More...
 
 getSlaveDB ()
 Alias for getReplicaDB() More...
 
 invalidateImageRedirect (Title $title)
 Invalidates image redirect cache related to that image. More...
 
 newFileFromRow ( $row)
 
 newFromArchiveName ( $title, $archiveName)
 
 publish ( $src, $dstRel, $archiveRel, $flags=0, array $options=[])
 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...
 
 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...
 
- Public Member Functions inherited from FileRepo
 backendSupportsUnicodePaths ()
 
 canTransformVia404 ()
 Returns true if the repository can transform files via a 404 handler. More...
 
 cleanDir ( $dir)
 Deletes a directory if empty. More...
 
 concatenate (array $srcPaths, $dstPath, $flags=0)
 Concatenate a list of temporary files into a target file location. More...
 
 enumFiles ( $callback)
 Call a callback function for every public regular file in the repository. More...
 
 fileExists ( $file)
 Checks existence of a file. More...
 
 fileExistsBatch (array $files)
 Checks existence of an array of files. More...
 
 findFile ( $title, $options=[])
 Find an instance of the named file created at the specified time Returns false if the file does not exist. More...
 
 findFileFromKey ( $sha1, $options=[])
 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...
 
 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...
 
 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...
 
 getTempHashPath ( $suffix)
 Get a relative path including trailing slash, e.g. More...
 
 getTempRepo ()
 Get a temporary private FileRepo associated with this repo. More...
 
 getThumbProxySecret ()
 Get the secret key for the proxied thumb service. More...
 
 getThumbProxyUrl ()
 Get the URL thumb.php requests are being proxied to. 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...
 
 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...
 
 hasSha1Storage ()
 Returns whether or not storage is SHA-1 based. 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...
 
 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...
 
 storeTemp ( $originalName, $srcPath)
 Pick a random name in the temp zone and store a file to it. More...
 
 streamFile ( $virtualUrl, $headers=[])
 Attempt to stream a file with the given virtual URL/storage path. More...
 
 streamFileWithStatus ( $virtualUrl, $headers=[], $optHeaders=[])
 Attempt to stream a file with the given virtual URL/storage path. More...
 
 supportsSha1URLs ()
 Returns whether or not repo supports having originals SHA-1s in the thumb URLs. More...
 
 validateFilename ( $filename)
 Determine if a relative path is valid, i.e. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from LocalRepo
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...
 
- 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
 
- Protected Member Functions inherited from LocalRepo
 deletedFileHasKey ( $key, $lock=null)
 Check if a deleted (filearchive) file has this sha1 key. More...
 
 getDBFactory ()
 Get a callback to get a DB handle given an index (DB_REPLICA/DB_MASTER) More...
 
 hiddenFileHasKey ( $key, $lock=null)
 Check if a hidden (revision delete) file has this sha1 key. More...
 
 skipWriteOperationIfSha1 ( $function, array $args)
 Skips the write operation if storage is sha1-based, executes it normally otherwise. 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=[])
 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...
 
- Static Protected Member Functions inherited from FileRepo
static getHashPathForLevel ( $name, $levels)
 
- Protected Attributes inherited from LocalRepo
callable $fileFactory = [ LocalFile::class, 'newFromTitle' ]
 
callable $fileFactoryKey = [ LocalFile::class, 'newFromKey' ]
 
callable $fileFromRowFactory = [ LocalFile::class, 'newFromRow' ]
 
callable $oldFileFactory = [ OldLocalFile::class, 'newFromTitle' ]
 
callable $oldFileFactoryKey = [ OldLocalFile::class, 'newFromKey' ]
 
callable $oldFileFromRowFactory = [ OldLocalFile::class, 'newFromRow' ]
 
- Protected Attributes inherited from FileRepo
int $abbrvThreshold
 File names over this size will use the short form of thumbnail names. More...
 
string $articleUrl
 Equivalent to $wgArticlePath, e.g. More...
 
FileBackend $backend
 
int $deletedHashLevels
 The number of directory levels for hash-based division of deleted files. More...
 
string $descBaseUrl
 URL of image description pages, e.g. More...
 
string $favicon
 The URL of the repo's favicon, if any. More...
 
array $fileFactory = [ UnregisteredLocalFile::class, 'newFromTitle' ]
 callable Override these in the base class More...
 
array $fileFactoryKey = false
 callable|bool Override these in the base class More...
 
int $hashLevels
 The number of directory levels for hash-based division of files. More...
 
bool $hasSha1Storage = false
 
bool $initialCapital
 Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter. More...
 
bool $isPrivate
 Whether all zones should be private (e.g. More...
 
array $oldFileFactory = false
 callable|bool Override these in the base class More...
 
array $oldFileFactoryKey = false
 callable|bool Override these in the base class More...
 
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...
 
string $scriptDirUrl
 URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g. More...
 
bool $supportsSha1URLs = false
 
string $thumbProxySecret
 Secret key to pass as an X-Swift-Secret header to the proxied thumb service. More...
 
string $thumbProxyUrl
 URL of where to proxy thumb.php requests to. More...
 
string $thumbScriptUrl
 URL of thumb.php. More...
 
string $thumbUrl
 The base thumbnail URL. More...
 
bool $transformVia404
 Whether to skip media file transformation on parse and rely on a 404 handler instead. More...
 
string false $url
 Public zone URL. More...
 
WANObjectCache $wanCache
 
array $zones = []
 Map of zones to config. More...
 

Detailed Description

Class simulating a local file repo.

Since
1.28

Definition at line 9 of file MockLocalRepo.php.

Member Function Documentation

◆ getFileProps()

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

Definition at line 18 of file MockLocalRepo.php.

References getLocalReference().

◆ getLocalCopy()

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

Reimplemented from FileRepo.

Definition at line 10 of file MockLocalRepo.php.

References wfRandomString(), and wfTempDir().

◆ getLocalReference()

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

Reimplemented from FileRepo.

Definition at line 14 of file MockLocalRepo.php.

References wfRandomString(), and wfTempDir().

Referenced by getFileProps().


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