X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fupload%2FUploadBase.php;h=9e92e78772f524811f483c42eea04bf7608ab77c;hp=d9e8e994980d23d4edbb17ed75034484f74b3fdd;hb=a38af7ba26579bb3004f673e44d39710887763aa;hpb=11d2280cf3e753295ab070ec1f4314a15709a812 diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index d9e8e99498..9e92e78772 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -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 = ''; @@ -1078,10 +1078,8 @@ abstract class UploadBase { $props = $this->mFileProps; $error = null; Hooks::run( 'UploadStashFile', [ $this, $user, $props, &$error ] ); - if ( $error ) { - if ( !is_array( $error ) ) { - $error = [ $error ]; - } + if ( $error && !is_array( $error ) ) { + $error = [ $error ]; } return $error; } @@ -1169,7 +1167,7 @@ abstract class UploadBase { * 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 ); @@ -1194,8 +1192,8 @@ abstract class UploadBase { * 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 ) { @@ -1916,10 +1914,8 @@ abstract class UploadBase { $output = true; # if there's no output, return true } elseif ( $msgPattern ) { $groups = []; - if ( preg_match( $msgPattern, $output, $groups ) ) { - if ( $groups[1] ) { - $output = $groups[1]; - } + if ( preg_match( $msgPattern, $output, $groups ) && $groups[1] ) { + $output = $groups[1]; } }