|
MediaWiki master
|
UploadStash provides temporary file storage for users, persisting across multiple requests. More...

Public Member Functions | |
| __construct (LocalRepo $repo, ?UserIdentity $user=null) | |
| clear () | |
| Remove all files from the stash. | |
| getFile ( $key, $noAuth=false) | |
| Get a file and its metadata from the stash. | |
| getFileProps ( $key) | |
| Get file properties. | |
| getMetadata ( $key) | |
| Get file metadata. | |
| listFiles () | |
| List all files in the stash. | |
| removeFile ( $key) | |
| Remove a particular file from the stash and the repo. | |
| removeFileNoAuth ( $key) | |
| Remove a file, but doesn't check ownership first. | |
| stashFile ( $path, $sourceType=null, $fileProps=null) | |
| Stash a file in a temp directory and record that we did this in the database, along with other metadata. | |
Static Public Member Functions | |
| static | getExtensionForPath ( $path) |
| Find or guess extension, ensuring that our extension matches our MIME type. | |
Public Attributes | |
| LocalRepo | $repo |
| Repository that this uses to store temp files. | |
| const | KEY_FORMAT_REGEX = '/^[\w\-\.]+\.\w*$/' |
Protected Member Functions | |
| fetchFileMetadata ( $key, $readFromDB=DB_REPLICA) | |
| Helper function: do the actual database query to fetch file metadata. | |
| initFile ( $key) | |
| Helper function: Initialize the UploadStashFile for a given file. | |
Protected Attributes | |
| array | $fileMetadata = [] |
| Cache of uploadstash rows indexed by stash key. | |
| array | $fileProps = [] |
| Cache of unserialized file properties (us_props) indexed by stash key. | |
| UploadStashFile[] | $files = [] |
| Array of initialized file objects. | |
UploadStash provides temporary file storage for users, persisting across multiple requests.
Files are stored in FileRepo and tracked in the database.
Stashed files are private. Read access is only provided to the creator.
Definition at line 36 of file UploadStash.php.
| MediaWiki\Upload\UploadStash::__construct | ( | LocalRepo | $repo, |
| ?UserIdentity | $user = null ) |
| LocalRepo | $repo | The repo to use for file storage |
| UserIdentity | null | $user | The user whose stash this is, or null to use the request context user |
Definition at line 66 of file UploadStash.php.
References MediaWiki\Upload\UploadStash\$repo.
| MediaWiki\Upload\UploadStash::clear | ( | ) |
Remove all files from the stash.
Does not clean up files in the repo, just the record of them.
| UploadStashNotLoggedInException |
Definition at line 297 of file UploadStash.php.
References wfDebug(), and wfMessage().
|
protected |
Helper function: do the actual database query to fetch file metadata.
| string | $key | |
| int | $readFromDB | Constant (default: DB_REPLICA) |
Definition at line 449 of file UploadStash.php.
References DB_PRIMARY.
Referenced by MediaWiki\Upload\UploadStash\getFile().
|
static |
Find or guess extension, ensuring that our extension matches our MIME type.
Since these files are constructed from PHP tempnames they may not start off with an extension.
XXX this is somewhat redundant with the checks that ApiUpload.php does with incoming uploads versus the desired filename. Maybe we can get that passed to us...
| string | $path |
Definition at line 416 of file UploadStash.php.
References $path, MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\MainConfigNames\ProhibitedFileExtensions.
Referenced by MediaWiki\Upload\UploadStash\stashFile().
| MediaWiki\Upload\UploadStash::getFile | ( | $key, | |
| $noAuth = false ) |
Get a file and its metadata from the stash.
The noAuth param is a bit janky but is required for automated scripts which clean out the stash.
| string | $key | The stash key from UploadStashFile::getFileKey() |
| bool | $noAuth | (optional) Don't check authentication. Used by maintenance scripts. |
| UploadStashNotLoggedInException | |
| UploadStashWrongOwnerException | |
| UploadStashBadPathException | |
| UploadStashFileNotFoundException |
Definition at line 84 of file UploadStash.php.
References $path, DB_PRIMARY, MediaWiki\Upload\UploadStash\fetchFileMetadata(), MediaWiki\Upload\UploadStash\initFile(), wfDebug(), and wfMessage().
Referenced by MediaWiki\Upload\UploadStash\getFileProps(), MediaWiki\Upload\UploadStash\getMetadata(), MediaWiki\Upload\UploadStash\removeFileNoAuth(), and MediaWiki\Upload\UploadStash\stashFile().
| MediaWiki\Upload\UploadStash::getFileProps | ( | $key | ) |
Get file properties.
| string | $key | The stash key |
Definition at line 154 of file UploadStash.php.
References MediaWiki\Upload\UploadStash\getFile().
| MediaWiki\Upload\UploadStash::getMetadata | ( | $key | ) |
Get file metadata.
| string | $key | The stash key |
Definition at line 142 of file UploadStash.php.
References MediaWiki\Upload\UploadStash\getFile().
|
protected |
Helper function: Initialize the UploadStashFile for a given file.
| string | $key | Key under which to store the object |
| UploadStashZeroLengthFileException |
Definition at line 485 of file UploadStash.php.
Referenced by MediaWiki\Upload\UploadStash\getFile(), and MediaWiki\Upload\UploadStash\stashFile().
| MediaWiki\Upload\UploadStash::listFiles | ( | ) |
List all files in the stash.
| UploadStashNotLoggedInException |
Definition at line 390 of file UploadStash.php.
References wfMessage().
| MediaWiki\Upload\UploadStash::removeFile | ( | $key | ) |
Remove a particular file from the stash and the repo.
| string | $key |
| UploadStashWrongOwnerException | |
| UploadStashNoSuchKeyException|UploadStashNotLoggedInException |
Definition at line 326 of file UploadStash.php.
References MediaWiki\Upload\UploadStash\removeFileNoAuth(), and wfMessage().
| MediaWiki\Upload\UploadStash::removeFileNoAuth | ( | $key | ) |
Remove a file, but doesn't check ownership first.
| string | $key |
Definition at line 363 of file UploadStash.php.
References $success, MediaWiki\Upload\UploadStash\getFile(), and wfDebug().
Referenced by MediaWiki\Upload\UploadStash\removeFile().
| MediaWiki\Upload\UploadStash::stashFile | ( | $path, | |
| $sourceType = null, | |||
| $fileProps = null ) |
Stash a file in a temp directory and record that we did this in the database, along with other metadata.
| string | $path | Path to file you want stashed |
| string | null | $sourceType | The source type from UploadBase::getSourceType() |
| array | null | $fileProps | File props or null to regenerate |
| UploadStashFileException | |
| UploadStashNotLoggedInException | |
| UploadStashBadPathException | |
| UploadStashZeroLengthFileException |
Definition at line 173 of file UploadStash.php.
References MediaWiki\Upload\UploadStash\$fileProps, $path, MediaWiki\Upload\UploadStash\getExtensionForPath(), MediaWiki\Upload\UploadStash\getFile(), MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Upload\UploadStash\initFile(), wfDebug(), and wfMessage().
|
protected |
Cache of uploadstash rows indexed by stash key.
Definition at line 53 of file UploadStash.php.
|
protected |
Cache of unserialized file properties (us_props) indexed by stash key.
Definition at line 56 of file UploadStash.php.
Referenced by MediaWiki\Upload\UploadStash\stashFile().
|
protected |
Array of initialized file objects.
Definition at line 50 of file UploadStash.php.
| LocalRepo MediaWiki\Upload\UploadStash::$repo |
Repository that this uses to store temp files.
Public because we sometimes need to get a LocalFile within the same repo.
Definition at line 47 of file UploadStash.php.
Referenced by MediaWiki\Upload\UploadStash\__construct().
| const MediaWiki\Upload\UploadStash::KEY_FORMAT_REGEX = '/^[\w\-\.]+\.\w*$/' |
Definition at line 38 of file UploadStash.php.
Referenced by MediaWiki\Upload\UploadFromStash\isValidKey().