Merge "upload: Simplify file extension extraction in UploadBase"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 25 Mar 2019 06:33:58 +0000 (06:33 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 25 Mar 2019 06:33:58 +0000 (06:33 +0000)
1  2 
includes/upload/UploadBase.php

@@@ -947,8 -947,8 +947,8 @@@ abstract class UploadBase 
                 */
                list( $partname, $ext ) = $this->splitExtensions( $this->mFilteredName );
  
-               if ( count( $ext ) ) {
-                       $this->mFinalExtension = trim( $ext[count( $ext ) - 1] );
+               if ( $ext !== [] ) {
+                       $this->mFinalExtension = trim( end( $ext ) );
                } else {
                        $this->mFinalExtension = '';
  
         * scripts, so the blacklist needs to check them all.
         *
         * @param string $filename
 -       * @return array
 +       * @return array [ string, string[] ]
         */
        public static function splitExtensions( $filename ) {
                $bits = explode( '.', $filename );
         * Perform case-insensitive match against a list of file extensions.
         * Returns an array of matching extensions.
         *
 -       * @param array $ext
 -       * @param array $list
 +       * @param string[] $ext
 +       * @param string[] $list
         * @return bool
         */
        public static function checkFileExtensionList( $ext, $list ) {