<?php
/**
- *
- *
- * Created on July 6, 2007
- *
* Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
*
* This program is free software; you can redistribute it and/or modify
* @file
*/
+use MediaWiki\MediaWikiServices;
+
/**
* A query action to get image information and upload history.
*
}
}
- /** @var $img File */
+ /** @var File $img */
$img = $images[$title];
if ( self::getTransformCount() >= self::TRANSFORM_LIMIT ) {
if ( count( $pageIds[NS_FILE] ) == 1 ) {
// See the 'the user is screwed' comment below
$this->setContinueEnumParameter( 'start',
- $start !== null ? $start : wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
+ $start ?? wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
);
} else {
$this->setContinueEnumParameter( 'continue',
// thing again. When the violating queries have been
// out-continued, the result will get through
$this->setContinueEnumParameter( 'start',
- $start !== null ? $start : wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
+ $start ?? wfTimestamp( TS_ISO_8601, $img->getTimestamp() )
);
} else {
$this->setContinueEnumParameter( 'continue',
// Get one more to facilitate query-continue functionality
$count = ( $gotOne ? 1 : 0 );
$oldies = $img->getHistory( $params['limit'] - $count + 1, $start, $params['end'] );
- /** @var $oldie File */
+ /** @var File $oldie */
foreach ( $oldies as $oldie ) {
if ( ++$count > $params['limit'] ) {
// We've reached the extra one which shows that there are
* @param File $file
* @param array $prop Array of properties to get (in the keys)
* @param ApiResult $result
- * @param array $thumbParams Containing 'width' and 'height' items, or null
+ * @param array|null $thumbParams Containing 'width' and 'height' items, or null
* @param array|bool|string $opts Options for data fetching.
* This is an array consisting of the keys:
* 'version': The metadata version for the metadata option
* @return array Result array
*/
public static function getInfo( $file, $prop, $result, $thumbParams = null, $opts = false ) {
- global $wgContLang;
-
$anyHidden = false;
if ( !$opts || is_string( $opts ) ) {
$opts = [
'version' => $opts ?: 'latest',
- 'language' => $wgContLang,
+ 'language' => MediaWikiServices::getInstance()->getContentLanguage(),
'multilang' => false,
'extmetadatafilter' => [],
'revdelUser' => null,
}
if ( $url ) {
- if ( !is_null( $thumbParams ) ) {
- $mto = $file->transform( $thumbParams );
- self::$transformCount++;
- if ( $mto && !$mto->isError() ) {
- $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT );
-
- // T25834 - If the URLs are the same, we haven't resized it, so shouldn't give the wanted
- // thumbnail sizes for the thumbnail actual size
- if ( $mto->getUrl() !== $file->getUrl() ) {
- $vals['thumbwidth'] = intval( $mto->getWidth() );
- $vals['thumbheight'] = intval( $mto->getHeight() );
- } else {
- $vals['thumbwidth'] = intval( $file->getWidth() );
- $vals['thumbheight'] = intval( $file->getHeight() );
- }
+ if ( $file->exists() ) {
+ if ( !is_null( $thumbParams ) ) {
+ $mto = $file->transform( $thumbParams );
+ self::$transformCount++;
+ if ( $mto && !$mto->isError() ) {
+ $vals['thumburl'] = wfExpandUrl( $mto->getUrl(), PROTO_CURRENT );
+
+ // T25834 - If the URLs are the same, we haven't resized it, so shouldn't give the wanted
+ // thumbnail sizes for the thumbnail actual size
+ if ( $mto->getUrl() !== $file->getUrl() ) {
+ $vals['thumbwidth'] = intval( $mto->getWidth() );
+ $vals['thumbheight'] = intval( $mto->getHeight() );
+ } else {
+ $vals['thumbwidth'] = intval( $file->getWidth() );
+ $vals['thumbheight'] = intval( $file->getHeight() );
+ }
- if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) {
- list( , $mime ) = $file->getHandler()->getThumbType(
- $mto->getExtension(), $file->getMimeType(), $thumbParams );
- $vals['thumbmime'] = $mime;
+ if ( isset( $prop['thumbmime'] ) && $file->getHandler() ) {
+ list( , $mime ) = $file->getHandler()->getThumbType(
+ $mto->getExtension(), $file->getMimeType(), $thumbParams );
+ $vals['thumbmime'] = $mime;
+ }
+ } elseif ( $mto && $mto->isError() ) {
+ $vals['thumberror'] = $mto->toText();
}
- } elseif ( $mto && $mto->isError() ) {
- $vals['thumberror'] = $mto->toText();
}
+ $vals['url'] = wfExpandUrl( $file->getFullUrl(), PROTO_CURRENT );
+ } else {
+ $vals['filemissing'] = true;
}
- $vals['url'] = wfExpandUrl( $file->getFullUrl(), PROTO_CURRENT );
$vals['descriptionurl'] = wfExpandUrl( $file->getDescriptionUrl(), PROTO_CURRENT );
$shortDescriptionUrl = $file->getDescriptionShortUrl();
}
if ( $meta ) {
- MediaWiki\suppressWarnings();
+ Wikimedia\suppressWarnings();
$metadata = unserialize( $file->getMetadata() );
- MediaWiki\restoreWarnings();
+ Wikimedia\restoreWarnings();
if ( $metadata && $version !== 'latest' ) {
$metadata = $file->convertMetadataVersion( $metadata, $version );
}
}
public function getAllowedParams() {
- global $wgContLang;
-
return [
'prop' => [
ApiBase::PARAM_ISMULTI => true,
],
'extmetadatalanguage' => [
ApiBase::PARAM_TYPE => 'string',
- ApiBase::PARAM_DFLT => $wgContLang->getCode(),
+ ApiBase::PARAM_DFLT =>
+ MediaWikiServices::getInstance()->getContentLanguage()->getCode(),
],
'extmetadatamultilang' => [
ApiBase::PARAM_TYPE => 'boolean',