35 parent::__construct( $query, $moduleName,
'msf' );
41 if ( !$user->isRegistered() ) {
42 $this->
dieWithError(
'apierror-mustbeloggedin-uploadstash',
'stashnotloggedin' );
52 $this->
addFields( [
'us_id',
'us_key',
'us_status' ] );
54 $this->
addWhere( [
'us_user' => $user->getId() ] );
56 if ( $params[
'continue'] !==
null ) {
59 'us_id' => (
int)$cont[0],
63 $this->
addOption(
'LIMIT', $params[
'limit'] + 1 );
66 $prop = array_fill_keys( $params[
'prop'],
true );
75 isset( $prop[
'size'] )
77 $this->
addFieldsIf( [
'us_mime',
'us_media_type' ], isset( $prop[
'type'] ) );
79 $res = $this->
select( __METHOD__ );
83 foreach ( $res as $row ) {
84 if ( ++$count > $params[
'limit'] ) {
92 'filekey' => $row->us_key,
93 'status' => $row->us_status,
96 if ( isset( $prop[
'size'] ) ) {
97 $item[
'size'] = (int)$row->us_size;
98 $item[
'width'] = (
int)$row->us_image_width;
99 $item[
'height'] = (int)$row->us_image_height;
100 $item[
'bits'] = (
int)$row->us_image_bits;
103 if ( isset( $prop[
'type'] ) ) {
104 $item[
'mimetype'] = $row->us_mime;
105 $item[
'mediatype'] = $row->us_media_type;
108 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $item );
116 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'file' );
122 ParamValidator::PARAM_ISMULTI =>
true,
123 ParamValidator::PARAM_DEFAULT =>
'',
124 ParamValidator::PARAM_TYPE => [
'size',
'type' ],
129 ParamValidator::PARAM_TYPE =>
'limit',
130 ParamValidator::PARAM_DEFAULT => 10,
131 IntegerDef::PARAM_MIN => 1,
144 'action=query&list=mystashedfiles&msfprop=size'
145 =>
'apihelp-query+mystashedfiles-example-simple',
150 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:mystashedfiles';
dieWithError( $msg, $code=null, $data=null, $httpCode=0)
Abort execution with an error.
parseContinueParamOrDie(string $continue, array $types)
Parse the 'continue' parameter in the usual format and validate the types of each part,...
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getDB()
Get the Query database connection (read-only)
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
action=query&list=mystashedfiles module, gets all stashed files for the current user.
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
__construct(ApiQuery $query, $moduleName)
This is the main query class.