'revdelUser' => $this->getUser(),
);
- $pageIds = $this->getPageSet()->getAllTitlesByNamespace();
+ $pageIds = $this->getPageSet()->getGoodAndMissingTitlesByNamespace();
if ( !empty( $pageIds[NS_FILE] ) ) {
$titles = array_keys( $pageIds[NS_FILE] );
asort( $titles ); // Ensure the order is always the same
$scale = array();
$scale['height'] = $params['urlheight'];
} else {
- $scale = null;
if ( $params['urlparam'] ) {
- $this->dieUsage( "{$p}urlparam requires {$p}urlwidth", "urlparam_no_width" );
+ // Audio files might not have a width/height.
+ $scale = array();
+ } else {
+ $scale = null;
}
}
* @return array Array of parameters for transform.
*/
protected function mergeThumbParams( $image, $thumbParams, $otherParams ) {
+ if ( $thumbParams === null ) {
+ // No scaling requested
+ return null;
+ }
if ( !isset( $thumbParams['width'] ) && isset( $thumbParams['height'] ) ) {
// We want to limit only by height in this situation, so pass the
// image's full width as the limiting width. But some file types
}
if ( !$otherParams ) {
+ $this->checkParameterNormalise( $image, $thumbParams );
return $thumbParams;
}
$p = $this->getModulePrefix();
// handlers.
$this->setWarning( "Could not parse {$p}urlparam for " . $image->getName()
. '. Using only width and height' );
-
+ $this->checkParameterNormalise( $image, $thumbParams );
return $thumbParams;
}
- if ( isset( $paramList['width'] ) ) {
+ if ( isset( $paramList['width'] ) && isset( $thumbParams['width'] ) ) {
if ( intval( $paramList['width'] ) != intval( $thumbParams['width'] ) ) {
$this->setWarning( "Ignoring width value set in {$p}urlparam ({$paramList['width']}) "
. "in favor of width value derived from {$p}urlwidth/{$p}urlheight "
}
}
- return $thumbParams + $paramList;
+ $finalParams = $thumbParams + $paramList;
+ $this->checkParameterNormalise( $image, $finalParams );
+ return $finalParams;
+ }
+
+ /**
+ * Verify that the final image parameters can be normalised.
+ *
+ * This doesn't use the normalised parameters, since $file->transform
+ * expects the pre-normalised parameters, but doing the normalisation
+ * allows us to catch certain error conditions early (such as missing
+ * required parameter).
+ *
+ * @param $image File
+ * @param $finalParams array List of parameters to transform image with
+ */
+ protected function checkParameterNormalise( $image, $finalParams ) {
+ $h = $image->getHandler();
+ if ( !$h ) {
+ return;
+ }
+ // Note: normaliseParams modifies the array in place, but we aren't interested
+ // in the actual normalised version, only if we can actually normalise them,
+ // so we use the functions scope to throw away the normalisations.
+ if ( !$h->normaliseParams( $image, $finalParams ) ) {
+ $this->dieUsage( "Could not normalise image parameters for " . $image->getName(), "urlparamnormal" );
+ }
}
/**
),
'urlwidth' => array(
ApiBase::PARAM_TYPE => 'integer',
- ApiBase::PARAM_DFLT => -1
+ ApiBase::PARAM_DFLT => -1,
+ ApiBase::PARAM_HELP_MSG => array(
+ 'apihelp-query+imageinfo-param-urlwidth',
+ ApiQueryImageInfo::TRANSFORM_LIMIT,
+ ),
),
'urlheight' => array(
ApiBase::PARAM_TYPE => 'integer',
ApiBase::PARAM_DFLT => '',
ApiBase::PARAM_TYPE => 'string',
),
- 'continue' => null,
+ 'continue' => array(
+ ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
+ ),
'localonly' => false,
);
}
/**
* Returns array key value pairs of properties and their descriptions
*
+ * @deprecated since 1.25
* @param string $modulePrefix
* @return array
*/
/**
* Returns the descriptions for the properties provided by getPropertyNames()
*
+ * @deprecated since 1.25
* @param array $filter List of properties to filter out
* @param string $modulePrefix
* @return array
);
}
- /**
- * Return the API documentation for the parameters.
- * @return array Parameter documentation.
- */
- public function getParamDescription() {
- $p = $this->getModulePrefix();
-
- return array(
- 'prop' => self::getPropertyDescriptions( array(), $p ),
- 'urlwidth' => array(
- "If {$p}prop=url is set, a URL to an image scaled to this width will be returned.",
- 'For performance reasons if this option is used, ' .
- 'no more than ' . self::TRANSFORM_LIMIT . ' scaled images will be returned.'
- ),
- 'urlheight' => "Similar to {$p}urlwidth.",
- 'urlparam' => array( "A handler specific parameter string. For example, pdf's ",
- "might use 'page15-100px'. {$p}urlwidth must be used and be consistent with {$p}urlparam" ),
- 'limit' => 'How many image revisions to return per image',
- 'start' => 'Timestamp to start listing from',
- 'end' => 'Timestamp to stop listing at',
- 'metadataversion'
- => array( "Version of metadata to use. if 'latest' is specified, use latest version.",
- "Defaults to '1' for backwards compatibility" ),
- 'extmetadatalanguage' => array(
- 'What language to fetch extmetadata in. This affects both which',
- 'translation to fetch, if multiple are available, as well as how things',
- 'like numbers and various values are formatted.'
- ),
- 'extmetadatamultilang'
- =>'If translations for extmetadata property are available, fetch all of them.',
- 'extmetadatafilter'
- => "If specified and non-empty, only these keys will be returned for {$p}prop=extmetadata",
- 'continue' => 'If the query response includes a continue value, ' .
- 'use it here to get another page of results',
- 'localonly' => 'Look only for files in the local repository',
- );
- }
-
- public function getDescription() {
- return 'Returns image information and upload history.';
- }
-
- public function getExamples() {
+ protected function getExamplesMessages() {
return array(
- 'api.php?action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo',
- 'api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
- 'iiend=20071231235959&iiprop=timestamp|user|url',
+ 'action=query&titles=File:Albert%20Einstein%20Head.jpg&prop=imageinfo'
+ => 'apihelp-query+imageinfo-example-simple',
+ 'action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&' .
+ 'iiend=2007-12-31T23:59:59Z&iiprop=timestamp|user|url'
+ => 'apihelp-query+imageinfo-example-dated',
);
}