Merge "MediaWikiTestCase: Fix schema restoration"
[lhc/web/wiklou.git] / includes / media / Exif.php
index a38e79b..0fde386 100644 (file)
@@ -20,7 +20,7 @@
  * @ingroup Media
  * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
  * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason, 2009 Brent Garber
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
+ * @license GPL-2.0-or-later
  * @see http://exif.org/Exif2-2.PDF The Exif 2.2 specification
  * @file
  */
@@ -290,7 +290,7 @@ class Exif {
                        $this->byteOrder = 'BE'; // BE seems about twice as popular as LE in jpg's.
                }
 
-               $this->debugFile( $this->basename, __FUNCTION__, true );
+               $this->debugFile( __FUNCTION__, true );
                if ( function_exists( 'exif_read_data' ) ) {
                        Wikimedia\suppressWarnings();
                        $data = exif_read_data( $this->file, 0, true );
@@ -455,8 +455,7 @@ class Exif {
                        $val = substr( $this->mFilteredExifData[$prop], 8 );
 
                        switch ( $charCode ) {
-                               case "\x4A\x49\x53\x00\x00\x00\x00\x00":
-                                       // JIS
+                               case "JIS\x00\x00\x00\x00\x00":
                                        $charset = "Shift-JIS";
                                        break;
                                case "UNICODE\x00":
@@ -742,12 +741,16 @@ class Exif {
                                $ecount = 1; // checking individual elements
                        }
                }
-               $count = count( $val );
-               if ( $ecount != $count ) {
-                       $this->debug( $val, __FUNCTION__, "Expected $ecount elements for $tag but got $count" );
 
-                       return false;
+               $count = 1;
+               if ( is_array( $val ) ) {
+                       $count = count( $val );
+                       if ( $ecount != $count ) {
+                               $this->debug( $val, __FUNCTION__, "Expected $ecount elements for $tag but got $count" );
+                               return false;
+                       }
                }
+               // If there are multiple values, recursively validate each of them.
                if ( $count > 1 ) {
                        foreach ( $val as $v ) {
                                if ( !$this->validate( $section, $tag, $v, true ) ) {