|
MediaWiki master
|
Base class for file repositories. More...
Inherited by MediaWiki\FileRepo\ForeignAPIRepo, MediaWiki\FileRepo\LocalRepo, MediaWiki\FileRepo\NullRepo, and MediaWiki\FileRepo\TempFileRepo.

Public Member Functions | |
| __construct (?array $info=null) | |
| addShellboxInputFile (BoxedCommand $command, string $boxedName, string $virtualUrl) | |
| Add a file to a Shellbox command as an input file. | |
| backendSupportsUnicodePaths () | |
| canTransformLocally () | |
| Returns true if the repository can transform files locally. | |
| canTransformVia404 () | |
| Returns true if the repository can transform files via a 404 handler. | |
| checkRedirect ( $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 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=[]) | |
| Find an instance of the named file created at the specified time Returns false if the file does not exist. | |
| 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. | |
| 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. | |
| 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 ( $kClassSuffix,... $components) | |
| Get a site-local, repository-qualified, WAN cache key. | |
| 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) | |
| Get the name of a file from its title. | |
| getReadOnlyReason () | |
| Get an explanatory message if this repo is read-only. | |
| getRootDirectory () | |
| Get the public zone root storage directory of the repository. | |
| getSharedCacheKey ( $kClassSuffix,... $components) | |
| Get a global, repository-qualified, WAN cache key. | |
| getTempHashPath ( $suffix) | |
| Get a relative path including trailing slash, e.g. | |
| getTempRepo () | |
| Get a temporary private FileRepo associated with this repo. | |
| getThumbProxySecret () | |
| Get the secret key for the proxied thumb service. | |
| getThumbProxyUrl () | |
| Get the URL thumb.php requests are being proxied to. | |
| getThumbScriptUrl () | |
| Get the URL of thumb.php. | |
| 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. | |
| hasSha1Storage () | |
| Returns whether or not storage is SHA-1 based. | |
| invalidateImageRedirect ( $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,... $parameters) | |
| 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 ( $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. | |
| 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. | |
| streamFileWithStatus ( $virtualUrl, $headers=[], $optHeaders=[]) | |
| Attempt to stream a file with the given virtual URL/storage path. | |
| supportsSha1URLs () | |
| Returns whether or not repo supports having originals SHA-1s in the thumb URLs. | |
| 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. | |
| string | $name |
| 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. | |
| getBackendOperationOptions () | |
| FileRepo is responsible for locking since there can be both file objects and metadata. | |
| getZoneLocation ( $zone) | |
| The storage container and base path of a zone. | |
| initDirectory ( $dir) | |
| Creates a directory with the appropriate zone permissions. | |
| initZones ( $doZones=[]) | |
| Ensure that a single zone or list of zones is defined for usage. | |
| resolveToStoragePathIfVirtual ( $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. | |
| string null | $articleUrl |
| Equivalent to $wgArticlePath, e.g. | |
| FileBackend | $backend |
| int | $deletedHashLevels |
| The number of directory levels for hash-based division of deleted files. | |
| string null | $descBaseUrl |
| URL of image description pages, e.g. | |
| bool | $disableLocalTransform = false |
| Disable local image scaling. | |
| null string | $favicon = null |
| The URL to a favicon (optional, may be a server-local path URL). | |
| callable | $fileFactory = [ UnregisteredLocalFile::class, 'newFromTitle' ] |
| Override these in the base class. | |
| callable false | $fileFactoryKey = false |
| Override these in the base class. | |
| int | $hashLevels |
| The number of directory levels for hash-based division of files. | |
| bool | $hasSha1Storage = false |
| bool | $initialCapital |
| Equivalent to $wgCapitalLinks (or $wgCapitalLinkOverrides[NS_FILE], determines whether filenames implicitly start with a capital letter. | |
| bool | $isPrivate |
| Whether all zones should be private (e.g. | |
| callable false | $oldFileFactory = false |
| Override these in the base class. | |
| callable false | $oldFileFactoryKey = false |
| Override these in the base class. | |
| 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. | |
| string null | $scriptDirUrl |
| URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g. | |
| bool | $supportsSha1URLs = false |
| string | $thumbProxySecret |
| Secret key to pass as an X-Swift-Secret header to the proxied thumb service. | |
| string | $thumbProxyUrl |
| URL of where to proxy thumb.php requests to. | |
| string | $thumbScriptUrl |
| URL of thumb.php. | |
| string false | $thumbUrl |
| The base thumbnail URL. | |
| bool | $transformVia404 |
| Whether to skip media file transformation on parse and rely on a 404 handler instead. | |
| string false | $url |
| Public zone URL. | |
| WANObjectCache | $wanCache |
| array | $zones = [] |
| Map of zones to config. | |
Base class for file repositories.
See the architecture doc for more information.
Definition at line 51 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::__construct | ( | ?array | $info = null | ) |
| array | null | $info |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 173 of file FileRepo.php.
References MediaWiki\FileRepo\FileRepo\$hashLevels, MediaWiki\MediaWikiServices\getInstance(), NS_FILE, and MediaWiki\FileRepo\FileRepo\supportsSha1URLs().
| MediaWiki\FileRepo\FileRepo::addShellboxInputFile | ( | BoxedCommand | $command, |
| string | $boxedName, | ||
| string | $virtualUrl ) |
Add a file to a Shellbox command as an input file.
| BoxedCommand | $command | |
| string | $boxedName | |
| string | $virtualUrl |
Definition at line 1622 of file FileRepo.php.
References $path.
|
protected |
Throw an exception if this repo is read-only by design.
This does not and should not check getReadOnlyReason().
| LogicException |
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo, MediaWiki\FileRepo\ForeignDBRepo, MediaWiki\FileRepo\ForeignDBViaLBRepo, and MediaWiki\FileRepo\NullRepo.
Definition at line 1972 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::backendSupportsUnicodePaths | ( | ) |
Definition at line 355 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::canTransformLocally | ( | ) |
Returns true if the repository can transform files locally.
Definition at line 715 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::canTransformVia404 | ( | ) |
Returns true if the repository can transform files via a 404 handler.
Definition at line 705 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::checkRedirect | ( | $title | ) |
Checks if there is a redirect named as $title.
If there is, return the title object. If not, return false. STUB
| PageIdentity | LinkTarget | $title | Title of image |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1840 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::cleanDir | ( | $dir | ) |
Deletes a directory if empty.
| string | $dir | Virtual URL (or storage path) of directory to clean |
Definition at line 1420 of file FileRepo.php.
| MediaWiki\FileRepo\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.
| string[] | $files | List of files to delete |
| int | $flags | Bitwise combination of the following flags: |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1012 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::cleanupDeletedBatch | ( | array | $storageKeys | ) |
Delete files in the deleted directory if they are not referenced in the filearchive table.
STUB
| string[] | $storageKeys |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1548 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::concatenate | ( | array | $srcPaths, |
| $dstPath, | |||
| $flags = 0 ) |
Concatenate a list of temporary files into a target file location.
| string[] | $srcPaths | Ordered list of source virtual URLs/storage paths |
| string | $dstPath | Target file system path |
| int | $flags | Bitwise combination of the following flags: self::DELETE_SOURCE Delete the source files on success |
Definition at line 1210 of file FileRepo.php.
References $source.
| MediaWiki\FileRepo\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
| mixed | $srcRel | Relative path for the file to be deleted |
| mixed | $archiveRel | Relative path for the archive location. Relative to a private archive directory. |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1471 of file FileRepo.php.
| MediaWiki\FileRepo\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.
| array | $sourceDestPairs | Array 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. |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1493 of file FileRepo.php.
| MediaWiki\FileRepo\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.
| callable | $callback |
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo.
Definition at line 1721 of file FileRepo.php.
|
protected |
Call a callback function for every public file in the repository.
May use either the database or the filesystem.
| callable | $callback |
Definition at line 1732 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::fileExists | ( | $file | ) |
Checks existence of a file.
| string | $file | Virtual URL (or storage path) of file to check |
Definition at line 1436 of file FileRepo.php.
Referenced by MediaWiki\Upload\UploadStashFile\__construct(), and PurgeChangedFiles\purgeFromArchiveTable().
| MediaWiki\FileRepo\FileRepo::fileExistsBatch | ( | array | $files | ) |
Checks existence of an array of files.
| string[] | $files | Virtual URLs (or storage paths) of files to check |
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo.
Definition at line 1449 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::findBySha1 | ( | $hash | ) |
Get an array or iterator of file objects for files that have a given SHA-1 content hash.
STUB
| string | $hash | SHA-1 hash |
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo, and MediaWiki\FileRepo\LocalRepo.
Definition at line 638 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::findBySha1s | ( | array | $hashes | ) |
Get an array of arrays or iterators of file objects for files that have the given SHA-1 content hashes.
| string[] | $hashes | An array of hashes |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 649 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::findFile | ( | $title, | |
| $options = [] ) |
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.
| PageIdentity | LinkTarget | string | $title | |
| array | $options | Associative 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 an Authority object, return restricted (deleted) files if the performer is allowed to view them. Otherwise, such files will not be found. If set and not an Authority object, throws an exception. Authority is only accepted since 1.37, User was required before. latest: If true, load from the latest available data into File objects |
| InvalidArgumentException |
Definition at line 466 of file FileRepo.php.
References NS_FILE.
| MediaWiki\FileRepo\FileRepo::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.
Repositories not supporting version control should return false if the time is specified.
| string | $sha1 | Base 36 SHA-1 hash |
| array | $options | Option array, same as findFile(). |
| InvalidArgumentException | if the private option is set and not an Authority object |
Definition at line 594 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::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 = [ 'title' => $title, 'private' => true ];
$findBatch = [ $findItem ];
$repo->findFiles( $findBatch );
|
| int | $flags | Supports:
|
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 549 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::findFilesByPrefix | ( | $prefix, | |
| $limit ) |
Return an array of files where the name starts with $prefix.
STUB
| string | $prefix | The prefix to search for |
| int | $limit | The maximum amount of files to return |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 669 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::freeTemp | ( | $virtualUrl | ) |
Remove a temporary file or mark it for garbage collection.
| string | $virtualUrl | The virtual URL returned by FileRepo::storeTemp() |
Definition at line 1188 of file FileRepo.php.
References wfDebug().
| MediaWiki\FileRepo\FileRepo::getBackend | ( | ) |
Get the file backend instance.
Use this function wisely.
Definition at line 253 of file FileRepo.php.
References MediaWiki\FileRepo\FileRepo\$backend.
Referenced by CleanupUploadStash\doOperations(), MediaWiki\FileRepo\ForeignAPIRepo\getThumbUrlFromCache(), and PurgeChangedFiles\purgeFromArchiveTable().
|
protected |
FileRepo is responsible for locking since there can be both file objects and metadata.
FileBackend::doOperations() Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 263 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getDeletedHashPath | ( | $key | ) |
Get a relative path for a deletion archive key, e.g.
s/z/a/ for sza251lrxrc1jad41h5mgilp8nysje52.jpg
| string | $key |
Definition at line 1559 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\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().
| string | $name | Name of image to fetch |
| string | null | $lang | Language to fetch it in, if any. |
Definition at line 872 of file FileRepo.php.
References wfAppendQuery(), and wfUrlencode().
| MediaWiki\FileRepo\FileRepo::getDescriptionStylesheetUrl | ( | ) |
Get the URL of the stylesheet to apply to description pages.
Definition at line 897 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getDescriptionUrl | ( | $name | ) |
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.
| string | $name |
Definition at line 838 of file FileRepo.php.
References wfUrlencode().
| MediaWiki\FileRepo\FileRepo::getDisplayName | ( | ) |
Get the human-readable name of the repo.
Definition at line 1859 of file FileRepo.php.
References wfMessageFallback().
Referenced by MediaWiki\FileRepo\ForeignAPIRepo\getThumbError().
| MediaWiki\FileRepo\FileRepo::getFileProps | ( | $virtualUrl | ) |
Get properties of a file with a given virtual URL/storage path.
Properties should ultimately be obtained via FSFile::getProps().
| string | $virtualUrl |
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo.
Definition at line 1637 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getFileSha1 | ( | $virtualUrl | ) |
Get the sha1 (base 36) of a file with a given virtual URL/storage path.
| string | $virtualUrl |
Definition at line 1679 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::getFileSize | ( | $virtualUrl | ) |
Get the size of a file with a given virtual URL/storage path.
| string | $virtualUrl |
Definition at line 1667 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::getFileTimestamp | ( | $virtualUrl | ) |
Get the timestamp of a file with a given virtual URL/storage path.
| string | $virtualUrl |
Definition at line 1655 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::getHashLevels | ( | ) |
| MediaWiki\FileRepo\FileRepo::getHashPath | ( | $name | ) |
Get a relative path including trailing slash, e.g.
f/fa/ If the repo is not hashed, returns an empty string
| string | $name | Name of file |
Definition at line 757 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\ForeignAPIRepo\getThumbUrlFromCache().
|
staticprotected |
| string | $name | |
| int | $levels |
Definition at line 779 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::getInfo | ( | ) |
Return information about the repository.
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo, and MediaWiki\FileRepo\ForeignDBViaLBRepo.
Definition at line 1981 of file FileRepo.php.
Referenced by MediaWiki\Api\ApiQueryFileRepoInfo\execute(), and MediaWiki\Api\ApiQueryFileRepoInfo\getProps().
| MediaWiki\FileRepo\FileRepo::getLocalCacheKey | ( | $kClassSuffix, | |
| $components ) |
Get a site-local, repository-qualified, WAN cache key.
These cache keys are not shared among different site context and thus cannot be directly invalidated when repo objects are modified. These are useful when there is no accessible global cache or the values depend on the current site context.
| string | $kClassSuffix | Key collection name suffix (added to this repo class) |
| mixed | ...$components Additional key components |
Definition at line 1921 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\ForeignAPIRepo\getThumbUrlFromCache().
| MediaWiki\FileRepo\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.
| string | $virtualUrl |
Definition at line 1593 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\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.
| string | $virtualUrl |
Definition at line 1607 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::getName | ( | ) |
Get the name of this repository, as specified by $info['name]' to the constructor.
Definition at line 807 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getNameFromTitle | ( | $title | ) |
Get the name of a file from its title.
| PageIdentity | LinkTarget | $title |
Definition at line 725 of file FileRepo.php.
References NS_FILE.
| MediaWiki\FileRepo\FileRepo::getReadOnlyReason | ( | ) |
Get an explanatory message if this repo is read-only.
Definition at line 273 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getRootDirectory | ( | ) |
Get the public zone root storage directory of the repository.
Definition at line 746 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getSharedCacheKey | ( | $kClassSuffix, | |
| $components ) |
Get a global, repository-qualified, WAN cache key.
This might be called from either the site context of the wiki that owns the repo or the site context of another wiki that simply has access to the repo. This returns false if the repository's cache is not accessible from the current site context.
| string | $kClassSuffix | Key collection name suffix (added to this repo class) |
| mixed | ...$components Additional key components |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1906 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getTempHashPath | ( | $suffix | ) |
Get a relative path including trailing slash, e.g.
f/fa/ If the repo is not hashed, returns an empty string
| string | $suffix | Basename of file from FileRepo::storeTemp() |
Definition at line 768 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getTempRepo | ( | ) |
Get a temporary private FileRepo associated with this repo.
Files will be created in the temp zone of this repo. It will have the same backend as this repo.
Reimplemented in MediaWiki\FileRepo\TempFileRepo.
Definition at line 1937 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getThumbProxySecret | ( | ) |
Get the secret key for the proxied thumb service.
Definition at line 696 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getThumbProxyUrl | ( | ) |
Get the URL thumb.php requests are being proxied to.
Definition at line 687 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getThumbScriptUrl | ( | ) |
| MediaWiki\FileRepo\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.
| string | false | $suffix |
Definition at line 309 of file FileRepo.php.
References $path.
Referenced by MediaWiki\Upload\UploadStashFile\__construct().
|
protected |
The storage container and base path of a zone.
| string | $zone |
Definition at line 393 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::getZonePath | ( | $zone | ) |
Get the storage path corresponding to one of the zones.
| string | $zone |
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo.
Definition at line 407 of file FileRepo.php.
Referenced by MediaWiki\Upload\UploadStashFile\__construct().
| MediaWiki\FileRepo\FileRepo::getZoneUrl | ( | $zone, | |
| $ext = null ) |
Get the URL corresponding to one of the four basic zones.
| string | $zone | One of: public, deleted, temp, thumb |
| string | null | $ext | Optional file extension |
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo.
Definition at line 325 of file FileRepo.php.
References $url.
| MediaWiki\FileRepo\FileRepo::hasSha1Storage | ( | ) |
Returns whether or not storage is SHA-1 based.
Definition at line 2017 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\LocalRepo\__construct().
|
protected |
Creates a directory with the appropriate zone permissions.
Callers are responsible for doing read-only and "writable repo" checks.
| string | $dir | Virtual URL (or storage path) of directory to clean |
Definition at line 1397 of file FileRepo.php.
References $path.
|
protected |
Ensure that a single zone or list of zones is defined for usage.
| string[] | string | $doZones | Only do a particular zones |
Definition at line 282 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::invalidateImageRedirect | ( | $title | ) |
Invalidates image redirect cache related to that image Doesn't do anything for repositories that don't support image redirects.
STUB
| PageIdentity | LinkTarget | $title | Title of image |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1851 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::isLocal | ( | ) |
Returns true if this the local file repository.
Definition at line 1891 of file FileRepo.php.
|
static |
Determine if a string is an mwrepo:// URL.
| string | $url |
Definition at line 297 of file FileRepo.php.
References $url.
Referenced by MediaWiki\FileRepo\RepoGroup\getFileProps().
| MediaWiki\FileRepo\FileRepo::makeUrl | ( | $query = '', | |
| $entry = 'index' ) |
Make an url to this repo.
| string | array | $query | Query string to append |
| string | $entry | Entry point; defaults to index |
Definition at line 818 of file FileRepo.php.
References wfAppendQuery().
Referenced by MediaWiki\FileRepo\ForeignAPIRepo\httpGetCached().
| MediaWiki\FileRepo\FileRepo::nameForThumb | ( | $name | ) |
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.
| string | $name |
Definition at line 1877 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::newFatal | ( | $message, | |
| $parameters ) |
Create a new fatal error.
| string | $message | |
| mixed | ...$parameters |
Definition at line 1812 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::newFile | ( | $title, | |
| $time = false ) |
Create a new File object from the local repository.
| PageIdentity | LinkTarget | string | $title | |
| string | false | $time | 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. |
Reimplemented in MediaWiki\FileRepo\ForeignAPIRepo.
Definition at line 431 of file FileRepo.php.
Referenced by FindOrphanedFiles\checkFiles().
| MediaWiki\FileRepo\FileRepo::newGood | ( | $value = null | ) |
Create a new good result.
| null | mixed | $value |
Definition at line 1825 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::paranoidClean | ( | $param | ) |
Path disclosure protection function.
| string | $param |
Definition at line 1791 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::passThrough | ( | $param | ) |
Path disclosure protection function.
| string | $param |
Definition at line 1801 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::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.
Returns a Status object. On success, the value contains "new" or "archived", to indicate whether the file was new with that name.
Using FSFile/TempFSFile can improve performance via caching. Using TempFSFile can further improve performance by signalling that it is safe to touch the source file or write extended attribute metadata to it directly.
Options to $options include:
| string | FSFile | $src | The source file system path, storage path, or URL |
| string | $dstRel | The destination relative path |
| string | $archiveRel | The relative path where the existing file is to be archived, if there is one. Relative to the public zone root. |
| int | $flags | Bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source file should be deleted if possible |
| array | $options | Optional additional parameters |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1263 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::publishBatch | ( | array | $ntuples, |
| $flags = 0 ) |
Publish a batch of files.
| array | $ntuples | (source, dest, archive) triplets or (source, dest, archive, options) 4-tuples as per publish(). |
| int | $flags | Bitfield, may be FileRepo::DELETE_SOURCE to indicate that the source files should be deleted if possible |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 1289 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::quickCleanDir | ( | $dir | ) |
Deletes a directory if empty.
This function can be used to write to otherwise read-only foreign repos.
| string | $dir | Virtual URL (or storage path) of directory to clean |
Definition at line 1127 of file FileRepo.php.
|
final |
Import a file from the local file system into the repo.
This does no locking 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.
Using FSFile/TempFSFile can improve performance via caching. Using TempFSFile can further improve performance by signalling that it is safe to touch the source file or write extended attribute metadata to it directly.
| string | FSFile | $src | Source file system path, storage path, or virtual URL |
| string | $dst | Virtual URL or storage path |
| array | string | null | $options | An 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) |
Definition at line 1054 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::quickImportBatch | ( | array | $triples | ) |
Import a batch of files from the local file system into the repo.
This does no locking 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.
| array | $triples | List of (source path or FSFile, destination path, disposition) |
Definition at line 1072 of file FileRepo.php.
|
final |
Purge a file from the repo.
This does no locking. This function can be used to write to otherwise read-only foreign repos. This is intended for purging thumbnails.
| string | $path | Virtual URL or storage path |
Definition at line 1116 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::quickPurgeBatch | ( | array | $paths | ) |
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 and is intended for purging thumbnails.
| string[] | $paths | List of virtual URLs or storage paths |
Definition at line 1143 of file FileRepo.php.
References $path.
|
protected |
If a path is a virtual URL, resolve it to a storage path.
Otherwise, just return the path as it is.
| string | $path |
Definition at line 1578 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::resolveVirtualUrl | ( | $url | ) |
Get the backend storage path corresponding to a virtual URL.
Callers are responsible of verifying that $url is a valid virtual URL. Use this function wisely.
| string | $url |
Definition at line 367 of file FileRepo.php.
References $url.
Referenced by MediaWiki\Upload\UploadStashFile\__construct().
| MediaWiki\FileRepo\FileRepo::store | ( | $srcPath, | |
| $dstZone, | |||
| $dstRel, | |||
| $flags = 0 ) |
Store a file to a given destination.
Using FSFile/TempFSFile can improve performance via caching. Using TempFSFile can further improve performance by signalling that it is safe to touch the source file or write extended attribute metadata to it directly.
| string | FSFile | $srcPath | Source file system path, storage path, or virtual URL |
| string | $dstZone | Destination zone |
| string | $dstRel | Destination relative path |
| int | $flags | Bitwise combination of the following flags: 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 |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 923 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::storeBatch | ( | array | $triplets, |
| $flags = 0 ) |
Store a batch of files.
| array | $triplets | (src, dest zone, dest rel) triplets as per store() |
| int | $flags | Bitwise combination of the following flags: 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 |
Reimplemented in MediaWiki\FileRepo\LocalRepo.
Definition at line 946 of file FileRepo.php.
References wfDebug().
| MediaWiki\FileRepo\FileRepo::storeTemp | ( | $originalName, | |
| $srcPath ) |
Pick a random name in the temp zone and store a file to it.
Returns a Status object with the file Virtual URL in the value, file can later be disposed using FileRepo::freeTemp().
| string | $originalName | The base name of the file as specified by the user. The file extension will be maintained. |
| string | $srcPath | The current location of the file. |
Definition at line 1168 of file FileRepo.php.
| MediaWiki\FileRepo\FileRepo::streamFileWithStatus | ( | $virtualUrl, | |
| $headers = [], | |||
| $optHeaders = [] ) |
Attempt to stream a file with the given virtual URL/storage path.
| string | $virtualUrl | |
| array | $headers | Additional HTTP headers to send on success |
| array | $optHeaders | HTTP request headers (if-modified-since, range, ...) |
Definition at line 1694 of file FileRepo.php.
References $path.
| MediaWiki\FileRepo\FileRepo::supportsSha1URLs | ( | ) |
Returns whether or not repo supports having originals SHA-1s in the thumb URLs.
Definition at line 2025 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\FileRepo\__construct().
| MediaWiki\FileRepo\FileRepo::validateFilename | ( | $filename | ) |
Determine if a relative path is valid, i.e.
not blank or involving directory traversal
| string | $filename |
Definition at line 1760 of file FileRepo.php.
Referenced by MediaWiki\Upload\UploadStashFile\__construct(), and MediaWiki\FileRepo\ForeignAPIRepo\getThumbUrlFromCache().
|
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 131 of file FileRepo.php.
|
protected |
Equivalent to $wgArticlePath, e.g.
https://en.wikipedia.org/wiki/$1
Definition at line 99 of file FileRepo.php.
|
protected |
Definition at line 75 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\FileRepo\getBackend(), and MediaWiki\FileRepo\ForeignAPIRepo\getThumbUrlFromCache().
|
protected |
The number of directory levels for hash-based division of deleted files.
Definition at line 125 of file FileRepo.php.
|
protected |
URL of image description pages, e.g.
https://en.wikipedia.org/wiki/File:
Definition at line 91 of file FileRepo.php.
| int MediaWiki\FileRepo\FileRepo::$descriptionCacheExpiry |
Definition at line 66 of file FileRepo.php.
|
protected |
Disable local image scaling.
Definition at line 156 of file FileRepo.php.
|
protected |
The URL to a favicon (optional, may be a server-local path URL).
Definition at line 134 of file FileRepo.php.
| bool MediaWiki\FileRepo\FileRepo::$fetchDescription |
Whether to fetch commons image description pages and display them on the local wiki.
Definition at line 63 of file FileRepo.php.
|
protected |
Override these in the base class.
Definition at line 140 of file FileRepo.php.
|
protected |
Override these in the base class.
Definition at line 144 of file FileRepo.php.
|
protected |
The number of directory levels for hash-based division of files.
Definition at line 122 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\FileRepo\__construct().
|
protected |
Definition at line 69 of file FileRepo.php.
|
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 106 of file FileRepo.php.
|
protected |
Whether all zones should be private (e.g.
private wiki repo)
Definition at line 137 of file FileRepo.php.
| string MediaWiki\FileRepo\FileRepo::$name |
Definition at line 166 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\ForeignAPIRepo\getThumbError(), and MediaWiki\FileRepo\ForeignAPIRepo\getThumbUrlFromCache().
|
protected |
Override these in the base class.
Definition at line 142 of file FileRepo.php.
|
protected |
Override these in the base class.
Definition at line 146 of file FileRepo.php.
|
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 113 of file FileRepo.php.
|
protected |
URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g.
Definition at line 96 of file FileRepo.php.
|
protected |
Definition at line 72 of file FileRepo.php.
|
protected |
Secret key to pass as an X-Swift-Secret header to the proxied thumb service.
Definition at line 153 of file FileRepo.php.
|
protected |
URL of where to proxy thumb.php requests to.
Example: http://127.0.0.1:8888/wiki/dev/thumb/
Definition at line 151 of file FileRepo.php.
|
protected |
URL of thumb.php.
Definition at line 81 of file FileRepo.php.
|
protected |
The base thumbnail URL.
Defaults to "<url>/thumb".
Definition at line 119 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\ForeignAPIRepo\getZoneUrl().
|
protected |
Whether to skip media file transformation on parse and rely on a 404 handler instead.
Definition at line 86 of file FileRepo.php.
|
protected |
Public zone URL.
Definition at line 116 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\ForeignAPIRepo\getZoneUrl(), MediaWiki\FileRepo\ForeignAPIRepo\httpGet(), and MediaWiki\FileRepo\ForeignAPIRepo\httpGetCached().
|
protected |
Definition at line 159 of file FileRepo.php.
|
protected |
Map of zones to config.
Definition at line 78 of file FileRepo.php.
| const MediaWiki\FileRepo\FileRepo::DELETE_SOURCE = 1 |
Definition at line 52 of file FileRepo.php.
| const MediaWiki\FileRepo\FileRepo::NAME_AND_TIME_ONLY = 1 |
Definition at line 58 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\LocalRepo\findFiles().
| const MediaWiki\FileRepo\FileRepo::OVERWRITE = 2 |
Definition at line 53 of file FileRepo.php.
| const MediaWiki\FileRepo\FileRepo::OVERWRITE_SAME = 4 |
Definition at line 54 of file FileRepo.php.
Referenced by MediaWiki\FileRepo\File\LocalFileMoveBatch\execute(), and MediaWiki\FileRepo\File\LocalFileRestoreBatch\execute().
| const MediaWiki\FileRepo\FileRepo::SKIP_LOCKING = 8 |
Definition at line 56 of file FileRepo.php.