MediaWiki  1.23.1
UploadBase Class Reference
Inheritance diagram for UploadBase:

Public Member Functions

 __construct ()
 
 checkSvgScriptCallback ( $element, $attribs)
 
 checkWarnings ()
 Check for non fatal problems with the file. More...
 
 cleanupTempFile ()
 If we've modified the upload file we need to manually remove it on exit to clean up. More...
 
 convertVerifyErrorToStatus ( $error)
 
 fetchFile ()
 Fetch the file. More...
 
 getFileSize ()
 Return the file size. More...
 
 getImageInfo ( $result)
 Gets image info about the file just uploaded. More...
 
 getLocalFile ()
 Return the local file and initializes if necessary. More...
 
 getRealPath ( $srcPath)
 
 getSourceType ()
 Returns the upload type. More...
 
 getTempFileSha1Base36 ()
 Get the base 36 SHA1 of the file. More...
 
 getTempPath ()
 
 getTitle ()
 Returns the title of the file to be uploaded. More...
 
 getVerificationErrorCode ( $error)
 
 initializeFromRequest (&$request)
 Initialize from a WebRequest. More...
 
 initializePathInfo ( $name, $tempPath, $fileSize, $removeTempFile=false)
 Initialize the path information. More...
 
 isEmptyFile ()
 Return true if the file is empty. More...
 
 performUpload ( $comment, $pageText, $watch, $user)
 Really perform the upload. More...
 
 stashFile (User $user=null)
 If the user does not supply all necessary information in the first upload form submission (either by accident or by design) then we may want to stash the file temporarily, get more information, and publish the file later. More...
 
 stashFileGetKey ()
 Stash a file in a temporary directory, returning a key which can be used to find the file again. More...
 
 stashSession ()
 alias for stashFileGetKey, for backwards compatibility More...
 
 validateName ()
 Verify that the name is valid and, if necessary, that we can overwrite. More...
 
 verifyPermissions ( $user)
 Alias for verifyTitlePermissions. More...
 
 verifyTitlePermissions ( $user)
 Check whether the user can edit, upload and create the image. More...
 
 verifyUpload ()
 Verify whether the upload is sane. More...
 
 zipEntryCallback ( $entry)
 Callback for ZipDirectoryReader to detect Java class files. More...
 

Static Public Member Functions

static checkFileExtension ( $ext, $list)
 Perform case-insensitive match against a list of file extensions. More...
 
static checkFileExtensionList ( $ext, $list)
 Perform case-insensitive match against a list of file extensions. More...
 
static checkSvgPICallback ( $target, $data)
 Callback to filter SVG Processing Instructions. More...
 
static checkXMLEncodingMissmatch ( $file)
 Check a whitelist of xml encodings that are known not to be interpreted differently by the server's xml parser (expat) and some common browsers. More...
 
static createFromRequest (&$request, $type=null)
 Create a form of UploadBase depending on wpSourceType and initializes it. More...
 
static detectScript ( $file, $mime, $extension)
 Heuristic for detecting files that could contain JavaScript instructions or things that may look like HTML to a browser and are thus potentially harmful. More...
 
static detectVirus ( $file)
 Generic wrapper function for a virus scanner program. More...
 
static getExistsWarning ( $file)
 Helper function that does various existence checks for a file. More...
 
static getFilenamePrefixBlacklist ()
 Get a list of blacklisted filename prefixes from [[MediaWiki:Filename-prefix-blacklist]]. More...
 
static getMaxUploadSize ( $forType=null)
 
static getSessionStatus ( $statusKey)
 Get the current status of a chunked upload (used for polling). More...
 
static isAllowed ( $user)
 Returns true if the user can use this upload module or else a string identifying the missing permission. More...
 
static isEnabled ()
 Returns true if uploads are enabled. More...
 
static isThumbName ( $filename)
 Helper function that checks whether the filename looks like a thumbnail. More...
 
static isValidRequest ( $request)
 Check whether a request if valid for this handler. More...
 
static setSessionStatus ( $statusKey, $value)
 Set the current status of a chunked upload (used for polling). More...
 
static splitExtensions ( $filename)
 Split a file into a base name and all dot-delimited 'extensions' on the end. More...
 
static userCanReUpload (User $user, $img)
 Check if a user is the last uploader. More...
 
static verifyExtension ( $mime, $extension)
 Checks if the mime type of the uploaded file matches the file extension. More...
 

Public Attributes

 $mDestName
 
 $mFileProps
 
 $mFileSize
 
 $mFinalExtension
 
 $mRemoveTempFile
 
 $mSourceType
 
 $mSVGNSError
 
 $mTitleError = 0
 
const EMPTY_FILE = 3
 
const FILE_TOO_LARGE = 12
 
const FILENAME_TOO_LONG = 14
 
const FILETYPE_BADTYPE = 9
 
const FILETYPE_MISSING = 8
 
const HOOK_ABORTED = 11
 
const ILLEGAL_FILENAME = 5
 
const MIN_LENGTH_PARTNAME = 4
 
const OK = 0
 
const OVERWRITE_EXISTING_FILE = 7
 
const SESSION_STATUS_KEY = 'wsUploadStatusData'
 
const SUCCESS = 0
 
const UPLOAD_VERIFICATION_ERROR = 11
 
const VERIFICATION_ERROR = 10
 
const WINDOWS_NONASCII_FILENAME = 13
 

Static Public Attributes

static $uploadHandlers = array( 'Stash', 'File', 'Url' )
 

Protected Member Functions

 detectScriptInSvg ( $filename)
 
 verifyFile ()
 Verifies that it's ok to include the uploaded file. More...
 
 verifyMimeType ( $mime)
 Verify the mime type. More...
 
 verifyPartialFile ()
 A verification routine suitable for partial files. More...
 

Protected Attributes

 $mBlackListedExtensions
 
 $mDesiredDestName
 
 $mFilteredName
 
 $mJavaDetected
 
 $mLocalFile
 
 $mTempPath
 
 $mTitle = false
 

Static Protected Attributes

static $safeXmlEncodings = array( 'UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'UTF-16', 'UTF-32' )
 

Private Member Functions

 checkOverwrite ( $user)
 Check if there's an overwrite conflict and, if so, if restrictions forbid this user from performing the upload. More...
 
 stripXmlNamespace ( $name)
 

Static Private Member Functions

static splitXmlNamespace ( $element)
 Divide the element name passed by the xml parser to the callback into URI and prifix. More...
 

Detailed Description

UploadBase and subclasses are the backend of MediaWiki's file uploads. The frontends are formed by ApiUpload and SpecialUpload.

Author
Brion Vibber
Bryan Tong Minh
Michael Dale

Definition at line 38 of file UploadBase.php.

Constructor & Destructor Documentation

◆ __construct()

UploadBase::__construct ( )

Definition at line 182 of file UploadBase.php.

Member Function Documentation

◆ checkFileExtension()

static UploadBase::checkFileExtension (   $ext,
  $list 
)
static

Perform case-insensitive match against a list of file extensions.

Returns true if the extension is in the list.

Parameters
$extString
$listArray
Returns
Boolean

Definition at line 916 of file UploadBase.php.

References $ext.

Referenced by checkWarnings(), getTitle(), and verifyMimeType().

◆ checkFileExtensionList()

static UploadBase::checkFileExtensionList (   $ext,
  $list 
)
static

Perform case-insensitive match against a list of file extensions.

Returns an array of matching extensions.

Parameters
$extArray
$listArray
Returns
Boolean

Definition at line 928 of file UploadBase.php.

References $ext.

Referenced by StreamFile\contentTypeFromPath(), and getTitle().

◆ checkOverwrite()

UploadBase::checkOverwrite (   $user)
private

Check if there's an overwrite conflict and, if so, if restrictions forbid this user from performing the upload.

Parameters
$userUser
Returns
mixed true on success, array on failure

Definition at line 1497 of file UploadBase.php.

Referenced by verifyTitlePermissions().

◆ checkSvgPICallback()

static UploadBase::checkSvgPICallback (   $target,
  $data 
)
static

Callback to filter SVG Processing Instructions.

Parameters
$targetstring processing instruction name
$datastring processing instruction attribute and value
Returns
bool (true if the filter identified something bad)

Definition at line 1198 of file UploadBase.php.

◆ checkSvgScriptCallback()

UploadBase::checkSvgScriptCallback (   $element,
  $attribs 
)
Todo:
Replace this with a whitelist filter!
Parameters
$elementstring
$attribsarray
Returns
bool

Definition at line 1212 of file UploadBase.php.

References $attribs, $matches, $value, array(), as, list, splitXmlNamespace(), stripXmlNamespace(), and wfDebug().

◆ checkWarnings()

UploadBase::checkWarnings ( )

Check for non fatal problems with the file.

This should not assume that mTempPath is set.

Returns
Array of warnings

Reimplemented in UploadFromUrl.

Definition at line 598 of file UploadBase.php.

References $extensions, $hash, $title, $wgFileExtensions, $wgLang, array(), as, Title\capitalize(), checkFileExtension(), File\DELETED_FILE, getExistsWarning(), getLocalFile(), getTempFileSha1Base36(), getTitle(), global, NS_FILE, RepoGroup\singleton(), wfDebugLog(), wfProfileIn(), and wfProfileOut().

◆ checkXMLEncodingMissmatch()

static UploadBase::checkXMLEncodingMissmatch (   $file)
static

Check a whitelist of xml encodings that are known not to be interpreted differently by the server's xml parser (expat) and some common browsers.

Parameters
string$filepathname to the temporary upload file
Returns
Boolean: true if the file contains an encoding that could be misinterpreted

Definition at line 1120 of file UploadBase.php.

References $file, $matches, array(), as, global, wfDebug(), wfRestoreWarnings(), and wfSuppressWarnings().

◆ cleanupTempFile()

UploadBase::cleanupTempFile ( )

If we've modified the upload file we need to manually remove it on exit to clean up.

Definition at line 882 of file UploadBase.php.

References wfDebug().

◆ convertVerifyErrorToStatus()

UploadBase::convertVerifyErrorToStatus (   $error)
Parameters
$errorarray
Returns
Status

Definition at line 1709 of file UploadBase.php.

References $error, getVerificationErrorCode(), and Status\newFatal().

◆ createFromRequest()

static UploadBase::createFromRequest ( $request,
  $type = null 
)
static

Create a form of UploadBase depending on wpSourceType and initializes it.

Parameters
$requestWebRequest
$type
Returns
null

Definition at line 136 of file UploadBase.php.

References $type, array(), wfDebug(), and wfRunHooks().

Referenced by SpecialUpload\loadRequest().

◆ detectScript()

static UploadBase::detectScript (   $file,
  $mime,
  $extension 
)
static

Heuristic for detecting files that could contain JavaScript instructions or things that may look like HTML to a browser and are thus potentially harmful.

The present implementation will produce false positives in some situations.

Parameters
string$filepathname to the temporary upload file
string$mimethe mime type of the file
string$extensionthe extension of the file
Returns
Boolean: true if the file contains something looking like embedded scripts

Definition at line 987 of file UploadBase.php.

References $file, $mime, array(), as, Sanitizer\decodeCharReferences(), global, in, wfDebug(), wfProfileIn(), and wfProfileOut().

◆ detectScriptInSvg()

UploadBase::detectScriptInSvg (   $filename)
protected
Parameters
$filenamestring
Returns
mixed false of the file is verified (does not contain scripts), array otherwise.

Definition at line 1172 of file UploadBase.php.

References array().

Referenced by verifyPartialFile().

◆ detectVirus()

static UploadBase::detectVirus (   $file)
static

Generic wrapper function for a virus scanner program.

This relies on the $wgAntivirus and $wgAntivirusSetup variables. $wgAntivirusRequired may be used to deny upload if the scan fails.

Parameters
string$filepathname to the temporary upload file
Returns
mixed false if not virus is found, NULL if the scan fails or is disabled, or a string containing feedback from the virus scanner if a virus was found. If textual feedback is missing but a virus was found, this function returns true.

Definition at line 1400 of file UploadBase.php.

References $command, $file, $output, $wgOut, array(), AV_NO_VIRUS, AV_SCAN_ABORTED, AV_SCAN_FAILED, global, there, wfDebug(), wfEscapeShellArg(), wfMessage(), wfProfileIn(), wfProfileOut(), and wfShellExecWithStderr().

Referenced by verifyPartialFile().

◆ fetchFile()

UploadBase::fetchFile ( )

Fetch the file.

Usually a no-op

Returns
Status

Definition at line 221 of file UploadBase.php.

References Status\newGood().

◆ getExistsWarning()

static UploadBase::getExistsWarning (   $file)
static

Helper function that does various existence checks for a file.

The following checks are performed:

  • The file exists
  • Article with the same name as the file exists
  • File exists with normalized extension
  • The file looks like a thumbnail and the original exists
Parameters
$fileFile The File object to check
Returns
mixed False if the file does not exists, else an array

Definition at line 1554 of file UploadBase.php.

Referenced by checkWarnings(), and ApiQueryImageInfo\getInfo().

◆ getFilenamePrefixBlacklist()

static UploadBase::getFilenamePrefixBlacklist ( )
static

Get a list of blacklisted filename prefixes from [[MediaWiki:Filename-prefix-blacklist]].

Returns
array list of prefixes

Definition at line 1659 of file UploadBase.php.

References $comment, $line, $lines, array(), as, and wfMessage().

◆ getFileSize()

UploadBase::getFileSize ( )

Return the file size.

Returns
integer

Definition at line 237 of file UploadBase.php.

References $mFileSize.

◆ getImageInfo()

UploadBase::getImageInfo (   $result)

Gets image info about the file just uploaded.

Also has the effect of setting metadata to be an 'indexed tag name' in returned API result if 'metadata' was requested. Oddly, we have to pass the "result" object down just so it can do that with the appropriate format, presumably.

Parameters
$resultApiResult:
Returns
Array: image info

Definition at line 1691 of file UploadBase.php.

References $file, ApiQueryImageInfo\getInfo(), getLocalFile(), and ApiQueryImageInfo\getPropertyNames().

◆ getLocalFile()

UploadBase::getLocalFile ( )

Return the local file and initializes if necessary.

Returns
LocalFile|null

Definition at line 828 of file UploadBase.php.

References $mLocalFile, getTitle(), and wfLocalFile().

Referenced by checkWarnings(), getImageInfo(), performUpload(), and validateName().

◆ getMaxUploadSize()

static UploadBase::getMaxUploadSize (   $forType = null)
static
Parameters
$forTypenull|string
Returns
int

Definition at line 1719 of file UploadBase.php.

References global.

Referenced by UploadFromChunks\addChunk(), UploadForm\addUploadJS(), UploadForm\getSourceSection(), and verifyUpload().

◆ getRealPath()

UploadBase::getRealPath (   $srcPath)
Parameters
string$srcPaththe source path
Returns
string|bool the real path if it was a virtual URL Returns false on failure

Definition at line 253 of file UploadBase.php.

References $path, RepoGroup\singleton(), wfProfileIn(), and wfProfileOut().

Referenced by UploadFromChunks\continueChunks(), and UploadFromStash\initialize().

◆ getSessionStatus()

static UploadBase::getSessionStatus (   $statusKey)
static

Get the current status of a chunked upload (used for polling).

The status will be read from the current user session.

Parameters
$statusKeystring
Returns
Array|bool

Definition at line 1739 of file UploadBase.php.

References SESSION_STATUS_KEY.

Referenced by ApiUpload\getChunkResult(), ApiUpload\performUpload(), and ApiUpload\selectUploadModule().

◆ getSourceType()

UploadBase::getSourceType ( )

Returns the upload type.

Should be overridden by child classes

Since
1.18
Returns
string

Reimplemented in UploadFromUrl, UploadFromStash, and UploadFromFile.

Definition at line 190 of file UploadBase.php.

Referenced by stashFile(), and verifyUpload().

◆ getTempFileSha1Base36()

UploadBase::getTempFileSha1Base36 ( )

Get the base 36 SHA1 of the file.

Returns
string

Reimplemented in UploadFromStash.

Definition at line 245 of file UploadBase.php.

References FSFile\getSha1Base36FromPath().

Referenced by checkWarnings().

◆ getTempPath()

UploadBase::getTempPath ( )

Definition at line 889 of file UploadBase.php.

References $mTempPath.

◆ getTitle()

◆ getVerificationErrorCode()

UploadBase::getVerificationErrorCode (   $error)
Parameters
$errorint
Returns
string

Definition at line 72 of file UploadBase.php.

References $error, and array().

Referenced by UploadFromChunks\concatenateChunks(), and convertVerifyErrorToStatus().

◆ initializeFromRequest()

UploadBase::initializeFromRequest ( $request)
abstract

Initialize from a WebRequest.

Override this in a subclass.

Reimplemented in UploadFromUrl, UploadTestHandler, UploadFromStash, and UploadFromFile.

◆ initializePathInfo()

UploadBase::initializePathInfo (   $name,
  $tempPath,
  $fileSize,
  $removeTempFile = false 
)

Initialize the path information.

Parameters
string$namethe desired destination name
string$tempPaththe temporary path
int$fileSizethe file size
bool$removeTempFile(false) remove the temporary file?
Exceptions
MWException

Definition at line 202 of file UploadBase.php.

References $name, and FileBackend\isStoragePath().

Referenced by UploadFromChunks\continueChunks(), UploadFromFile\initialize(), UploadFromStash\initialize(), and UploadFromUrl\initialize().

◆ isAllowed()

static UploadBase::isAllowed (   $user)
static

Returns true if the user can use this upload module or else a string identifying the missing permission.

Can be overridden by subclasses.

Parameters
$userUser
Returns
bool

Reimplemented in UploadFromUrl.

Definition at line 117 of file UploadBase.php.

References $user, array(), and as.

Referenced by SkinTemplate\buildNavUrls(), and SpecialUpload\execute().

◆ isEmptyFile()

UploadBase::isEmptyFile ( )

Return true if the file is empty.

Returns
bool

Definition at line 229 of file UploadBase.php.

Referenced by UploadFromFile\verifyUpload(), and verifyUpload().

◆ isEnabled()

static UploadBase::isEnabled ( )
static

Returns true if uploads are enabled.

Can be override by subclasses.

Returns
bool

Reimplemented in UploadFromUrl.

Definition at line 98 of file UploadBase.php.

References global, wfIniGetBool(), and wfIsHHVM().

Referenced by SkinTemplate\buildNavUrls(), ApiUpload\execute(), SpecialUpload\execute(), and SpecialUpload\userCanExecute().

◆ isThumbName()

static UploadBase::isThumbName (   $filename)
static

Helper function that checks whether the filename looks like a thumbnail.

Parameters
$filenamestring
Returns
bool

Definition at line 1644 of file UploadBase.php.

References $n.

◆ isValidRequest()

static UploadBase::isValidRequest (   $request)
static

Check whether a request if valid for this handler.

Parameters
$request
Returns
bool

Reimplemented in UploadFromUrl, UploadFromStash, and UploadFromFile.

Definition at line 178 of file UploadBase.php.

◆ performUpload()

UploadBase::performUpload (   $comment,
  $pageText,
  $watch,
  $user 
)

Really perform the upload.

Stores the file in the local repo, watches if necessary and runs the UploadComplete hook.

Parameters
$comment
$pageText
$watch
$userUser
Returns
Status indicating the whether the upload succeeded.

Reimplemented in UploadFromUrl, UploadFromStash, and UploadFromChunks.

Definition at line 683 of file UploadBase.php.

References $comment, $user, array(), File\DELETE_SOURCE, WatchAction\doWatch(), getLocalFile(), getTitle(), WatchedItem\IGNORE_USER_RIGHTS, wfProfileIn(), wfProfileOut(), and wfRunHooks().

◆ setSessionStatus()

static UploadBase::setSessionStatus (   $statusKey,
  $value 
)
static

Set the current status of a chunked upload (used for polling).

The status will be stored in the current user session.

Parameters
$statusKeystring
$valuearray|false
Returns
void

Definition at line 1752 of file UploadBase.php.

References $value, and SESSION_STATUS_KEY.

Referenced by ApiUpload\getChunkResult(), ApiUpload\performUpload(), AssembleUploadChunksJob\run(), and PublishStashedFileJob\run().

◆ splitExtensions()

static UploadBase::splitExtensions (   $filename)
static

Split a file into a base name and all dot-delimited 'extensions' on the end.

Some web server configurations will fall back to earlier pseudo-'extensions' to determine type and execute scripts, so the blacklist needs to check them all.

Parameters
$filenamestring
Returns
array

Definition at line 902 of file UploadBase.php.

References array().

Referenced by StreamFile\contentTypeFromPath(), and getTitle().

◆ splitXmlNamespace()

static UploadBase::splitXmlNamespace (   $element)
staticprivate

Divide the element name passed by the xml parser to the callback into URI and prifix.

Parameters
$namestring
Returns
array containing the namespace URI and prefix

Definition at line 1372 of file UploadBase.php.

References $name, and array().

Referenced by checkSvgScriptCallback().

◆ stashFile()

UploadBase::stashFile ( User  $user = null)

If the user does not supply all necessary information in the first upload form submission (either by accident or by design) then we may want to stash the file temporarily, get more information, and publish the file later.

This method will stash a file in a temporary directory for later processing, and save the necessary descriptive info into the database. This method returns the file object, which also has a 'fileKey' property which can be passed through a form or API request to find this stashed file again.

Parameters
$userUser
Returns
UploadStashFile stashed file

Reimplemented in UploadFromStash, and UploadFromChunks.

Definition at line 848 of file UploadBase.php.

References $file, $user, getSourceType(), RepoGroup\singleton(), wfProfileIn(), and wfProfileOut().

Referenced by stashFileGetKey().

◆ stashFileGetKey()

UploadBase::stashFileGetKey ( )

Stash a file in a temporary directory, returning a key which can be used to find the file again.

See stashFile().

Returns
String: file key

Definition at line 865 of file UploadBase.php.

References stashFile().

Referenced by stashSession().

◆ stashSession()

UploadBase::stashSession ( )

alias for stashFileGetKey, for backwards compatibility

Returns
String: file key

Reimplemented in UploadFromStash.

Definition at line 874 of file UploadBase.php.

References stashFileGetKey().

Referenced by UploadFromUrl\insertJob().

◆ stripXmlNamespace()

UploadBase::stripXmlNamespace (   $name)
private
Parameters
$namestring
Returns
string

Definition at line 1384 of file UploadBase.php.

References $name.

Referenced by checkSvgScriptCallback().

◆ userCanReUpload()

static UploadBase::userCanReUpload ( User  $user,
  $img 
)
static

Check if a user is the last uploader.

Parameters
$userUser object
string$imgimage name
Returns
Boolean

Definition at line 1526 of file UploadBase.php.

Referenced by ImagePage\uploadLinksBox().

◆ validateName()

UploadBase::validateName ( )

Verify that the name is valid and, if necessary, that we can overwrite.

Returns
mixed true if valid, otherwise and array with 'status' and other keys

Definition at line 339 of file UploadBase.php.

References $mBlackListedExtensions, $mFilteredName, $mFinalExtension, array(), getLocalFile(), and getTitle().

Referenced by verifyUpload().

◆ verifyExtension()

static UploadBase::verifyExtension (   $mime,
  $extension 
)
static

Checks if the mime type of the uploaded file matches the file extension.

Parameters
string$mimethe mime type of the uploaded file
string$extensionthe filename extension that the file is to be served with
Returns
Boolean

Definition at line 939 of file UploadBase.php.

References $mime, and wfDebug().

Referenced by verifyFile().

◆ verifyFile()

UploadBase::verifyFile ( )
protected

Verifies that it's ok to include the uploaded file.

Returns
mixed true of the file is verified, array otherwise.

Definition at line 403 of file UploadBase.php.

References $mime, array(), MediaHandler\getHandler(), FSFile\getPropsFromPath(), global, verifyExtension(), verifyPartialFile(), wfDebug(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

Referenced by verifyUpload().

◆ verifyMimeType()

UploadBase::verifyMimeType (   $mime)
protected

Verify the mime type.

Note
Only checks that it is not an evil mime. The does it have correct extension given its mime type check is in verifyFile.
Parameters
string$mimerepresenting the mime
Returns
mixed true if the file is verified, an array otherwise

Definition at line 367 of file UploadBase.php.

References $mime, array(), as, checkFileExtension(), global, wfDebug(), wfProfileIn(), and wfProfileOut().

Referenced by verifyPartialFile().

◆ verifyPartialFile()

UploadBase::verifyPartialFile ( )
protected

A verification routine suitable for partial files.

Runs the blacklist checks, but not any checks that may assume the entire file is present.

Returns
Mixed true for valid or array with error message key.

Definition at line 453 of file UploadBase.php.

References $error, $mime, array(), detectScriptInSvg(), detectVirus(), FSFile\getPropsFromPath(), getTitle(), global, ZipDirectoryReader\read(), verifyMimeType(), wfProfileIn(), and wfProfileOut().

Referenced by UploadFromChunks\verifyChunk(), and verifyFile().

◆ verifyPermissions()

UploadBase::verifyPermissions (   $user)

Alias for verifyTitlePermissions.

The function was originally 'verifyPermissions' but that suggests it's checking the user, when it's really checking the title + user combination.

Parameters
$userUser object to verify the permissions against
Returns
mixed An array as returned by getUserPermissionsErrors or true in case the user has proper permissions.

Definition at line 546 of file UploadBase.php.

References $user, and verifyTitlePermissions().

◆ verifyTitlePermissions()

UploadBase::verifyTitlePermissions (   $user)

Check whether the user can edit, upload and create the image.

This checks only against the current title; if it returns errors, it may very well be that another title will not give errors. Therefore isAllowed() should be called as well for generic is-user-blocked or can-user-upload checking.

Parameters
$userUser object to verify the permissions against
Returns
mixed An array as returned by getUserPermissionsErrors or true in case the user has proper permissions.

Reimplemented in UploadFromUrl.

Definition at line 561 of file UploadBase.php.

References $user, array(), checkOverwrite(), getTitle(), and wfArrayDiff2().

Referenced by verifyPermissions().

◆ verifyUpload()

UploadBase::verifyUpload ( )

Verify whether the upload is sane.

Returns
mixed self::OK or else an array with error information

Reimplemented in UploadFromUrl, and UploadFromFile.

Definition at line 275 of file UploadBase.php.

References $error, array(), getMaxUploadSize(), getSourceType(), isEmptyFile(), validateName(), verifyFile(), wfProfileIn(), wfProfileOut(), and wfRunHooks().

◆ zipEntryCallback()

UploadBase::zipEntryCallback (   $entry)

Callback for ZipDirectoryReader to detect Java class files.

Definition at line 519 of file UploadBase.php.

References array().

Member Data Documentation

◆ $mBlackListedExtensions

UploadBase::$mBlackListedExtensions
protected

Definition at line 44 of file UploadBase.php.

Referenced by validateName().

◆ $mDesiredDestName

UploadBase::$mDesiredDestName
protected

Definition at line 40 of file UploadBase.php.

Referenced by getTitle(), and UploadFromChunks\verifyChunk().

◆ $mDestName

UploadBase::$mDestName

Definition at line 40 of file UploadBase.php.

◆ $mFileProps

UploadBase::$mFileProps

Definition at line 43 of file UploadBase.php.

◆ $mFileSize

UploadBase::$mFileSize

Definition at line 43 of file UploadBase.php.

Referenced by getFileSize().

◆ $mFilteredName

UploadBase::$mFilteredName
protected

Definition at line 42 of file UploadBase.php.

Referenced by validateName().

◆ $mFinalExtension

UploadBase::$mFinalExtension

Definition at line 42 of file UploadBase.php.

Referenced by validateName().

◆ $mJavaDetected

UploadBase::$mJavaDetected
protected

Definition at line 45 of file UploadBase.php.

◆ $mLocalFile

UploadBase::$mLocalFile
protected

◆ $mRemoveTempFile

UploadBase::$mRemoveTempFile

Definition at line 40 of file UploadBase.php.

◆ $mSourceType

UploadBase::$mSourceType

Definition at line 40 of file UploadBase.php.

◆ $mSVGNSError

UploadBase::$mSVGNSError

Definition at line 45 of file UploadBase.php.

◆ $mTempPath

UploadBase::$mTempPath
protected

Definition at line 39 of file UploadBase.php.

Referenced by UploadFromChunks\addChunk(), and getTempPath().

◆ $mTitle

UploadBase::$mTitle = false
protected

Definition at line 41 of file UploadBase.php.

Referenced by getTitle().

◆ $mTitleError

UploadBase::$mTitleError = 0

Definition at line 41 of file UploadBase.php.

Referenced by UploadTestHandler\testTitleValidation().

◆ $safeXmlEncodings

UploadBase::$safeXmlEncodings = array( 'UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'UTF-16', 'UTF-32' )
staticprotected

Definition at line 47 of file UploadBase.php.

◆ $uploadHandlers

UploadBase::$uploadHandlers = array( 'Stash', 'File', 'Url' )
static

Definition at line 127 of file UploadBase.php.

◆ EMPTY_FILE

const UploadBase::EMPTY_FILE = 3

◆ FILE_TOO_LARGE

const UploadBase::FILE_TOO_LARGE = 12

◆ FILENAME_TOO_LONG

const UploadBase::FILENAME_TOO_LONG = 14

◆ FILETYPE_BADTYPE

const UploadBase::FILETYPE_BADTYPE = 9

◆ FILETYPE_MISSING

const UploadBase::FILETYPE_MISSING = 8

◆ HOOK_ABORTED

const UploadBase::HOOK_ABORTED = 11

◆ ILLEGAL_FILENAME

const UploadBase::ILLEGAL_FILENAME = 5

◆ MIN_LENGTH_PARTNAME

const UploadBase::MIN_LENGTH_PARTNAME = 4

◆ OK

◆ OVERWRITE_EXISTING_FILE

const UploadBase::OVERWRITE_EXISTING_FILE = 7

Definition at line 54 of file UploadBase.php.

◆ SESSION_STATUS_KEY

const UploadBase::SESSION_STATUS_KEY = 'wsUploadStatusData'

Definition at line 66 of file UploadBase.php.

Referenced by getSessionStatus(), and setSessionStatus().

◆ SUCCESS

const UploadBase::SUCCESS = 0

Definition at line 49 of file UploadBase.php.

◆ UPLOAD_VERIFICATION_ERROR

const UploadBase::UPLOAD_VERIFICATION_ERROR = 11

Definition at line 60 of file UploadBase.php.

◆ VERIFICATION_ERROR

const UploadBase::VERIFICATION_ERROR = 10

◆ WINDOWS_NONASCII_FILENAME

const UploadBase::WINDOWS_NONASCII_FILENAME = 13

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