Merge "parser: Validate $length in padleft/padright parser functions"
[lhc/web/wiklou.git] / includes / upload / UploadBase.php
index 064ca67..87b96ac 100644 (file)
@@ -160,7 +160,7 @@ abstract class UploadBase {
         * @return null|UploadBase
         */
        public static function createFromRequest( &$request, $type = null ) {
-               $type = $type ? $type : $request->getVal( 'wpSourceType', 'File' );
+               $type = $type ?: $request->getVal( 'wpSourceType', 'File' );
 
                if ( !$type ) {
                        return null;
@@ -854,7 +854,7 @@ abstract class UploadBase {
                        if ( !is_array( $error ) ) {
                                $error = [ $error ];
                        }
-                       return call_user_func_array( 'Status::newFatal', $error );
+                       return Status::newFatal( ...$error );
                }
 
                $status = $this->getLocalFile()->upload(
@@ -1063,7 +1063,7 @@ abstract class UploadBase {
                if ( !$isPartial ) {
                        $error = $this->runUploadStashFileHook( $user );
                        if ( $error ) {
-                               return call_user_func_array( 'Status::newFatal', $error );
+                               return Status::newFatal( ...$error );
                        }
                }
                try {
@@ -1397,7 +1397,7 @@ abstract class UploadBase {
         */
        public static function checkXMLEncodingMissmatch( $file ) {
                global $wgSVGMetadataCutoff;
-               $contents = file_get_contents( $file, false, null, -1, $wgSVGMetadataCutoff );
+               $contents = file_get_contents( $file, false, null, 0, $wgSVGMetadataCutoff );
                $encodingRegex = '!encoding[ \t\n\r]*=[ \t\n\r]*[\'"](.*?)[\'"]!si';
 
                if ( preg_match( "!<\?xml\b(.*?)\?>!si", $contents, $matches ) ) {
@@ -1864,8 +1864,7 @@ abstract class UploadBase {
                # look up scanner configuration
                $command = $wgAntivirusSetup[$wgAntivirus]['command'];
                $exitCodeMap = $wgAntivirusSetup[$wgAntivirus]['codemap'];
-               $msgPattern = isset( $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ) ?
-                       $wgAntivirusSetup[$wgAntivirus]['messagepattern'] : null;
+               $msgPattern = $wgAntivirusSetup[$wgAntivirus]['messagepattern'] ?? null;
 
                if ( strpos( $command, "%f" ) === false ) {
                        # simple pattern: append file to scan