Merge "Add attributes parameter to ShowSearchHitTitle"
[lhc/web/wiklou.git] / includes / media / FormatMetadata.php
index 2c541e0..6661965 100644 (file)
@@ -24,6 +24,7 @@
  * @see http://exif.org/Exif2-2.PDF The Exif 2.2 specification
  * @file
  */
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Timestamp\TimestampException;
 
 /**
@@ -101,9 +102,6 @@ class FormatMetadata extends ContextSource {
        public function makeFormattedData( $tags ) {
                $resolutionunit = !isset( $tags['ResolutionUnit'] ) || $tags['ResolutionUnit'] == 2 ? 2 : 3;
                unset( $tags['ResolutionUnit'] );
-               // Width and height are for internal use and already available & displayed outside of metadata
-               unset( $tags['Width'] );
-               unset( $tags['Height'] );
 
                foreach ( $tags as $tag => &$vals ) {
                        // This seems ugly to wrap non-array's in an array just to unwrap again,
@@ -1584,14 +1582,14 @@ class FormatMetadata extends ContextSource {
         * @since 1.23
         */
        public function fetchExtendedMetadata( File $file ) {
-               $cache = ObjectCache::getMainWANInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
 
                // If revision deleted, exit immediately
                if ( $file->isDeleted( File::DELETED_FILE ) ) {
                        return [];
                }
 
-               $cacheKey = wfMemcKey(
+               $cacheKey = $cache->makeKey(
                        'getExtendedMetadata',
                        $this->getLanguage()->getCode(),
                        (int)$this->singleLang,
@@ -1677,7 +1675,7 @@ class FormatMetadata extends ContextSource {
         *
         * @param File $file File to use
         * @param array $extendedMetadata
-        * @param int $maxCacheTime Hook handlers might use this parameter to override cache time
+        * @param int &$maxCacheTime Hook handlers might use this parameter to override cache time
         *
         * @return array [<property name> => ['value' => <value>]], or [] on error
         * @since 1.23
@@ -1763,9 +1761,9 @@ class FormatMetadata extends ContextSource {
                        }
                        return $newValue;
                } else { // _type is 'ul' or 'ol' or missing in which case it defaults to 'ul'
-                       list( $k, $v ) = each( $value );
-                       if ( $k === '_type' ) {
-                               $v = current( $value );
+                       $v = reset( $value );
+                       if ( key( $value ) === '_type' ) {
+                               $v = next( $value );
                        }
                        return $v;
                }
@@ -1774,7 +1772,7 @@ class FormatMetadata extends ContextSource {
        /**
         * Takes an array returned by the getExtendedMetadata* functions,
         * and resolves multi-language values in it.
-        * @param array $metadata
+        * @param array &$metadata
         * @since 1.23
         */
        protected function resolveMultilangMetadata( &$metadata ) {
@@ -1791,7 +1789,7 @@ class FormatMetadata extends ContextSource {
        /**
         * Takes an array returned by the getExtendedMetadata* functions,
         * and turns all fields into single-valued ones by dropping extra values.
-        * @param array $metadata
+        * @param array &$metadata
         * @since 1.25
         */
        protected function discardMultipleValues( &$metadata ) {
@@ -1812,7 +1810,7 @@ class FormatMetadata extends ContextSource {
 
        /**
         * Makes sure the given array is a valid API response fragment
-        * @param array $arr
+        * @param array &$arr
         */
        protected function sanitizeArrayForAPI( &$arr ) {
                if ( !is_array( $arr ) ) {