Reedy has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/400916 )

Change subject: Only run count() on array()
......................................................................

Only run count() on array()

Bug: T182377
Change-Id: I9c8aca35bf8610316ec7e1757395e9bd56a531ad
---
M includes/media/Exif.php
1 file changed, 14 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/16/400916/1

diff --git a/includes/media/Exif.php b/includes/media/Exif.php
index cd457f0..0d901b8b 100644
--- a/includes/media/Exif.php
+++ b/includes/media/Exif.php
@@ -742,21 +742,24 @@
                                $ecount = 1; // checking individual elements
                        }
                }
-               $count = count( $val );
-               if ( $ecount != $count ) {
-                       $this->debug( $val, __FUNCTION__, "Expected $ecount 
elements for $tag but got $count" );
+               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 ( $count > 1 ) {
-                       foreach ( $val as $v ) {
-                               if ( !$this->validate( $section, $tag, $v, true 
) ) {
-                                       return false;
-                               }
+                               return false;
                        }
+                       if ( $count > 1 ) {
+                               foreach ( $val as $v ) {
+                                       if ( !$this->validate( $section, $tag, 
$v, true ) ) {
+                                               return false;
+                                       }
+                               }
 
-                       return true;
+                               return true;
+                       }
                }
+
                // Does not work if not typecast
                switch ( (string)$etype ) {
                        case (string)self::BYTE:

-- 
To view, visit https://gerrit.wikimedia.org/r/400916
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9c8aca35bf8610316ec7e1757395e9bd56a531ad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Reedy <re...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to