40 $this->fileKey = $key;
43// resolve mwrepo:// urls 44if ( FileRepo::isVirtualUrl(
$path ) ) {
47// check if path appears to be correct, no parent traversals, 48// and is in this repo's temp zone. 51 !str_starts_with(
$path, $repoTempPath )
53wfDebug(
"UploadStash: tried to construct an UploadStashFile " 54 .
"from a file that should already exist at '$path', but path is not valid" );
60// check if path exists! and is a plain file. 62wfDebug(
"UploadStash: tried to construct an UploadStashFile from " 63 .
"a file that should already exist at '$path', but path is not found" );
65wfMessage(
'uploadstash-file-not-found-not-exists' )
72 $this->name = basename( $this->path );
83 $this->sha1 = parent::getSha1();
111$path = dirname( $this->path );
112if ( $thumbName !==
false ) {
113$path .=
"/$thumbName";
138privatefunction getSpecialUrl( $subPage ) {
139return SpecialPage::getTitleFor(
'UploadStash', $subPage )->getLocalURL();
153wfDebug( __METHOD__ .
" getting for $thumbName" );
155return $this->getSpecialUrl(
'thumb/' . $this->
getUrlName() .
'/' . $thumbName );
165if ( !$this->urlName ) {
166 $this->urlName = $this->fileKey;
169return $this->urlName;
179if ( $this->url ===
null ) {
180 $this->url = $this->getSpecialUrl(
'file/' . $this->
getUrlName() );
204return $this->fileKey;
211publicfunctionremove() {
212if ( !$this->repo->fileExists( $this->path ) ) {
213// Maybe the file's already been removed? This could totally happen in UploadBase. 217return $this->repo->freeTemp( $this->path );
222return $this->repo->fileExists( $this->path );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Base class for file repositories.
resolveVirtualUrl( $url)
Get the backend storage path corresponding to a virtual URL.
fileExists( $file)
Checks existence of a file.
getZonePath( $zone)
Get the storage path corresponding to one of the zones.
validateFilename( $filename)
Determine if a relative path is valid, i.e.
FileRepo LocalRepo ForeignAPIRepo false $repo
Some member variables can be lazy-initialised using __get().
generateThumbName( $name, $params)
Generate a thumbnail file name from a name and specified parameters.
File without associated database record.
Local repository that stores files in the local filesystem and registers them in the wiki's own datab...
Parent class for all special pages.
__construct( $repo, $path, $key, $sha1=null, $mime=false)
A LocalFile wrapper around a file that has been temporarily stashed, so we can do things like create ...
exists()
Returns true if file exists in the repository.Overridden by LocalFile to avoid unnecessary stat calls...
getThumbPath( $thumbName=false)
Get the path for the thumbnail (actually any transformation of this file) The actual argument is the ...
getDescriptionUrl()
A method needed by the file transforming and scaling routines in File.php We do not necessarily care ...
getUrl()
Return the URL of the file, if for some reason we wanted to download it We tend not to do this for th...
string null $url
Lazy set as in-memory cache.
getThumbUrl( $thumbName=false)
Get a URL to access the thumbnail This is required because the model of how files work requires that ...
getFullUrl()
Parent classes use this method, for no obvious reason, to return the path (relative to wiki root,...
getUrlName()
The basename for the URL, which we want to not be related to the filename.
getSha1()
Get the SHA-1 base 36 hash.
getFileKey()
Getter for file key (the unique id by which this file's location & metadata is stored in the db)
thumbName( $params, $flags=0)
Return the file/url base name of a thumbnail with the specified parameters.