Mass conversion of $wgContLang to service
[lhc/web/wiklou.git] / includes / api / ApiQueryImageInfo.php
index fd456cb..18d2804 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * A query action to get image information and upload history.
  *
@@ -127,7 +129,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                        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',
@@ -152,7 +154,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                                                // 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',
@@ -359,7 +361,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
         * @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
@@ -369,14 +371,12 @@ class ApiQueryImageInfo extends ApiQueryBase {
         * @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,
@@ -542,9 +542,9 @@ class ApiQueryImageInfo extends ApiQueryBase {
                }
 
                if ( $meta ) {
-                       MediaWiki\suppressWarnings();
+                       Wikimedia\suppressWarnings();
                        $metadata = unserialize( $file->getMetadata() );
-                       MediaWiki\restoreWarnings();
+                       Wikimedia\restoreWarnings();
                        if ( $metadata && $version !== 'latest' ) {
                                $metadata = $file->convertMetadataVersion( $metadata, $version );
                        }
@@ -650,8 +650,6 @@ class ApiQueryImageInfo extends ApiQueryBase {
        }
 
        public function getAllowedParams() {
-               global $wgContLang;
-
                return [
                        'prop' => [
                                ApiBase::PARAM_ISMULTI => true,
@@ -690,7 +688,8 @@ class ApiQueryImageInfo extends ApiQueryBase {
                        ],
                        'extmetadatalanguage' => [
                                ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_DFLT => $wgContLang->getCode(),
+                               ApiBase::PARAM_DFLT =>
+                                       MediaWikiServices::getInstance()->getContentLanguage()->getCode(),
                        ],
                        'extmetadatamultilang' => [
                                ApiBase::PARAM_TYPE => 'boolean',