X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FFormatMetadata.php;h=f683da2c02609afaed9bc01b15cdab20624071b9;hb=bdf062a8e9f351d3b94f99f2cbe9f7176f0b8801;hp=69982c2fb4f2d5e0e02e5180d1e7d2c2411327e6;hpb=f7e1770fb832aa77bf4e16ce8cc815f2b24dd10d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/FormatMetadata.php b/includes/media/FormatMetadata.php index 69982c2fb4..f683da2c02 100644 --- a/includes/media/FormatMetadata.php +++ b/includes/media/FormatMetadata.php @@ -740,8 +740,13 @@ class FormatMetadata extends ContextSource { case 'Software': if ( is_array( $val ) ) { - // if its a software, version array. - $val = $this->msg( 'exif-software-version-value', $val[0], $val[1] )->text(); + if ( count( $val ) > 1 ) { + // if its a software, version array. + $val = $this->msg( 'exif-software-version-value', $val[0], $val[1] )->text(); + } else { + // https://phabricator.wikimedia.org/T178130 + $val = $this->exifMsg( $tag, '', $val[0] ); + } } else { $val = $this->exifMsg( $tag, '', $val ); } @@ -1042,7 +1047,7 @@ class FormatMetadata extends ContextSource { if ( !is_array( $vals ) ) { return $vals; // do nothing if not an array; - } elseif ( count( $vals ) === 1 && $type !== 'lang' ) { + } elseif ( count( $vals ) === 1 && $type !== 'lang' && isset( $vals[0] ) ) { return $vals[0]; } elseif ( count( $vals ) === 0 ) { wfDebug( __METHOD__ . " metadata array with 0 elements!\n" ); @@ -1675,7 +1680,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 [ => ['value' => ]], or [] on error * @since 1.23 @@ -1761,9 +1766,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; } @@ -1772,7 +1777,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 ) { @@ -1789,7 +1794,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 ) { @@ -1810,7 +1815,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 ) ) {