MediaWiki
1.30.2
|
UploadStash is intended to accomplish a few things: More...
Public Member Functions | |
__construct (FileRepo $repo, $user=null) | |
Represents a temporary filestore, with metadata in the database. More... | |
clear () | |
Remove all files from the stash. More... | |
getFile ( $key, $noAuth=false) | |
Get a file and its metadata from the stash. More... | |
getFileProps ( $key) | |
Getter for fileProps. More... | |
getMetadata ( $key) | |
Getter for file metadata. More... | |
listFiles () | |
List all files in the stash. More... | |
removeFile ( $key) | |
Remove a particular file from the stash. More... | |
removeFileNoAuth ( $key) | |
Remove a file (see removeFile), but doesn't check ownership first. More... | |
stashFile ( $path, $sourceType=null) | |
Stash a file in a temp directory and record that we did this in the database, along with other metadata. More... | |
Static Public Member Functions | |
static | getExtensionForPath ( $path) |
Find or guess extension – ensuring that our extension matches our MIME type. More... | |
Public Attributes | |
$isLoggedIn | |
LocalRepo | $repo |
repository that this uses to store temp files public because we sometimes need to get a LocalFile within the same repo. More... | |
$userId | |
const | KEY_FORMAT_REGEX = '/^[\w-\.]+\.\w*$/' |
const | MAX_US_PROPS_SIZE = 65535 |
Protected Member Functions | |
fetchFileMetadata ( $key, $readFromDB=DB_REPLICA) | |
Helper function: do the actual database query to fetch file metadata. More... | |
initFile ( $key) | |
Helper function: Initialize the UploadStashFile for a given file. More... | |
Protected Attributes | |
$fileMetadata = [] | |
$fileProps = [] | |
$files = [] | |
$user | |
UploadStash is intended to accomplish a few things:
UploadStash right now is mostly intended to show you one user's slice of the entire stash. The user parameter is only optional because there are few cases where we clean out the stash from an automated script. In the future we might refactor this.
UploadStash represents the entire stash of temporary files. UploadStashFile is a filestore for the actual physical disk files. UploadFromStash extends UploadBase, and represents a single stashed file as it is moved from the stash to the regular file repository
Definition at line 54 of file UploadStash.php.
UploadStash::__construct | ( | FileRepo | $repo, |
$user = null |
|||
) |
Represents a temporary filestore, with metadata in the database.
Designed to be compatible with the session stashing code in UploadBase (should replace it eventually).
Definition at line 87 of file UploadStash.php.
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 333 of file UploadStash.php.
|
protected |
|
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 |
UploadStashFileException |
Definition at line 466 of file UploadStash.php.
References $path, $wgFileBlacklist, captcha-old\count, global, File\normalizeExtension(), and MimeMagic\singleton().
Referenced by stashFile().
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 | Key under which file information is stored |
bool | $noAuth | (optional) Don't check authentication. Used by maintenance scripts. |
UploadStashFileNotFoundException | |
UploadStashNotLoggedInException | |
UploadStashWrongOwnerException | |
UploadStashBadPathException |
Definition at line 119 of file UploadStash.php.
References $path, DB_MASTER, fetchFileMetadata(), files, initFile(), unserialize(), and wfDebug().
Referenced by getFileProps(), getMetadata(), removeFileNoAuth(), and stashFile().
UploadStash::getFileProps | ( | $key | ) |
Getter for fileProps.
string | $key | Key under which file information is stored |
Definition at line 187 of file UploadStash.php.
References getFile().
UploadStash::getMetadata | ( | $key | ) |
Getter for file metadata.
string | $key | Key under which file information is stored |
Definition at line 175 of file UploadStash.php.
References getFile().
|
protected |
Helper function: Initialize the UploadStashFile for a given file.
string | $key | Key under which to store the object |
UploadStashZeroLengthFileException |
Definition at line 541 of file UploadStash.php.
References files.
Referenced by getFile(), and stashFile().
UploadStash::listFiles | ( | ) |
List all files in the stash.
UploadStashNotLoggedInException |
Definition at line 428 of file UploadStash.php.
UploadStash::removeFile | ( | $key | ) |
Remove a particular file from the stash.
Also removes it from the repo.
string | $key |
UploadStashNoSuchKeyException|UploadStashNotLoggedInException | |
UploadStashWrongOwnerException |
Definition at line 362 of file UploadStash.php.
References removeFileNoAuth().
UploadStash::removeFileNoAuth | ( | $key | ) |
Remove a file (see removeFile), but doesn't check ownership first.
string | $key |
Definition at line 397 of file UploadStash.php.
References files, getFile(), and wfDebug().
Referenced by removeFile().
UploadStash::stashFile | ( | $path, | |
$sourceType = 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 | $sourceType | The type of upload that generated this file (currently, I believe, 'file' or null) |
Definition at line 205 of file UploadStash.php.
References $fileProps, $path, $userId, captcha-old\count, getExtensionForPath(), getFile(), initFile(), list, serialize(), MimeMagic\singleton(), text, wfDebug(), and wfMessage().
|
protected |
Definition at line 71 of file UploadStash.php.
|
protected |
Definition at line 74 of file UploadStash.php.
Referenced by stashFile().
|
protected |
Definition at line 68 of file UploadStash.php.
UploadStash::$isLoggedIn |
Definition at line 77 of file UploadStash.php.
LocalRepo 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 65 of file UploadStash.php.
Referenced by __construct().
|
protected |
Definition at line 77 of file UploadStash.php.
Referenced by __construct().
UploadStash::$userId |
Definition at line 77 of file UploadStash.php.
Referenced by stashFile().
Definition at line 56 of file UploadStash.php.
Referenced by UploadFromStash\isValidKey().
const UploadStash::MAX_US_PROPS_SIZE = 65535 |
Definition at line 57 of file UploadStash.php.