MediaWiki  REL1_24
ApiUpload Class Reference
Inheritance diagram for ApiUpload:
Collaboration diagram for ApiUpload:

List of all members.

Public Member Functions

 execute ()
 Evaluates the parameters, performs the requested query, and sets up the result.
 getAllowedParams ()
 Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.
 getDescription ()
 Returns the description string for this module.
 getExamples ()
 Returns usage examples for this module.
 getHelpUrls ()
 getParamDescription ()
 Returns an array of parameter descriptions.
 isWriteMode ()
 Indicates whether this module requires write mode.
 mustBePosted ()
 Indicates whether this module must be called with a POST request.
 needsToken ()
 Returns the token type this module requires in order to execute.

Protected Member Functions

 checkAsyncDownloadEnabled ()
 Checks if asynchronous copy uploads are enabled and throws an error if they are not.
 checkPermissions ($user)
 Checks that the user has permissions to perform this upload.
 checkVerification (array $verification)
 Performs file verification, dies on error.
 getApiWarnings ()
 Check warnings.
 performUpload ($warnings)
 Perform the actual upload.
 selectUploadModule ()
 Select an upload module and set it to mUpload.
 transformWarnings ($warnings)
 verifyUpload ()
 Performs file verification, dies on error.

Protected Attributes

 $mParams
UploadBase UploadFromChunks $mUpload = null
 *

Private Member Functions

 dieRecoverableError ($error, $parameter, $data=array())
 Throw an error that the user can recover from by providing a better value for $parameter.
 getChunkResult ($warnings)
 Get the result of a chunk upload.
 getContextResult ()
 Get an upload result based on upload context.
 getStashResult ($warnings)
 Get Stash Result, throws an exception if the file could not be stashed.
 getWarningsResult ($warnings)
 Get Warnings Result.
 performStash ()
 Stash the file and return the file key Also re-raises exceptions with slightly more informative message strings (useful for API)

Detailed Description

Definition at line 30 of file ApiUpload.php.


Member Function Documentation

Checks if asynchronous copy uploads are enabled and throws an error if they are not.

Definition at line 669 of file ApiUpload.php.

ApiUpload::checkPermissions ( user) [protected]

Checks that the user has permissions to perform this upload.

Dies with usage message on inadequate permissions.

Parameters:
User$userThe user to check.

Definition at line 443 of file ApiUpload.php.

Referenced by execute().

ApiUpload::checkVerification ( array verification) [protected]

Performs file verification, dies on error.

Parameters:
array$verification

Definition at line 472 of file ApiUpload.php.

ApiUpload::dieRecoverableError ( error,
parameter,
data = array() 
) [private]

Throw an error that the user can recover from by providing a better value for $parameter.

Parameters:
array$errorError array suitable for passing to dieUsageMsg()
string$parameterParameter that needs revising
array$dataOptional extra data to pass to the user
Exceptions:
UsageException

Definition at line 298 of file ApiUpload.php.

Referenced by execute().

Evaluates the parameters, performs the requested query, and sets up the result.

Concrete implementations of ApiBase must override this method to provide whatever functionality their module offers. Implementations must not produce any output on their own and are not expected to handle any errors.

The execute() method will be invoked directly by ApiMain immediately before the result of the module is output. Aside from the constructor, implementations should assume that no other methods will be called externally on the module before the result is processed.

The result data should be stored in the ApiResult object available through getResult().

Reimplemented from ApiBase.

Definition at line 35 of file ApiUpload.php.

References $e, $error, $result, $user, checkPermissions(), dieRecoverableError(), ApiBase\dieUsage(), ApiBase\dieUsageMsg(), ApiBase\extractRequestParams(), ContextSource\getConfig(), getContextResult(), ApiBase\getMain(), ApiBase\getModuleName(), ApiBase\getResult(), ContextSource\getUser(), UploadBase\isEnabled(), ApiBase\logFeatureUsage(), selectUploadModule(), verifyUpload(), and wfDebug().

Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.

Some derived classes may choose to handle an integer $flags parameter in the overriding methods. Callers of this method can pass zero or more OR-ed flags like GET_VALUES_FOR_HELP.

Returns:
array|bool

Reimplemented from ApiBase.

Definition at line 683 of file ApiUpload.php.

References $params, array(), ApiBase\PARAM_DEPRECATED, ApiBase\PARAM_DFLT, and ApiBase\PARAM_TYPE.

ApiUpload::getApiWarnings ( ) [protected]

Check warnings.

Returns a suitable array for inclusion into API results if there were warnings Returns the empty array if there were no warnings

Returns:
array

Definition at line 541 of file ApiUpload.php.

ApiUpload::getChunkResult ( warnings) [private]

Get the result of a chunk upload.

Parameters:
array$warningsArray of Api upload warnings
Returns:
array

Definition at line 194 of file ApiUpload.php.

Get an upload result based on upload context.

Returns:
array

Definition at line 127 of file ApiUpload.php.

Referenced by execute().

Returns the description string for this module.

Returns:
string|array

Reimplemented from ApiBase.

Definition at line 763 of file ApiUpload.php.

References array().

Returns usage examples for this module.

Return false if no examples are available.

Returns:
bool|string|array

Reimplemented from ApiBase.

Definition at line 778 of file ApiUpload.php.

References array().

Returns:
bool|string|array Returns a false if the module has no help URL, else returns a (array of) string

Reimplemented from ApiBase.

Definition at line 788 of file ApiUpload.php.

Returns an array of parameter descriptions.

Don't call this function directly: use getFinalParamDescription() to allow hooks to modify descriptions as needed.

Returns:
array|bool False on no parameter descriptions

Reimplemented from ApiBase.

Definition at line 732 of file ApiUpload.php.

References $params, and array().

ApiUpload::getStashResult ( warnings) [private]

Get Stash Result, throws an exception if the file could not be stashed.

Parameters:
array$warningsArray of Api upload warnings
Returns:
array

Definition at line 150 of file ApiUpload.php.

ApiUpload::getWarningsResult ( warnings) [private]

Get Warnings Result.

Parameters:
array$warningsArray of Api upload warnings
Returns:
array

Definition at line 173 of file ApiUpload.php.

Indicates whether this module requires write mode.

Returns:
bool

Reimplemented from ApiBase.

Definition at line 679 of file ApiUpload.php.

Indicates whether this module must be called with a POST request.

Returns:
bool

Reimplemented from ApiBase.

Definition at line 675 of file ApiUpload.php.

Returns the token type this module requires in order to execute.

Modules are strongly encouraged to use the core 'csrf' type unless they have specialized security needs. If the token type is not one of the core types, you must use the ApiQueryTokensRegisterTypes hook to register it.

Returning a non-falsey value here will cause self::getFinalParams() to return a required string 'token' parameter and self::getFinalParamDescription() to ensure there is standardized documentation for it. Also, self::mustBePosted() must return true when tokens are used.

In previous versions of MediaWiki, true was a valid return value. Returning true will generate errors indicating that the API module needs updating.

Returns:
string|false

Reimplemented from ApiBase.

Definition at line 774 of file ApiUpload.php.

ApiUpload::performStash ( ) [private]

Stash the file and return the file key Also re-raises exceptions with slightly more informative message strings (useful for API)

Exceptions:
MWException
Returns:
string File key

Definition at line 272 of file ApiUpload.php.

ApiUpload::performUpload ( warnings) [protected]

Perform the actual upload.

Returns a suitable result array on success; dies on failure.

Parameters:
array$warningsArray of Api upload warnings
Returns:
array

Definition at line 584 of file ApiUpload.php.

Select an upload module and set it to mUpload.

Dies on failure. If the request was a status request and not a true upload, returns false; otherwise true

Returns:
bool

Definition at line 318 of file ApiUpload.php.

Referenced by execute().

ApiUpload::transformWarnings ( warnings) [protected]

Definition at line 547 of file ApiUpload.php.

References $result, array(), as, and ApiBase\getResult().

ApiUpload::verifyUpload ( ) [protected]

Performs file verification, dies on error.

Definition at line 459 of file ApiUpload.php.

Referenced by execute().


Member Data Documentation

ApiUpload::$mParams [protected]

Definition at line 33 of file ApiUpload.php.

UploadBase UploadFromChunks ApiUpload::$mUpload = null [protected]

*

Definition at line 31 of file ApiUpload.php.


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