Siebrand has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/99451


Change subject: Remove unneeded uses of else {} in media classes
......................................................................

Remove unneeded uses of else {} in media classes

Change-Id: Id51688f2906a965af30adc3e9c66cc1fd02ebe04
---
M includes/media/Bitmap.php
M includes/media/BitmapMetadataHandler.php
M includes/media/DjVu.php
M includes/media/Exif.php
M includes/media/FormatMetadata.php
M includes/media/GIF.php
M includes/media/GIFMetadataExtractor.php
M includes/media/IPTC.php
M includes/media/ImageHandler.php
M includes/media/Jpeg.php
M includes/media/JpegMetadataExtractor.php
M includes/media/MediaHandler.php
M includes/media/MediaTransformOutput.php
M includes/media/SVG.php
M includes/media/SVGMetadataExtractor.php
M includes/media/Tiff.php
M includes/media/XMPValidate.php
17 files changed, 209 insertions(+), 198 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/51/99451/1

diff --git a/includes/media/Bitmap.php b/includes/media/Bitmap.php
index 5999486..a509549 100644
--- a/includes/media/Bitmap.php
+++ b/includes/media/Bitmap.php
@@ -230,14 +230,14 @@
                                $scalerParams['clientWidth'], 
$scalerParams['clientHeight'] );
                } elseif ( $mto ) {
                        return $mto;
-               } else {
-                       $params = array(
-                               'width' => $scalerParams['clientWidth'],
-                               'height' => $scalerParams['clientHeight']
-                       );
-
-                       return new ThumbnailImage( $image, $dstUrl, $dstPath, 
$params );
                }
+
+               $params = array(
+                       'width' => $scalerParams['clientWidth'],
+                       'height' => $scalerParams['clientHeight']
+               );
+
+               return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
        }
 
        /**
diff --git a/includes/media/BitmapMetadataHandler.php 
b/includes/media/BitmapMetadataHandler.php
index 2a393db..1457e8f 100644
--- a/includes/media/BitmapMetadataHandler.php
+++ b/includes/media/BitmapMetadataHandler.php
@@ -273,18 +273,19 @@
                        if ( !$byteOrder ) {
                                throw new MWException( "Error determining byte 
order of $filename" );
                        }
+
                        $exif = new Exif( $filename, $byteOrder );
                        $data = $exif->getFilteredData();
                        if ( $data ) {
                                $data['MEDIAWIKI_EXIF_VERSION'] = 
Exif::version();
 
                                return $data;
-                       } else {
-                               throw new MWException( "Could not extract data 
from tiff file $filename" );
                        }
-               } else {
-                       throw new MWException( "File doesn't exist - $filename" 
);
+
+                       throw new MWException( "Could not extract data from 
tiff file $filename" );
                }
+
+               throw new MWException( "File doesn't exist - $filename" );
        }
 
        /**
diff --git a/includes/media/DjVu.php b/includes/media/DjVu.php
index 03b3564..d568722 100644
--- a/includes/media/DjVu.php
+++ b/includes/media/DjVu.php
@@ -36,9 +36,9 @@
                        wfDebug( "DjVu is disabled, please set \$wgDjvuRenderer 
and \$wgDjvuDump\n" );
 
                        return false;
-               } else {
-                       return true;
                }
+
+               return true;
        }
 
        /**
@@ -76,12 +76,12 @@
                if ( in_array( $name, array( 'width', 'height', 'page' ) ) ) {
                        if ( $value <= 0 ) {
                                return false;
-                       } else {
-                               return true;
                        }
-               } else {
-                       return false;
+
+                       return true;
                }
+
+               return false;
        }
 
        /**
@@ -105,9 +105,9 @@
                $m = false;
                if ( preg_match( '/^page(\d+)-(\d+)px$/', $str, $m ) ) {
                        return array( 'width' => $m[2], 'page' => $m[1] );
-               } else {
-                       return false;
                }
+
+               return false;
        }
 
        /**
@@ -146,6 +146,7 @@
                if ( !$this->normaliseParams( $image, $params ) ) {
                        return new TransformParameterError( $params );
                }
+
                $width = $params['width'];
                $height = $params['height'];
                $page = $params['page'];
@@ -200,15 +201,15 @@
                                        wfHostname(), $retval, trim( $err ), 
$cmd ) );
 
                        return new MediaTransformError( 'thumbnail_error', 
$width, $height, $err );
-               } else {
-                       $params = array(
-                               'width' => $width,
-                               'height' => $height,
-                               'page' => $page
-                       );
-
-                       return new ThumbnailImage( $image, $dstUrl, $dstPath, 
$params );
                }
+
+               $params = array(
+                       'width' => $width,
+                       'height' => $height,
+                       'page' => $page
+               );
+
+               return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
        }
 
        /**
@@ -276,9 +277,9 @@
                wfProfileOut( __METHOD__ );
                if ( $gettext ) {
                        return $image->djvuTextTree;
-               } else {
-                       return $image->dejaMetaTree;
                }
+
+               return $image->dejaMetaTree;
        }
 
        /**
@@ -336,9 +337,9 @@
                                'width' => intval( $o['width'] ),
                                'height' => intval( $o['height'] )
                        );
-               } else {
-                       return false;
                }
+
+               return false;
        }
 
        /**
@@ -357,8 +358,8 @@
                        $txt = $o['value'];
 
                        return $txt;
-               } else {
-                       return false;
                }
+
+               return false;
        }
 }
diff --git a/includes/media/Exif.php b/includes/media/Exif.php
index 846ad45..2117645 100644
--- a/includes/media/Exif.php
+++ b/includes/media/Exif.php
@@ -365,7 +365,6 @@
         * if we make up our own types like Exif::DATE.
         */
        function collapseData() {
-
                $this->exifGPStoNumber( 'GPSLatitude' );
                $this->exifGPStoNumber( 'GPSDestLatitude' );
                $this->exifGPStoNumber( 'GPSLongitude' );
@@ -631,11 +630,11 @@
                        $this->debug( $in, __FUNCTION__, true );
 
                        return true;
-               } else {
-                       $this->debug( $in, __FUNCTION__, false );
-
-                       return false;
                }
+
+               $this->debug( $in, __FUNCTION__, false );
+
+               return false;
        }
 
        /**
@@ -671,11 +670,11 @@
                        $this->debug( $in, __FUNCTION__, true );
 
                        return true;
-               } else {
-                       $this->debug( $in, __FUNCTION__, false );
-
-                       return false;
                }
+
+               $this->debug( $in, __FUNCTION__, false );
+
+               return false;
        }
 
        /**
@@ -687,11 +686,11 @@
                        $this->debug( $in, __FUNCTION__, true );
 
                        return true;
-               } else {
-                       $this->debug( $in, __FUNCTION__, false );
-
-                       return false;
                }
+
+               $this->debug( $in, __FUNCTION__, false );
+
+               return false;
        }
 
        /**
@@ -706,11 +705,11 @@
                        && preg_match( '/^(\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, 
$m )
                ) {
                        return $this->isLong( $m[1] ) && $this->isLong( $m[2] );
-               } else {
-                       $this->debug( $in, __FUNCTION__, 'fed a non-fraction 
value' );
-
-                       return false;
                }
+
+               $this->debug( $in, __FUNCTION__, 'fed a non-fraction value' );
+
+               return false;
        }
 
        /**
@@ -732,11 +731,11 @@
                        $this->debug( $in, __FUNCTION__, true );
 
                        return true;
-               } else {
-                       $this->debug( $in, __FUNCTION__, false );
-
-                       return false;
                }
+
+               $this->debug( $in, __FUNCTION__, false );
+
+               return false;
        }
 
        /**
@@ -751,11 +750,11 @@
                        preg_match( '/^(-?\d+)\/(\d+[1-9]|[1-9]\d*)$/', $in, $m 
)
                ) {
                        return $this->isSlong( $m[0] ) && $this->isSlong( $m[1] 
);
-               } else {
-                       $this->debug( $in, __FUNCTION__, 'fed a non-fraction 
value' );
-
-                       return false;
                }
+
+               $this->debug( $in, __FUNCTION__, 'fed a non-fraction value' );
+
+               return false;
        }
 
        /**#@-*/
diff --git a/includes/media/FormatMetadata.php 
b/includes/media/FormatMetadata.php
index adaba76..1e437ac 100644
--- a/includes/media/FormatMetadata.php
+++ b/includes/media/FormatMetadata.php
@@ -1478,92 +1478,92 @@
                        }
 
                        return $this->flattenArrayReal( $vals );
-               } else {
-                       // We have a real ContactInfo field.
-                       // Its unclear if all these fields have to be
-                       // set, so assume they do not.
-                       $url = $tel = $street = $city = $country = '';
-                       $email = $postal = $region = '';
+               }
 
-                       // Also note, some of the class names this uses
-                       // are similar to those used by hCard. This is
-                       // mostly because they're sensible names. This
-                       // does not (and does not attempt to) output
-                       // stuff in the hCard microformat. However it
-                       // might output in the adr microformat.
+               // We have a real ContactInfo field.
+               // Its unclear if all these fields have to be
+               // set, so assume they do not.
+               $url = $tel = $street = $city = $country = '';
+               $email = $postal = $region = '';
 
-                       if ( isset( $vals['CiAdrExtadr'] ) ) {
-                               // Todo: This can potentially be multi-line.
-                               // Need to check how that works in XMP.
-                               $street = '<span class="extended-address">'
-                                       . htmlspecialchars(
-                                               $vals['CiAdrExtadr'] )
-                                       . '</span>';
-                       }
-                       if ( isset( $vals['CiAdrCity'] ) ) {
-                               $city = '<span class="locality">'
-                                       . htmlspecialchars( $vals['CiAdrCity'] )
-                                       . '</span>';
-                       }
-                       if ( isset( $vals['CiAdrCtry'] ) ) {
-                               $country = '<span class="country-name">'
-                                       . htmlspecialchars( $vals['CiAdrCtry'] )
-                                       . '</span>';
-                       }
-                       if ( isset( $vals['CiEmailWork'] ) ) {
-                               $emails = array();
-                               // Have to split multiple emails at commas/new 
lines.
-                               $splitEmails = explode( "\n", 
$vals['CiEmailWork'] );
-                               foreach ( $splitEmails as $e1 ) {
-                                       // Also split on comma
-                                       foreach ( explode( ',', $e1 ) as $e2 ) {
-                                               $finalEmail = trim( $e2 );
-                                               if ( $finalEmail == ',' || 
$finalEmail == '' ) {
-                                                       continue;
-                                               }
-                                               if ( strpos( $finalEmail, '<' ) 
!== false ) {
-                                                       // Don't do fancy 
formatting to
-                                                       // "My name" 
<[email protected]> style stuff
-                                                       $emails[] = $finalEmail;
-                                               } else {
-                                                       $emails[] = '[mailto:'
-                                                               . $finalEmail
-                                                               . ' <span 
class="email">'
-                                                               . $finalEmail
-                                                               . '</span>]';
-                                               }
+               // Also note, some of the class names this uses
+               // are similar to those used by hCard. This is
+               // mostly because they're sensible names. This
+               // does not (and does not attempt to) output
+               // stuff in the hCard microformat. However it
+               // might output in the adr microformat.
+
+               if ( isset( $vals['CiAdrExtadr'] ) ) {
+                       // @todo This can potentially be multi-line.
+                       // Need to check how that works in XMP.
+                       $street = '<span class="extended-address">'
+                               . htmlspecialchars(
+                                       $vals['CiAdrExtadr'] )
+                               . '</span>';
+               }
+               if ( isset( $vals['CiAdrCity'] ) ) {
+                       $city = '<span class="locality">'
+                               . htmlspecialchars( $vals['CiAdrCity'] )
+                               . '</span>';
+               }
+               if ( isset( $vals['CiAdrCtry'] ) ) {
+                       $country = '<span class="country-name">'
+                               . htmlspecialchars( $vals['CiAdrCtry'] )
+                               . '</span>';
+               }
+               if ( isset( $vals['CiEmailWork'] ) ) {
+                       $emails = array();
+                       // Have to split multiple emails at commas/new lines.
+                       $splitEmails = explode( "\n", $vals['CiEmailWork'] );
+                       foreach ( $splitEmails as $e1 ) {
+                               // Also split on comma
+                               foreach ( explode( ',', $e1 ) as $e2 ) {
+                                       $finalEmail = trim( $e2 );
+                                       if ( $finalEmail == ',' || $finalEmail 
== '' ) {
+                                               continue;
+                                       }
+                                       if ( strpos( $finalEmail, '<' ) !== 
false ) {
+                                               // Don't do fancy formatting to
+                                               // "My name" <[email protected]> 
style stuff
+                                               $emails[] = $finalEmail;
+                                       } else {
+                                               $emails[] = '[mailto:'
+                                                       . $finalEmail
+                                                       . ' <span 
class="email">'
+                                                       . $finalEmail
+                                                       . '</span>]';
                                        }
                                }
-                               $email = implode( ', ', $emails );
                        }
-                       if ( isset( $vals['CiTelWork'] ) ) {
-                               $tel = '<span class="tel">'
-                                       . htmlspecialchars( $vals['CiTelWork'] )
-                                       . '</span>';
-                       }
-                       if ( isset( $vals['CiAdrPcode'] ) ) {
-                               $postal = '<span class="postal-code">'
-                                       . htmlspecialchars(
-                                               $vals['CiAdrPcode'] )
-                                       . '</span>';
-                       }
-                       if ( isset( $vals['CiAdrRegion'] ) ) {
-                               // Note this is province/state.
-                               $region = '<span class="region">'
-                                       . htmlspecialchars(
-                                               $vals['CiAdrRegion'] )
-                                       . '</span>';
-                       }
-                       if ( isset( $vals['CiUrlWork'] ) ) {
-                               $url = '<span class="url">'
-                                       . htmlspecialchars( $vals['CiUrlWork'] )
-                                       . '</span>';
-                       }
-
-                       return $this->msg( 'exif-contact-value', $email, $url,
-                               $street, $city, $region, $postal, $country,
-                               $tel )->text();
+                       $email = implode( ', ', $emails );
                }
+               if ( isset( $vals['CiTelWork'] ) ) {
+                       $tel = '<span class="tel">'
+                               . htmlspecialchars( $vals['CiTelWork'] )
+                               . '</span>';
+               }
+               if ( isset( $vals['CiAdrPcode'] ) ) {
+                       $postal = '<span class="postal-code">'
+                               . htmlspecialchars(
+                                       $vals['CiAdrPcode'] )
+                               . '</span>';
+               }
+               if ( isset( $vals['CiAdrRegion'] ) ) {
+                       // Note this is province/state.
+                       $region = '<span class="region">'
+                               . htmlspecialchars(
+                                       $vals['CiAdrRegion'] )
+                               . '</span>';
+               }
+               if ( isset( $vals['CiUrlWork'] ) ) {
+                       $url = '<span class="url">'
+                               . htmlspecialchars( $vals['CiUrlWork'] )
+                               . '</span>';
+               }
+
+               return $this->msg( 'exif-contact-value', $email, $url,
+                       $street, $city, $region, $postal, $country,
+                       $tel )->text();
        }
 
        /**
diff --git a/includes/media/GIF.php b/includes/media/GIF.php
index bde889c..c9e585d 100644
--- a/includes/media/GIF.php
+++ b/includes/media/GIF.php
@@ -87,9 +87,9 @@
                        $metadata = unserialize( $ser );
 
                        return $image->getWidth() * $image->getHeight() * 
$metadata['frameCount'];
-               } else {
-                       return $image->getWidth() * $image->getHeight();
                }
+
+               return $image->getWidth() * $image->getHeight();
        }
 
        /**
diff --git a/includes/media/GIFMetadataExtractor.php 
b/includes/media/GIFMetadataExtractor.php
index 9328ffe..08a2881 100644
--- a/includes/media/GIFMetadataExtractor.php
+++ b/includes/media/GIFMetadataExtractor.php
@@ -141,6 +141,7 @@
                                        if ( strlen( $term ) < 1 ) {
                                                throw new Exception( "Ran out 
of input" );
                                        }
+
                                        $term = unpack( 'C', $term );
                                        $term = $term[1];
                                        if ( $term != 0 ) {
@@ -282,6 +283,7 @@
                if ( strlen( $data ) < 1 ) {
                        throw new Exception( "Ran out of input" );
                }
+
                $buf = unpack( 'C', $data );
                $buf = $buf[1];
                $bpp = ( $buf & 7 ) + 1;
@@ -302,6 +304,7 @@
                        if ( strlen( $buf ) < 1 ) {
                                throw new Exception( "Ran out of input" );
                        }
+
                        $block_len = unpack( 'C', $buf );
                        $block_len = $block_len[1];
                        if ( $block_len == 0 ) {
@@ -332,12 +335,15 @@
 
                while ( $subLength !== "\0" ) {
                        $blocks++;
+
                        if ( $blocks > self::MAX_SUBBLOCKS ) {
                                throw new Exception( "MAX_SUBBLOCKS exceeded 
(over $blocks sub-blocks)" );
                        }
+
                        if ( feof( $fh ) ) {
                                throw new Exception( "Read error: Unexpected 
EOF." );
                        }
+
                        if ( $includeLengths ) {
                                $data .= $subLength;
                        }
diff --git a/includes/media/IPTC.php b/includes/media/IPTC.php
index 503b968..5d9a384 100644
--- a/includes/media/IPTC.php
+++ b/includes/media/IPTC.php
@@ -412,9 +412,9 @@
                if ( $dateOnly ) {
                        //return the date only
                        return substr( $finalTimestamp, 0, 10 );
-               } else {
-                       return $finalTimestamp;
                }
+
+               return $finalTimestamp;
        }
 
        /**
@@ -452,19 +452,19 @@
                                $data = "";
                                wfDebugLog( 'iptc', __METHOD__ . " Error 
converting iptc data charset $charset to utf-8" );
                        }
-               } else {
-                       //treat as utf-8 if is valid utf-8. otherwise pretend 
its windows-1252
-                       // most of the time if there is no 1:90 tag, it is 
either ascii, latin1, or utf-8
-                       $oldData = $data;
-                       UtfNormal::quickIsNFCVerify( $data ); //make $data 
valid utf-8
-                       if ( $data === $oldData ) {
-                               return $data; //if validation didn't change 
$data
-                       } else {
-                               return self::convIPTCHelper( $oldData, 
'Windows-1252' );
-                       }
+
+                       return trim( $data );
                }
 
-               return trim( $data );
+               //treat as utf-8 if is valid utf-8. otherwise pretend its 
windows-1252
+               // most of the time if there is no 1:90 tag, it is either 
ascii, latin1, or utf-8
+               $oldData = $data;
+               UtfNormal::quickIsNFCVerify( $data ); //make $data valid utf-8
+               if ( $data === $oldData ) {
+                       return $data; //if validation didn't change $data
+               }
+
+               return self::convIPTCHelper( $oldData, 'Windows-1252' );
        }
 
        /**
@@ -476,7 +476,6 @@
         * only code that seems to have wide use. It does detect that code.
         */
        static function getCharset( $tag ) {
-
                //According to iim standard, charset is defined by the tag 1:90.
                //in which there are iso 2022 escape sequences to specify the 
character set.
                //the iim standard seems to encourage that all necessary escape 
sequences are
diff --git a/includes/media/ImageHandler.php b/includes/media/ImageHandler.php
index 4dd79a8..ee0e216 100644
--- a/includes/media/ImageHandler.php
+++ b/includes/media/ImageHandler.php
@@ -43,12 +43,12 @@
                if ( in_array( $name, array( 'width', 'height' ) ) ) {
                        if ( $value <= 0 ) {
                                return false;
-                       } else {
-                               return true;
                        }
-               } else {
-                       return false;
+
+                       return true;
                }
+
+               return false;
        }
 
        function makeParamString( $params ) {
@@ -69,9 +69,9 @@
                $m = false;
                if ( preg_match( '/^(\d+)px$/', $str, $m ) ) {
                        return array( 'width' => $m[1] );
-               } else {
-                       return false;
                }
+
+               return false;
        }
 
        function getScriptParams( $params ) {
@@ -263,9 +263,9 @@
                if ( $pages > 1 ) {
                        return wfMessage( 'widthheightpage' )
                                ->numParams( $file->getWidth(), 
$file->getHeight(), $pages )->text();
-               } else {
-                       return wfMessage( 'widthheight' )
-                               ->numParams( $file->getWidth(), 
$file->getHeight() )->text();
                }
+
+               return wfMessage( 'widthheight' )
+                       ->numParams( $file->getWidth(), $file->getHeight() 
)->text();
        }
 }
diff --git a/includes/media/Jpeg.php b/includes/media/Jpeg.php
index ee7eff8..88a6b94 100644
--- a/includes/media/Jpeg.php
+++ b/includes/media/Jpeg.php
@@ -90,8 +90,8 @@
                        }
 
                        return false;
-               } else {
-                       return parent::rotate( $file, $params );
                }
+
+               return parent::rotate( $file, $params );
        }
 }
diff --git a/includes/media/JpegMetadataExtractor.php 
b/includes/media/JpegMetadataExtractor.php
index a0f8524..03992a6 100644
--- a/includes/media/JpegMetadataExtractor.php
+++ b/includes/media/JpegMetadataExtractor.php
@@ -282,8 +282,9 @@
                        return 'iptc-no-hash';
                } elseif ( $realHash === $recordedHash ) {
                        return 'iptc-good-hash';
-               } else { /*$realHash !== $recordedHash */
-                       return 'iptc-bad-hash';
                }
+
+               /*$realHash !== $recordedHash */
+               return 'iptc-bad-hash';
        }
 }
diff --git a/includes/media/MediaHandler.php b/includes/media/MediaHandler.php
index bb9108b..5dbaede 100644
--- a/includes/media/MediaHandler.php
+++ b/includes/media/MediaHandler.php
@@ -412,9 +412,9 @@
                                'width' => $gis[0],
                                'height' => $gis[1]
                        );
-               } else {
-                       return false;
                }
+
+               return false;
        }
 
        /**
@@ -536,6 +536,7 @@
                        wfDebug( __METHOD__ . ' Unknown metadata name: ' . $id 
. "\n" );
                        $name = wfEscapeWikiText( $id );
                }
+
                $array[$visibility][] = array(
                        'id' => "$type-$id",
                        'name' => $name,
@@ -606,9 +607,9 @@
                $roundedUp = ceil( $idealWidth );
                if ( round( $roundedUp * $boxHeight / $boxWidth ) > $maxHeight 
) {
                        return floor( $idealWidth );
-               } else {
-                       return $roundedUp;
                }
+
+               return $roundedUp;
        }
 
        /**
diff --git a/includes/media/MediaTransformOutput.php 
b/includes/media/MediaTransformOutput.php
index 9d89560..5dee8e9 100644
--- a/includes/media/MediaTransformOutput.php
+++ b/includes/media/MediaTransformOutput.php
@@ -172,9 +172,9 @@
                        $fsFile = $be->getLocalReference( array( 'src' => 
$this->path ) );
 
                        return $fsFile ? $fsFile->getPath() : false;
-               } else {
-                       return $this->path; // may return false
                }
+
+               return $this->path; // may return false
        }
 
        /**
@@ -190,9 +190,10 @@
                        $be = $this->file->getRepo()->getBackend();
 
                        return $be->streamFile( array( 'src' => $this->path, 
'headers' => $headers ) )->isOK();
-               } else { // FS-file
-                       return StreamFile::stream( $this->getLocalCopyPath(), 
$headers );
                }
+
+               // FS-file
+               return StreamFile::stream( $this->getLocalCopyPath(), $headers 
);
        }
 
        /**
@@ -205,9 +206,9 @@
        protected function linkWrap( $linkAttribs, $contents ) {
                if ( $linkAttribs ) {
                        return Xml::tags( 'a', $linkAttribs, $contents );
-               } else {
-                       return $contents;
                }
+
+               return $contents;
        }
 
        /**
diff --git a/includes/media/SVG.php b/includes/media/SVG.php
index 0a8d68f..8e9b474 100644
--- a/includes/media/SVG.php
+++ b/includes/media/SVG.php
@@ -46,9 +46,9 @@
                        wfDebug( "\$wgSVGConverter is invalid, disabling SVG 
rendering.\n" );
 
                        return false;
-               } else {
-                       return true;
                }
+
+               return true;
        }
 
        function mustRender( $file ) {
@@ -151,9 +151,9 @@
                $status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, 
$physicalHeight, $lang );
                if ( $status === true ) {
                        return new ThumbnailImage( $image, $dstUrl, $dstPath, 
$params );
-               } else {
-                       return $status; // MediaTransformError
                }
+
+               return $status; // MediaTransformError
        }
 
        /**
@@ -225,6 +225,7 @@
                if ( !$im->thumbnailImage( intval( $width ), intval( $height ), 
/* fit */ false ) ) {
                        return 'Could not resize image';
                }
+
                if ( !$im->writeImage( $dstPath ) ) {
                        return "Could not write to $dstPath";
                }
@@ -311,9 +312,9 @@
                wfRestoreWarnings();
                if ( isset( $unser['version'] ) && $unser['version'] == 
self::SVG_METADATA_VERSION ) {
                        return $unser;
-               } else {
-                       return false;
                }
+
+               return false;
        }
 
        function getMetadataType( $image ) {
@@ -325,6 +326,7 @@
                if ( $meta === false ) {
                        return self::METADATA_BAD;
                }
+
                if ( !isset( $meta['originalWidth'] ) ) {
                        // Old but compatible
                        return self::METADATA_COMPATIBLE;
@@ -433,9 +435,9 @@
                        return array( 'width' => array_pop( $m ), 'lang' => 
$m[1] );
                } elseif ( preg_match( '/^(\d+)px$/', $str, $m ) ) {
                        return array( 'width' => $m[1], 'lang' => 'en' );
-               } else {
-                       return false;
                }
+
+               return false;
        }
 
        function getParamMap() {
diff --git a/includes/media/SVGMetadataExtractor.php 
b/includes/media/SVGMetadataExtractor.php
index db58c62..31cf7f6 100644
--- a/includes/media/SVGMetadataExtractor.php
+++ b/includes/media/SVGMetadataExtractor.php
@@ -373,12 +373,12 @@
                        $unit = $matches[2];
                        if ( $unit == '%' ) {
                                return $length * 0.01 * $viewportSize;
-                       } else {
-                               return $length * $unitLength[$unit];
                        }
-               } else {
-                       // Assume pixels
-                       return floatval( $length );
+
+                       return $length * $unitLength[$unit];
                }
+
+               // Assume pixels
+               return floatval( $length );
        }
 }
diff --git a/includes/media/Tiff.php b/includes/media/Tiff.php
index 6964170..5bf21b9 100644
--- a/includes/media/Tiff.php
+++ b/includes/media/Tiff.php
@@ -93,8 +93,8 @@
 
                                return ExifBitmapHandler::BROKEN_FILE;
                        }
-               } else {
-                       return '';
                }
+
+               return '';
        }
 }
diff --git a/includes/media/XMPValidate.php b/includes/media/XMPValidate.php
index 4362217..0941442 100644
--- a/includes/media/XMPValidate.php
+++ b/includes/media/XMPValidate.php
@@ -370,12 +370,12 @@
                        $val = $coord;
 
                        return;
-               } else {
-                       wfDebugLog( 'XMP', __METHOD__
-                               . " Expected GPSCoordinate, but got $val." );
-                       $val = null;
-
-                       return;
                }
+
+               wfDebugLog( 'XMP', __METHOD__
+                       . " Expected GPSCoordinate, but got $val." );
+               $val = null;
+
+               return;
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id51688f2906a965af30adc3e9c66cc1fd02ebe04
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to