Upgrade wikimedia/ip-set to 1.3.0
[lhc/web/wiklou.git] / includes / media / FormatMetadata.php
index 6cac126..6cb33ac 100644 (file)
@@ -271,7 +271,7 @@ class FormatMetadata extends ContextSource {
                                        // TODO: YCbCrCoefficients  #p27 (see annex E)
                                        case 'ExifVersion':
                                        case 'FlashpixVersion':
-                                               $val = "$val" / 100;
+                                               $val = (int)$val / 100;
                                                break;
 
                                        case 'ColorSpace':
@@ -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" );
@@ -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;
                }
@@ -1854,9 +1859,9 @@ class FormatMetadata extends ContextSource {
                // drop all characters which are not valid in an XML tag name
                // a bunch of non-ASCII letters would be valid but probably won't
                // be used so we take the easy way
-               $key = preg_replace( '/[^a-zA-z0-9_:.-]/', '', $key );
+               $key = preg_replace( '/[^a-zA-z0-9_:.\-]/', '', $key );
                // drop characters which are invalid at the first position
-               $key = preg_replace( '/^[\d-.]+/', '', $key );
+               $key = preg_replace( '/^[\d\-.]+/', '', $key );
 
                if ( $key == '' ) {
                        $key = '_';